From a5445100050e49e83f73424198d73cd72d672a4d Mon Sep 17 00:00:00 2001 From: Michael Lando Date: Sun, 4 Mar 2018 14:53:33 +0200 Subject: Sync Integ to Master Change-Id: I71e3acc26fa612127756ac04073a522b9cc6cd74 Issue-ID: SDC-977 Signed-off-by: Gitelman, Tal (tg851x) --- test-apis-ci/pom.xml | 781 ++++---- .../sdc/ci/tests/api/ComponentBaseTest.java | 43 +- .../openecomp/sdc/ci/tests/api/ExtentManager.java | 12 +- .../sdc/ci/tests/api/ExtentTestActions.java | 6 +- .../sdc/ci/tests/api/ExtentTestManager.java | 4 +- .../java/org/openecomp/sdc/ci/tests/api/Urls.java | 438 ++--- .../org/openecomp/sdc/ci/tests/config/Config.java | 22 +- .../dataProviders/OnbordingDataProviders.java | 9 +- .../tests/datatypes/GroupHeatMetaDefinition.java | 12 +- .../sdc/ci/tests/datatypes/ImportReqDetails.java | 4 +- .../sdc/ci/tests/datatypes/PropertyObject.java | 90 + .../sdc/ci/tests/datatypes/ResourceReqDetails.java | 4 + .../datatypes/VendorSoftwareProductObject.java | 4 +- .../VendorSoftwareProductObjectReqDetails.java | 32 +- .../tests/datatypes/enums/GroupPropertyEnum.java | 46 + .../datatypes/enums/ResourceCategoryEnum.java | 5 + .../sdc/ci/tests/datatypes/enums/UserRoleEnum.java | 2 +- .../sdc/ci/tests/datatypes/http/HttpRequest.java | 921 +++------- .../execute/artifacts/ArtifactServletTest.java | 3 +- .../execute/artifacts/DownloadComponentArt.java | 5 +- .../execute/service/GetComponentAuditApiTest.java | 3 +- .../org/openecomp/sdc/ci/tests/sanity/Onboard.java | 9 +- .../datatypes/ToscaGroupPropertyDefinition.java | 112 ++ .../ToscaGroupsTopologyTemplateDefinition.java | 33 +- .../ToscaServiceGroupsMetadataDefinition.java | 10 +- .../datatypes/ToscaTopologyTemplateDefinition.java | 5 + .../sdc/ci/tests/utils/CsarParserUtils.java | 14 +- .../sdc/ci/tests/utils/DistributionUtils.java | 2 + .../sdc/ci/tests/utils/ToscaParserUtils.java | 6 +- .../org/openecomp/sdc/ci/tests/utils/Utils.java | 18 + .../ci/tests/utils/cassandra/CassandraUtils.java | 372 ++-- .../tests/utils/general/AtomicOperationUtils.java | 150 +- .../sdc/ci/tests/utils/general/ElementFactory.java | 88 +- .../sdc/ci/tests/utils/general/FileHandling.java | 13 +- .../sdc/ci/tests/utils/general/FileUtils.java | 3 +- .../utils/general/OnboardingUtillViaApis.java | 63 +- .../ci/tests/utils/general/OnboardingUtils.java | 1018 +---------- .../sdc/ci/tests/utils/general/SnmpTypeEnum.java | 50 + .../utils/general/VendorLicenseModelRestUtils.java | 285 +++ .../general/VendorSoftwareProductRestUtils.java | 697 ++++++++ .../sdc/ci/tests/utils/rest/ArtifactRestUtils.java | 137 +- .../sdc/ci/tests/utils/rest/AssetRestUtils.java | 61 +- .../sdc/ci/tests/utils/rest/AutomationUtils.java | 14 +- .../sdc/ci/tests/utils/rest/BaseRestUtils.java | 7 +- .../sdc/ci/tests/utils/rest/CatalogRestUtils.java | 2 +- .../utils/rest/ComponentInstanceRestUtils.java | 6 +- .../sdc/ci/tests/utils/rest/ConsumerRestUtils.java | 16 +- .../ci/tests/utils/rest/EcompUserRestUtils.java | 44 +- .../sdc/ci/tests/utils/rest/GroupRestUtils.java | 3 +- .../sdc/ci/tests/utils/rest/ImportRestUtils.java | 13 +- .../ci/tests/utils/rest/LifecycleRestUtils.java | 6 +- .../sdc/ci/tests/utils/rest/PropertyRestUtils.java | 58 +- .../sdc/ci/tests/utils/rest/ResourceRestUtils.java | 29 +- .../utils/rest/ResourceRestUtilsExternalAPI.java | 2 +- .../sdc/ci/tests/utils/rest/ResponseParser.java | 162 +- .../sdc/ci/tests/utils/rest/ServiceRestUtils.java | 25 +- .../sdc/ci/tests/utils/rest/UserRestUtils.java | 4 +- .../utils/validation/ArtifactValidationUtils.java | 30 +- .../utils/validation/AuditValidationUtils.java | 621 ++----- .../openecomp/sdc/externalApis/AssetLifeCycle.java | 198 +- .../sdc/externalApis/CRUDExternalAPI.java | 342 +--- .../sdc/externalApis/DeploymentValiditaion.java | 269 +-- .../sdc/externalApis/GetAssetServlet.java | 182 +- .../openecomp/sdc/externalApis/GetCSARofVF.java | 82 +- .../sdc/externalApis/GetFilteredAssetServlet.java | 584 +++--- .../GetSpecificAssetMetadataServlet.java | 100 +- .../SearchFilterCategoryExternalAPI.java | 50 +- .../sdc/externalApis/VFCMTExternalAPI.java | 112 +- .../src/main/resources/ci/conf/attsdc.yaml | 2 + .../resources/ci/scripts/addUsersFromList_new.sh | 4 +- .../src/main/resources/ci/scripts/sendMail.sh | 6 +- .../src/main/resources/ci/scripts/startTest.sh | 4 +- .../resources/ci/testSuites/ExternalApiSanity.xml | 68 + .../main/resources/ci/testSuites/externalAPIs.xml | 2 +- .../src/main/resources/ci/testSuites/onap.xml | 11 - .../sdc/conf/TestAPIConfDependentTest.java | 13 + .../runners/RunTenantIsolationCucumberCI.java | 31 + .../sdc/cucumber/spring/ImportTableConfig.java | 19 + .../steps/PrecannedTestExpectationCallback.java | 31 + .../sdc/cucumber/steps/StepsTenantIsolationCI.java | 597 +++++++ .../sdc/cucumber/utils/RunnerSession.java | 61 + .../tests/tenantIsolationCI/aai_error.properties | 10 + .../src/test/resources/catalogMgmtTest.properties | 34 + .../src/test/resources/catalogMgmtTest.yaml | 6 + .../src/test/resources/config/configuration1.yaml | 17 + .../src/test/resources/config/elasticsearch.yml | 387 ++++ .../config/test-apis-ci/DME2preferredRouter.txt | 0 .../config/test-apis-ci/configuration.yaml | 677 +++++++ .../distribution-engine-configuration.yaml | 77 + .../test-apis-ci/ecomp-error-configuration.yaml | 383 ++++ .../config/test-apis-ci/error-configuration.yaml | 1883 ++++++++++++++++++++ .../test-apis-ci/neo4j-errors-configuration.yaml | 60 + .../config/test-apis-ci/users-configuration.yaml | 2 + .../resources/cucumber/tenantIsolation.feature | 38 + .../src/test/resources/preferredRouter.txt | 0 95 files changed, 8387 insertions(+), 4589 deletions(-) create mode 100644 test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/PropertyObject.java create mode 100644 test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/GroupPropertyEnum.java create mode 100644 test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupPropertyDefinition.java create mode 100644 test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/VendorLicenseModelRestUtils.java create mode 100644 test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/VendorSoftwareProductRestUtils.java create mode 100644 test-apis-ci/src/main/resources/ci/testSuites/ExternalApiSanity.xml create mode 100644 test-apis-ci/src/test/java/org/openecomp/sdc/conf/TestAPIConfDependentTest.java create mode 100644 test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/runners/RunTenantIsolationCucumberCI.java create mode 100644 test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/spring/ImportTableConfig.java create mode 100644 test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/steps/PrecannedTestExpectationCallback.java create mode 100644 test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/steps/StepsTenantIsolationCI.java create mode 100644 test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/utils/RunnerSession.java create mode 100644 test-apis-ci/src/test/resources/CI/tests/tenantIsolationCI/aai_error.properties create mode 100644 test-apis-ci/src/test/resources/catalogMgmtTest.properties create mode 100644 test-apis-ci/src/test/resources/catalogMgmtTest.yaml create mode 100644 test-apis-ci/src/test/resources/config/configuration1.yaml create mode 100644 test-apis-ci/src/test/resources/config/elasticsearch.yml create mode 100644 test-apis-ci/src/test/resources/config/test-apis-ci/DME2preferredRouter.txt create mode 100644 test-apis-ci/src/test/resources/config/test-apis-ci/configuration.yaml create mode 100644 test-apis-ci/src/test/resources/config/test-apis-ci/distribution-engine-configuration.yaml create mode 100644 test-apis-ci/src/test/resources/config/test-apis-ci/ecomp-error-configuration.yaml create mode 100644 test-apis-ci/src/test/resources/config/test-apis-ci/error-configuration.yaml create mode 100644 test-apis-ci/src/test/resources/config/test-apis-ci/neo4j-errors-configuration.yaml create mode 100644 test-apis-ci/src/test/resources/config/test-apis-ci/users-configuration.yaml create mode 100644 test-apis-ci/src/test/resources/cucumber/tenantIsolation.feature create mode 100644 test-apis-ci/src/test/resources/preferredRouter.txt (limited to 'test-apis-ci') diff --git a/test-apis-ci/pom.xml b/test-apis-ci/pom.xml index 59dc3fd433..ef0eff467c 100644 --- a/test-apis-ci/pom.xml +++ b/test-apis-ci/pom.xml @@ -1,359 +1,450 @@ - - 4.0.0 - - test-apis-ci - - - org.openecomp.sdc - sdc-main - 1.2.0-SNAPSHOT - - - - true - - - - - com.google.guava - guava - ${guava.version} - compile - - - - junit - junit - ${junit.version} - compile - - - - org.testng - testng - ${testng.version} - compile - - - - com.aventstack - extentreports - 3.0.6 - compile - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - com.typesafe - config - 1.0.2 - compile - - - - log4j - log4j - 1.2.17 - compile - - - - com.jcraft.jsch - com.springsource.com.jcraft.jsch - 0.1.41 - compile - - - - org.openecomp.sdc - common-app-api - ${project.version} - compile - - - - org.openecomp.sdc.be - common-be - ${project.version} - compile - - - - - org.openecomp.sdc.be - catalog-model - ${project.version} - compile - - - - - org.openecomp.sdc.be - catalog-dao - ${project.version} - compile - - - - org.functionaljava - functionaljava - ${functionaljava.version} - compile - - - - com.datastax.cassandra - cassandra-driver-core - ${cassandra.driver.version} - compile - - - - - - org.slf4j - slf4j-api + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + 4.0.0 + + test-apis-ci + + + org.openecomp.sdc + sdc-main + 1.2.0-SNAPSHOT + + + + + com.google.guava + guava + ${guava.version} + compile + + + + junit + junit + ${junit.version} + compile + + + + org.hamcrest + hamcrest-all + 1.3 + test + + + org.testng + testng + ${testng.version} + compile + + + + com.aventstack + extentreports + 3.0.6 + compile + + + + org.mockito + mockito-core + test + + + + com.typesafe + config + 1.0.2 + compile + + + + log4j + log4j + 1.2.17 + compile + + + + com.jcraft.jsch + com.springsource.com.jcraft.jsch + 0.1.41 + compile + + + + + + org.openecomp.sdc + common-app-api + ${project.version} + compile + + + + org.openecomp.sdc.be + common-be + ${project.version} + compile + + + + + org.openecomp.sdc.be + catalog-model + ${project.version} + compile + + + + + org.openecomp.sdc.be + catalog-dao + ${project.version} + compile + + + + org.functionaljava + functionaljava + ${functionaljava.version} + compile + + + + com.datastax.cassandra + cassandra-driver-core + ${cassandra.driver.version} + compile + + + + + + org.slf4j + slf4j-api ${slf4j-api.version} - compile - + compile + - - ch.qos.logback - logback-classic + + ch.qos.logback + logback-classic ${logback.version} - compile - + compile + - - ch.qos.logback - logback-core + + ch.qos.logback + logback-core ${logback.version} - compile - - - - com.googlecode.json-simple - json-simple - ${json-simple.version} - compile - - - - - org.apache.commons - commons-jci-core - ${commons-jci-core.version} - compile - - - - commons-codec - commons-codec + compile + + + + com.googlecode.json-simple + json-simple + ${json-simple.version} + compile + + + + + org.apache.commons + commons-jci-core + ${commons-jci-core.version} + compile + + + + commons-codec + commons-codec ${commons-codec} - compile - - - - - com.google.code.gson - gson - ${gson.version} - compile - - - - - org.yaml - snakeyaml - ${snakeyaml.version} - compile - - - - - org.apache.httpcomponents - httpclient + compile + + + + + com.google.code.gson + gson + ${gson.version} + compile + + + + + org.yaml + snakeyaml + ${snakeyaml.version} + compile + + + + + org.apache.httpcomponents + httpclient ${httpclient.version} - compile - + compile + - - org.apache.httpcomponents - httpmime + + org.apache.httpcomponents + httpmime ${httpclient.version} - compile - - - - commons-io - commons-io - 2.5 - compile - - - - commons-logging - commons-logging + compile + + + + commons-io + commons-io + 2.5 + compile + + + + commons-logging + commons-logging ${commons-logging} - compile - - - - - org.apache.httpcomponents - httpcore - ${httpcore.version} - compile - - - - - com.thinkaurelius.titan - titan-core - ${titan.version} - compile - - - slf4j-log4j12 - org.slf4j - - - - - - org.openecomp.sdc.sdc-titan-cassandra - sdc-titan-cassandra - ${titan.version} - compile - - - slf4j-log4j12 - org.slf4j - - - - - - org.codehaus.jackson - jackson-mapper-asl - 1.9.2 - compile - - - - com.fasterxml.jackson.core - jackson-databind - 2.3.1 - compile - - - - com.fasterxml.jackson.core - jackson-core - 2.3.1 - compile - - - - org.openecomp.ecompsdkos - epsdk-fw - ${ecomp.version} - compile - - - slf4j-log4j12 - org.slf4j - - - - - - org.json - json - 20090211 - - - org.openecomp.sdc.sdc-tosca - sdc-tosca - ${sdc-tosca-parser.version} - compile - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.apache.maven.plugins - maven-deploy-plugin - 2.7 - - true - - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - create.jar.with.dependencies - package - - single - - - - - org.openecomp.sdc.ci.tests.run.StartTest - - - - jar-with-dependencies - - - - - - - + compile + + + + + org.apache.httpcomponents + httpcore + ${httpcore.version} + compile + + + + + com.thinkaurelius.titan + titan-core + ${titan.version} + compile + + + slf4j-log4j12 + org.slf4j + + + + + + com.thinkaurelius.titan + titan-cassandra + ${titan.version} + compile + + + slf4j-log4j12 + org.slf4j + + + + + + org.codehaus.jackson + jackson-mapper-asl + 1.9.2 + compile + + + + com.fasterxml.jackson.core + jackson-databind + 2.3.1 + compile + + + + com.fasterxml.jackson.core + jackson-core + 2.3.1 + compile + + + + org.openecomp.ecompsdkos + epsdk-fw + ${ecomp.version} + compile + + + slf4j-log4j12 + org.slf4j + + + + + + org.json + json + 20131018 + + + + org.openecomp.sdc.sdc-tosca + sdc-tosca + 1.2.1-SNAPSHOT + compile + + + + info.cukes + cucumber-junit + 1.2.4 + test + + + + info.cukes + cucumber-core + 1.2.4 + test + + + + info.cukes + gherkin + 2.12.2 + + + info.cukes + cucumber-java + 1.2.5 + test + + + + info.cukes + cucumber-jvm-deps + 1.0.5 + + + + org.mock-server + mockserver-netty + 3.10.4 + test + + + + org.openecomp.sdc.sdc-distribution-client + sdc-distribution-client + 1.2.2 + test + + + + + info.cukes + cucumber-testng + 1.2.5 + + + + + org.springframework + spring-context + ${spring.version} + compile + + + + + com.datastax.cassandra + cassandra-driver-mapping + ${cassandra.driver.version} + compile + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + 2.7 + + true + + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + create.jar.with.dependencies + package + + single + + + + + org.openecomp.sdc.ci.tests.run.StartTest + + + + jar-with-dependencies + + + + + + + diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentBaseTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentBaseTest.java index a49d5c61fe..1d0b4040ca 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentBaseTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentBaseTest.java @@ -37,6 +37,7 @@ import java.util.stream.Collectors; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.ImmutableTriple; +import org.apache.log4j.Logger; import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.rules.TestName; @@ -66,15 +67,10 @@ import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils; -import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.ITestContext; import org.testng.ITestResult; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.AfterSuite; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeSuite; +import org.testng.annotations.*; import com.aventstack.extentreports.ExtentTest; import com.aventstack.extentreports.Status; @@ -85,11 +81,17 @@ import com.thinkaurelius.titan.core.TitanVertex; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.LoggerContext; - public abstract class ComponentBaseTest { +// private static Logger logger = LoggerFactory.getLogger(ComponentBaseTest.class.getName()); + + protected static Logger logger= Logger.getLogger(ComponentBaseTest.class); + + +// public ComponentBaseTest(TestName testName, String className) { +// super(testName, className); +// } - protected static Logger logger= LoggerFactory.getLogger(ComponentBaseTest.class); protected static final String REPORT_FOLDER = "." + File.separator + "ExtentReport" + File.separator; private static final String VERSIONS_INFO_FILE_NAME = "versions.info"; private static final String REPORT_FILE_NAME = "SDC_CI_Extent_Report.html"; @@ -127,16 +129,16 @@ public abstract class ComponentBaseTest { myContext=context; ExtentManager.initReporter(getReportFolder(), REPORT_FILE_NAME, context); AtomicOperationUtils.createDefaultConsumer(true); - openTitanLogic(); +// openTitanLogic(); performClean(); - - + + } @BeforeMethod(alwaysRun = true) public void setupBeforeTest(java.lang.reflect.Method method, ITestContext context) throws Exception { - + System.out.println(" method.getName() " + method.getName()); if (!method.getName().equals("onboardVNFShotFlow")) { // System.out.println("ExtentReport instance started from BeforeMethod..."); @@ -182,7 +184,7 @@ public abstract class ComponentBaseTest { } - @AfterClass(alwaysRun = true) +/* @AfterClass(alwaysRun = true) public synchronized static void cleanAfterClass() throws Exception{ // System.out.println("<<<<<<<>>>>"+method.getDeclaringClass()); @@ -190,19 +192,23 @@ public abstract class ComponentBaseTest { System.out.println("delete components AfterClass"); - deleteCreatedComponents(getCatalogAsMap()); + if(!config.getSystemUnderDebug()){ + deleteCreatedComponents(getCatalogAsMap()); +// CassandraUtils.truncateAllKeyspaces(); + }else{ + System.out.println("Accordindig to configuration components will not be deleted, in case to unable option to delete, please change systemUnderDebug parameter value to false ..."); + } // extentReport.flush(); - } + }*/ @AfterSuite(alwaysRun = true) public static void shutdownTitan() throws Exception { performClean(); - shutdownTitanLogic(); +// shutdownTitanLogic(); } - protected static void openTitanLogic() throws Exception { logger.trace(config.toString()); @@ -234,9 +240,8 @@ public abstract class ComponentBaseTest { // cleanComponents(); if(!config.getSystemUnderDebug()){ deleteCreatedComponents(getCatalogAsMap()); - CassandraUtils.truncateAllKeyspaces(); +// CassandraUtils.truncateAllKeyspaces(); FileHandling.overWriteExistindDir("outputCsar"); - }else{ System.out.println("Accordindig to configuration components will not be deleted, in case to unable option to delete, please change systemUnderDebug parameter value to false ..."); } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentManager.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentManager.java index 26edee9c7f..b320f4200e 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentManager.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentManager.java @@ -20,19 +20,23 @@ package org.openecomp.sdc.ci.tests.api; -import java.io.File; - import org.openecomp.sdc.ci.tests.config.Config; import org.openecomp.sdc.ci.tests.utils.Utils; import org.openecomp.sdc.ci.tests.utils.general.FileHandling; -import org.openecomp.sdc.ci.tests.utils.rest.AutomationUtils; import org.testng.ITestContext; - import com.aventstack.extentreports.ExtentReports; import com.aventstack.extentreports.reporter.ExtentHtmlReporter; import com.aventstack.extentreports.reporter.ExtentXReporter; import com.aventstack.extentreports.reporter.configuration.Protocol; import com.aventstack.extentreports.reporter.configuration.Theme; +import org.openecomp.sdc.ci.tests.config.Config; + +import org.openecomp.sdc.ci.tests.utils.Utils; +import org.openecomp.sdc.ci.tests.utils.general.FileHandling; +import org.openecomp.sdc.ci.tests.utils.rest.AutomationUtils; +import org.testng.ITestContext; + +import java.io.File; public class ExtentManager { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentTestActions.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentTestActions.java index 045d565a41..2c242d00bd 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentTestActions.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentTestActions.java @@ -20,14 +20,16 @@ package org.openecomp.sdc.ci.tests.api; -import java.io.File; - import com.aventstack.extentreports.ExtentTest; +import com.aventstack.extentreports.MediaEntityBuilder; import com.aventstack.extentreports.Status; import com.aventstack.extentreports.markuputils.ExtentColor; import com.aventstack.extentreports.markuputils.Markup; import com.aventstack.extentreports.markuputils.MarkupHelper; +import java.io.File; +import org.openecomp.sdc.ci.tests.api.ExtentTestManager; + public class ExtentTestActions { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentTestManager.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentTestManager.java index b525150af4..810f6a6543 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentTestManager.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentTestManager.java @@ -20,12 +20,12 @@ package org.openecomp.sdc.ci.tests.api; -import java.util.HashMap; - import com.aventstack.extentreports.ExtentReports; import com.aventstack.extentreports.ExtentTest; +import java.util.HashMap; public class ExtentTestManager implements SomeInterface{ + private static HashMap extentTestMap = new HashMap(); private static ExtentReports extent = ExtentManager.getReporter(); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java index fd6e9eebc0..b908dddf48 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java @@ -20,220 +20,224 @@ package org.openecomp.sdc.ci.tests.api; + +import org.openecomp.sdc.ci.tests.utils.Utils; + +import java.io.FileNotFoundException; + public interface Urls { - final String UPLOAD_ZIP_URL = "http://%s:%s/sdc1/rest/v1/catalog/resources"; - final String GET_IMAGE_DATA_FROM_ES = "http://%s:%s/resources/imagedata/_search?q=resourceName:%s&pretty=true&size=1000"; - final String GET_SCRIPT_DATA_FROM_ES = "http://%s:%s/resources/artifactdata/_search?q=resourceName:%s&pretty=true&size=1000"; - final String GET_ID_LIST_BY_INDEX_FROM_ES = "http://%s:%s/%s/%s/_search?fields=_id&size=1000"; - final String ES_URL = "http://%s:%s"; - final String GET_SERVICE_CSAR_API1 = "http://%s:%s/sdc2/rest/services/%s/%s"; - final String GET_SERVICE_CSAR_API2 = "http://%s:%s/sdc2/rest/services/%s/%s/csar"; + final static String SDC_HTTP_METHOD = Utils.getConfigHandleException() == null ? "http" : Utils.getConfigHandleException().getSdcHttpMethod(); + final String AMDOCS_HTTP_METHOD = SDC_HTTP_METHOD; + - final String GET_SERVICE_CSAR_FE_PROXY_API1 = "http://%s:%s/sdc1/portal/rest/services/%s/%s"; - final String GET_CSAR_USING_SIMULATOR = "http://%s:%s/onboardingci/onbrest/onboarding-api/v1.0/vendor-software-products/packages/%s"; - final String COPY_CSAR_USING_SIMULATOR = "http://%s:%s/onboardingci/onbrest/onboarding-api/v1.0/vendor-software-products/packages/%s/%s"; + final String UPLOAD_ZIP_URL = SDC_HTTP_METHOD + "://%s:%s/sdc1/rest/v1/catalog/resources"; + final String GET_IMAGE_DATA_FROM_ES = SDC_HTTP_METHOD + "://%s:%s/resources/imagedata/_search?q=resourceName:%s&pretty=true&size=1000"; + final String GET_SCRIPT_DATA_FROM_ES = SDC_HTTP_METHOD + "://%s:%s/resources/artifactdata/_search?q=resourceName:%s&pretty=true&size=1000"; + final String GET_ID_LIST_BY_INDEX_FROM_ES = SDC_HTTP_METHOD + "://%s:%s/%s/%s/_search?fields=_id&size=1000"; - final String GET_HEALTH_CHECK_VIA_PROXY = "http://%s:%s/sdc1/rest/healthCheck"; + final String ES_URL = SDC_HTTP_METHOD + "://%s:%s"; + final String GET_SERVICE_CSAR_API1 = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/services/%s/%s"; + final String GET_SERVICE_CSAR_API2 = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/services/%s/%s/csar"; + + final String GET_SERVICE_CSAR_FE_PROXY_API1 = SDC_HTTP_METHOD + "://%s:%s/sdc1/portal/rest/services/%s/%s"; + final String GET_CSAR_USING_SIMULATOR = SDC_HTTP_METHOD + "://%s:%s/onboardingci/onbrest/onboarding-api/v1.0/vendor-software-products/packages/%s"; + final String COPY_CSAR_USING_SIMULATOR = SDC_HTTP_METHOD + "://%s:%s/onboardingci/onbrest/onboarding-api/v1.0/vendor-software-products/packages/%s/%s"; + + final String GET_HEALTH_CHECK_VIA_PROXY = SDC_HTTP_METHOD + "://%s:%s/sdc1/rest/healthCheck"; // Get back-end config http://172.20.43.132:8080/sdc2/rest/configmgr/get - final String GET_CONFIG_MANAGER = "http://%s:%s/sdc2/rest/configmgr/get"; + final String GET_CONFIG_MANAGER = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/configmgr/get"; // Get latest version of all non-abstract resources - final String GET_RESOURCE_lATEST_VERSION = "http://%s:%s/sdc2/rest/v1/catalog/resources/latestversion/notabstract"; + final String GET_RESOURCE_lATEST_VERSION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/latestversion/notabstract"; - final String GET_SERVICE_lATEST_VERSION = "http://%s:%s/sdc2/rest/v1/catalog/services/latestversion/notabstract"; + final String GET_SERVICE_lATEST_VERSION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/latestversion/notabstract"; // Get resource artifact list: // http://172.20.43.124:8080/sdc2/rest/v1/catalog/resources/alien.nodes.Apache/2.0.0-SNAPSHOT/artifacts - final String GET_RESOURCE_ARTIFACTS_LIST = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s/artifacts"; + final String GET_RESOURCE_ARTIFACTS_LIST = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s/artifacts"; // get resource artifact metadata (creation, MD5, etc): // http://172.20.43.124:8080/sdc2/rest/v1/catalog/resources/alien.nodes.Apache/2.0.0-SNAPSHOT/artifacts/install_apache.sh/metadata - final String GET_RESOURCE_ARTIFACT_METADATA = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s/artifacts/%s/metadata"; + final String GET_RESOURCE_ARTIFACT_METADATA = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s/artifacts/%s/metadata"; // resource artifact payload: // http://172.20.43.124:8080/sdc2/rest/v1/catalog/resources/alien.nodes.Apache/2.0.0-SNAPSHOT/artifacts/install_apache.sh - final String GET_RESOURCE_ARTIFACT_PAYLOAD = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s/artifacts/%s"; - - final String GET_RESOURCE_ARTIFACT_PAYLOAD_FE_PROXY = "http://%s:%s/sdc1/portal/rest/v1/catalog/resources/%s/%s/artifacts/%s"; - - // Get service list: http://172.20.43.124:8080/sdc2/rest/v1/catalog/services - final String GET_SERVICE_LIST = "http://%s:%s/sdc2/rest/v1/catalog/services"; + final String GET_RESOURCE_ARTIFACT_PAYLOAD = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s/artifacts/%s"; - // Get service versions: - // http://172.20.43.124:8080/sdc2/rest/v1/catalog/services/MyService - final String GET_SERVICE_VERSIONS = "http://%s:%s/sdc2/rest/v1/catalog/services/%s"; + final String GET_RESOURCE_ARTIFACT_PAYLOAD_FE_PROXY = SDC_HTTP_METHOD + "://%s:%s/sdc1/portal/rest/v1/catalog/resources/%s/%s/artifacts/%s"; // Get service artifact list: // http://172.20.43.124:8080/sdc2/rest/v1/catalog/services/alien.nodes.Apache/0.0.1/artifacts - final String GET_SERVICE_ARTIFACTS_LIST = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/%s/artifacts"; + final String GET_SERVICE_ARTIFACTS_LIST = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/%s/artifacts"; // get service artifact metadata (creation, MD5, etc): // http://172.20.43.124:8080/sdc2/rest/v1/catalog/services/alien.nodes.Apache/0.0.1/artifacts/install_apache.sh/metadata - final String GET_SERVICE_METADATA = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/%s/artifacts/%s/metadata"; + final String GET_SERVICE_METADATA = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/%s/artifacts/%s/metadata"; // service artifact payload: // http://172.20.43.124:8080/sdc2/rest/v1/catalog/services/alien.nodes.Apache/0.0.1/artifacts/install_apache.sh - final String GET_SERVICE_ARTIFACT_PAYLOAD = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s/artifacts/%s"; + final String GET_SERVICE_ARTIFACT_PAYLOAD = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/%s/artifacts/%s"; - final String GET_SEARCH_DATA_FROM_ES = "http://%s:%s/%s"; + final String GET_SEARCH_DATA_FROM_ES = SDC_HTTP_METHOD + "://%s:%s/%s"; // ****************************************************USER // URLs******************************************************** - final String GET_USER = "http://%s:%s/sdc2/rest/v1/user/%s"; + final String GET_USER = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user/%s"; - final String GET_USER_ROLE = "http://%s:%s/sdc2/rest/v1/user/%s/role"; + final String GET_USER_ROLE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user/%s/role"; - final String CREATE_USER = "http://%s:%s/sdc2/rest/v1/user"; + final String CREATE_USER = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user"; - final String UPDATE_USER = "http://%s:%s/sdc2/rest/v1/user/%s"; + final String UPDATE_USER = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user/%s"; - final String UPDATE_USER_ROLE = "http://%s:%s/sdc2/rest/v1/user/%s/role"; + final String UPDATE_USER_ROLE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user/%s/role"; - final String DELETE_USER = "http://%s:%s/sdc2/rest/v1/user/%s"; + String DELETE_USER = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user/%s"; - final String GET_ALL_ADMIN_USERS = "http://%s:%s/sdc2/rest/v1/user/admins"; + String GET_ALL_ADMIN_USERS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user/admins"; - final String AUTHORIZE_USER = "http://%s:%s/sdc2/rest/v1/user/authorize"; + final String AUTHORIZE_USER = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user/authorize"; - final String GET_ALL_TAGS = "http://%s:%s/sdc2/rest/v1/tags"; + final String GET_ALL_TAGS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/tags"; - final String AUTH_USER = "http://%s:%s/sdc2/rest/v1/user/authorize"; + final String AUTH_USER = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user/authorize"; - final String GET_ALL_NOT_ABSTRACT_RESOURCES = "http://%s:%s/sdc2/rest/v1/catalog/resources/certified/notabstract"; + final String GET_ALL_NOT_ABSTRACT_RESOURCES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/certified/notabstract"; - final String GET_ALL_ABSTRACT_RESOURCES = "http://%s:%s/sdc2/rest/v1/catalog/resources/certified/abstract"; + final String GET_ALL_ABSTRACT_RESOURCES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/certified/abstract"; - final String QUERY_NEO4J = "http://%s:%s/db/data/transaction"; - final String CHANGE_IN_NEO4J = "http://%s:%s/db/data/transaction/commit"; + final String QUERY_NEO4J = SDC_HTTP_METHOD + "://%s:%s/db/data/transaction"; + final String CHANGE_IN_NEO4J = SDC_HTTP_METHOD + "://%s:%s/db/data/transaction/commit"; - final String GET_ALL_ADMINS = "http://%s:%s/sdc2/rest/v1/user/admins"; + final String GET_ALL_ADMINS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user/admins"; - final String GET_USERS_BY_ROLES = "http://%s:%s/sdc2/rest/v1/user/users?roles=%s"; + final String GET_USERS_BY_ROLES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user/users?roles=%s"; - final String GET_ALL_USERS = "http://%s:%s/sdc2/rest/v1/user/users?roles/"; + final String GET_ALL_USERS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user/users?roles/"; // *****************************************ECOMP User // URL's***************************************************** - final String ECOMP_PUSH_USER = "http://%s:%s/api/v2/user"; + final String ECOMP_PUSH_USER = SDC_HTTP_METHOD + "://%s:%s/api/v2/user"; - final String ECOMP_EDIT_USER = "http://%s:%s/api/v2/user/%s"; + final String ECOMP_EDIT_USER = SDC_HTTP_METHOD + "://%s:%s/api/v2/user/%s"; - final String ECOMP_GET_USER = "http://%s:%s/api/v2/user/%s"; + final String ECOMP_GET_USER = SDC_HTTP_METHOD + "://%s:%s/api/v2/user/%s"; - final String ECOMP_GET_ALL_USERS = "http://%s:%s/api/v2/users"; + final String ECOMP_GET_ALL_USERS = SDC_HTTP_METHOD + "://%s:%s/api/v2/users"; - final String ECOMP_GET_ALL_AVAILABLE_ROLES = "http://%s:%s/api/v2/roles"; + final String ECOMP_GET_ALL_AVAILABLE_ROLES = SDC_HTTP_METHOD + "://%s:%s/api/v2/roles"; - final String ECOMP_PUSH_USER_ROLES = "http://%s:%s/api/v2/user/%s/roles"; + final String ECOMP_PUSH_USER_ROLES = SDC_HTTP_METHOD + "://%s:%s/api/v2/user/%s/roles"; - final String ECOMP_GET_USER_ROLES = "http://%s:%s/api/v2/user/%s/roles"; + final String ECOMP_GET_USER_ROLES = SDC_HTTP_METHOD + "://%s:%s/api/v2/user/%s/roles"; // *****************************************Elements************************************************************* - final String GET_TAGS_LIST = "http://%s:%s/sdc2/rest/v1/tags"; + final String GET_TAGS_LIST = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/tags"; - final String GET_PROPERTY_SCOPES_LIST = "http://%s:%s/sdc2/rest/v1/propertyScopes"; + final String GET_PROPERTY_SCOPES_LIST = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/propertyScopes"; - final String GET_CONFIGURATION = "http://%s:%s/sdc2/rest/v1/configuration/ui"; + final String GET_CONFIGURATION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/configuration/ui"; - final String GET_ALL_ARTIFACTS = "http://%s:%s/sdc2/rest/v1/artifactTypes"; + final String GET_ALL_ARTIFACTS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/artifactTypes"; - final String GET_FOLLWED_LIST = "http://%s:%s/sdc2/rest/v1/followed"; + final String GET_FOLLWED_LIST = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/followed"; - final String GET_CATALOG_DATA = "http://%s:%s/sdc2/rest/v1/screen/?excludeTypes=VFCMT&excludeTypes=Configuration"; + final String GET_CATALOG_DATA = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/screen/?excludeTypes=VFCMT&excludeTypes=Configuration"; // *****************************************Resources // ********************************************************************** - final String GET_LIST_CERTIFIED_RESOURCE_TEMPLATES = "http://%s:%s/sdc2/rest/v1/resoourceTemplates"; + final String GET_LIST_CERTIFIED_RESOURCE_TEMPLATES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/resoourceTemplates"; - final String CREATE_RESOURCE = "http://%s:%s/sdc2/rest/v1/catalog/resources"; - final String UPDATE_RESOURCE = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s"; + final String CREATE_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources"; + final String UPDATE_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s"; - final String IMPORT_RESOURCE_NORMATIVE = "http://%s:%s/sdc2/rest/v1/catalog/upload/multipart"; + final String IMPORT_RESOURCE_NORMATIVE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/upload/multipart"; - final String IMPORT_USER_RESOURCE = "http://%s:%s/sdc2/rest/v1/catalog/upload/user-resource"; + final String IMPORT_USER_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/upload/user-resource"; - final String IMPORT_CAPABILITY_TYPE = "http://%s:%s/sdc2/rest/v1/catalog/uploadType/capability"; - final String IMPORT_CATEGORIES = "http://%s:%s/sdc2/rest/v1/catalog/uploadType/categories"; - final String IMPORT_GROUP_TYPE = "http://%s:%s/sdc2/rest/v1/catalog/uploadType/grouptypes"; + final String IMPORT_CAPABILITY_TYPE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/uploadType/capability"; + final String IMPORT_CATEGORIES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/uploadType/categories"; + final String IMPORT_GROUP_TYPE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/uploadType/grouptypes"; // last %s is resourceId, resourceId = resourceName.resourceVersion - final String GET_RESOURCE = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s"; - final String GET_RESOURCE_BY_NAME_AND_VERSION = "http://%s:%s/sdc2/rest/v1/catalog/resources/resourceName/%s/resourceVersion/%s"; - final String GET_RESOURCE_BY_CSAR_UUID = "http://%s:%s/sdc2/rest/v1/catalog/resources/csar/%s"; - final String GET_COMPONENT_REQUIRMENTS_CAPABILITIES = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/requirmentsCapabilities"; + final String GET_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s"; + final String GET_RESOURCE_BY_NAME_AND_VERSION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/resourceName/%s/resourceVersion/%s"; + final String GET_RESOURCE_BY_CSAR_UUID = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/csar/%s"; + final String GET_COMPONENT_REQUIRMENTS_CAPABILITIES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/requirmentsCapabilities"; - final String DELETE_RESOURCE = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s"; - final String DELETE_RESOURCE_BY_NAME_AND_VERSION = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s"; - final String DELETE_SERVICE_BY_NAME_AND_VERSION = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/%s"; + final String DELETE_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s"; + final String DELETE_RESOURCE_BY_NAME_AND_VERSION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s"; + final String DELETE_SERVICE_BY_NAME_AND_VERSION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/%s"; - final String DELETE_MARKED_RESOURCES = "http://%s:%s/sdc2/rest/v1/inactiveComponents/resource"; - final String DELETE_MARKED_SERVICES = "http://%s:%s/sdc2/rest/v1/inactiveComponents/service"; + final String DELETE_MARKED_RESOURCES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/inactiveComponents/resource"; + final String DELETE_MARKED_SERVICES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/inactiveComponents/service"; - final String GET_FOLLOWED_RESOURCES = "http://%s:%s/sdc2/rest/v1/followed/resources/%s"; - final String CHANGE_RESOURCE_LIFECYCLE_STATE = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/lifecycleState/%s"; - final String CHANGE_SERVICE_LIFECYCLE_STATE = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/lifecycleState/%s"; - final String CHANGE_PRODUCT_LIFECYCLE_STATE = "http://%s:%s/sdc2/rest/v1/catalog/products/%s/lifecycleState/%s"; - final String CHANGE_COMPONENT_LIFECYCLE_STATE = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/lifecycleState/%s"; + final String GET_FOLLOWED_RESOURCES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/followed/resources/%s"; + final String CHANGE_RESOURCE_LIFECYCLE_STATE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/lifecycleState/%s"; + final String CHANGE_SERVICE_LIFECYCLE_STATE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/lifecycleState/%s"; + final String CHANGE_PRODUCT_LIFECYCLE_STATE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/products/%s/lifecycleState/%s"; + final String CHANGE_COMPONENT_LIFECYCLE_STATE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/lifecycleState/%s"; - final String CREATE_PROPERTY = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/properties"; - final String DECLARE_PROPERTIES = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/create/inputs"; + final String CREATE_PROPERTY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/properties"; + final String DECLARE_PROPERTIES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/create/inputs"; + final String UPDATE_INPUT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/update/inputs"; - final String UPDATE_RESOURCE_METADATA = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/metadata"; + final String UPDATE_RESOURCE_METADATA = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/metadata"; // ***********************************External API's // (AssetData)**************************************** - - final String DELETE_EXTRNAL_API_DELETE_ARTIFACT_OF_ASSET = "http://%s:%s/sdc/v1/catalog/%s/%s/artifacts/%s"; - final String DELETE_EXTRNAL_API_DELETE_ARTIFACT_OF_COMPONENTINSTANCE_ON_ASSET = "http://%s:%s/sdc/v1/catalog/%s/%s/resourceInstances/%s/artifacts/%s"; - final String POST_EXTERNAL_API_UPDATE_ARTIFACT_OF_ASSET = "http://%s:%s/sdc/v1/catalog/%s/%s/artifacts/%s"; - final String POST_EXTERNAL_API_UPDATE_ARTIFACT_OF_COMPONENTINSTANCE_ON_ASSET = "http://%s:%s/sdc/v1/catalog/%s/%s/resourceInstances/%s/artifacts/%s"; - - final String POST_EXTERNAL_API_UPLOAD_ARTIFACT_OF_ASSET = "http://%s:%s/sdc/v1/catalog/%s/%s/artifacts"; - final String POST_EXTERNAL_API_UPLOAD_ARTIFACT_OF_COMPONENTINSTANCE_ON_ASSET = "http://%s:%s/sdc/v1/catalog/%s/%s/resourceInstances/%s/artifacts"; + final String DELETE_EXTRNAL_API_DELETE_ARTIFACT_OF_ASSET = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/%s/%s/artifacts/%s"; + final String DELETE_EXTRNAL_API_DELETE_ARTIFACT_OF_COMPONENTINSTANCE_ON_ASSET = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/%s/%s/resourceInstances/%s/artifacts/%s"; - final String GET_DOWNLOAD_RESOURCE_ARTIFACT_OF_ASSET = "http://%s:%s/sdc/v1/catalog/resources/%s/artifacts/%s"; - final String GET_DOWNLOAD_SERVICE_ARTIFACT_OF_ASSET = "http://%s:%s/sdc/v1/catalog/services/%s/artifacts/%s"; + final String POST_EXTERNAL_API_UPDATE_ARTIFACT_OF_ASSET = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/%s/%s/artifacts/%s"; + final String POST_EXTERNAL_API_UPDATE_ARTIFACT_OF_COMPONENTINSTANCE_ON_ASSET = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/%s/%s/resourceInstances/%s/artifacts/%s"; - final String GET_DOWNLOAD_RESOURCE_ARTIFACT_OF_COMPONENT_INSTANCE = "http://%s:%s/sdc/v1/catalog/resources/%s/resourceInstances/%s/artifacts/%s"; - final String GET_DOWNLOAD_SERVICE_ARTIFACT_OF_COMPONENT_INSTANCE = "http://%s:%s/sdc/v1/catalog/services/%s/resourceInstances/%s/artifacts/%s"; + final String POST_EXTERNAL_API_UPLOAD_ARTIFACT_OF_ASSET = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/%s/%s/artifacts"; + final String POST_EXTERNAL_API_UPLOAD_ARTIFACT_OF_COMPONENTINSTANCE_ON_ASSET = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/%s/%s/resourceInstances/%s/artifacts"; - final String GET_ASSET_LIST = "http://%s:%s/sdc/v1/catalog/%s"; - final String GET_FILTERED_ASSET_LIST = "http://%s:%s/sdc/v1/catalog/%s?%s"; - final String GET_TOSCA_MODEL = "http://%s:%s/sdc/v1/catalog/%s/%s/toscaModel"; + final String GET_DOWNLOAD_RESOURCE_ARTIFACT_OF_ASSET = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/resources/%s/artifacts/%s"; + final String GET_DOWNLOAD_SERVICE_ARTIFACT_OF_ASSET = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/services/%s/artifacts/%s"; + + final String GET_DOWNLOAD_RESOURCE_ARTIFACT_OF_COMPONENT_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/resources/%s/resourceInstances/%s/artifacts/%s"; + final String GET_DOWNLOAD_SERVICE_ARTIFACT_OF_COMPONENT_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/services/%s/resourceInstances/%s/artifacts/%s"; + + final String GET_ASSET_LIST = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/%s"; + final String GET_FILTERED_ASSET_LIST = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/%s?%s"; + final String GET_TOSCA_MODEL = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/%s/%s/toscaModel"; // https://{serverRoot}/sdc/v1/catalog/{assetType}/{uuid}/metadata, where // assetType in {resources, services} - final String GET_ASSET_METADATA = "http://%s:%s/sdc/v1/catalog/%s/%s/metadata"; - final String POST_AUTHORIZATION = "http://%s:%s/sdc2/rest/v1/consumers"; - final String GET_DOWNLOAD_SERVICE_RI_ARTIFACT = "http://%s:%s/sdc/v1/catalog/services/%s/resourceInstances/%s/artifacts/%s"; - final String GET_DOWNLOAD_SERVICE_ARTIFACT = "http://%s:%s/sdc/v1/catalog/services/%s/artifacts/%s"; - - final String POST_EXTERNAL_API_CREATE_RESOURCE = "http://%s:%s/sdc/v1/catalog/resources"; - + final String GET_ASSET_METADATA = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/%s/%s/metadata"; + final String POST_AUTHORIZATION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/consumers"; + final String GET_DOWNLOAD_SERVICE_RI_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/services/%s/resourceInstances/%s/artifacts/%s"; + final String GET_DOWNLOAD_SERVICE_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/services/%s/artifacts/%s"; + + final String POST_EXTERNAL_API_CREATE_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/resources"; + // Change LifeCycle of Resource // https://{serverRoot}:{port}/sdc/v1/catalog/{resources|services}/{uuid}/lifecycleState/{lifecycle state} - final String POST_EXTERNAL_API_CHANGE_LIFE_CYCLE_OF_ASSET = "http://%s:%s/sdc/v1/catalog/%s/%s/lifecycleState/%s"; - + final String POST_EXTERNAL_API_CHANGE_LIFE_CYCLE_OF_ASSET = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/%s/%s/lifecycleState/%s"; + // ***************************************************************************************************** - final String ADD_ARTIFACT_TO_RESOURCE = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/artifacts"; - final String UPDATE_OR_DELETE_ARTIFACT_OF_RESOURCE = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/artifacts/%s"; - final String ADD_ARTIFACT_TO_SERVICE = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/artifacts"; - final String UPDATE_OR_DELETE_ARTIFACT_OF_SERVICE = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/artifacts/%s"; + final String ADD_ARTIFACT_TO_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/artifacts"; + final String UPDATE_OR_DELETE_ARTIFACT_OF_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/artifacts/%s"; + final String ADD_ARTIFACT_TO_SERVICE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/artifacts"; + final String UPDATE_OR_DELETE_ARTIFACT_OF_SERVICE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/artifacts/%s"; - final String UPLOAD_DELETE_ARTIFACT_OF_COMPONENT = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/artifacts"; - final String UPDATE_ARTIFACT_OF_COMPONENT = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/artifacts/%s"; - final String UPLOAD_HEAT_ENV_ARTIFACT = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/%s/artifacts/%s"; + final String UPLOAD_DELETE_ARTIFACT_OF_COMPONENT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/artifacts"; + final String UPDATE_ARTIFACT_OF_COMPONENT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/artifacts/%s"; + final String UPLOAD_HEAT_ENV_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/%s/artifacts/%s"; // ***************************************************************************************************** - final String UPLOAD_ARTIFACT_BY_INTERFACE_TO_RESOURCE = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s/%s/artifacts/"; - final String UPDATE_OR_DELETE_ARTIFACT_BY_INTERFACE_TO_RESOURCE = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s/%s/artifacts/%s"; + final String UPLOAD_ARTIFACT_BY_INTERFACE_TO_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s/%s/artifacts/"; + final String UPDATE_OR_DELETE_ARTIFACT_BY_INTERFACE_TO_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s/%s/artifacts/%s"; - final String UPLOAD_ARTIFACT_BY_INTERFACE_TO_COMPONENT = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s/%s/artifacts/"; - final String UPDATE_OR_DELETE_ARTIFACT_BY_INTERFACE_TO_COMPONENT = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s/%s/artifacts/%s"; + final String UPLOAD_ARTIFACT_BY_INTERFACE_TO_COMPONENT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s/%s/artifacts/"; + final String UPDATE_OR_DELETE_ARTIFACT_BY_INTERFACE_TO_COMPONENT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s/%s/artifacts/%s"; // ***************************************************************************************************** // "/sdc2/v1/services//<0.1>/artifacts/aaa.hh" @@ -242,148 +246,150 @@ public interface Urls { final String DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT = "/sdc2/rest/v1/catalog/services/%s/%s/resources/%s/%s/artifacts/%s"; final String DISTRIB_DOWNLOAD_SERVICE_ARTIFACT_RELATIVE_URL = "/sdc/v1/catalog/services/%s/%s/artifacts/%s"; final String DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL = "/sdc/v1/catalog/services/%s/%s/resources/%s/%s/artifacts/%s"; - final String DOWNLOAD_SERVICE_ARTIFACT_FULL_URL = "http://%s:%s%s"; - final String DOWNLOAD_RESOURCE_ARTIFACT_FULL_URL = "http://%s:%s%s"; + final String DOWNLOAD_SERVICE_ARTIFACT_FULL_URL = SDC_HTTP_METHOD + "://%s:%s%s"; + final String DOWNLOAD_RESOURCE_ARTIFACT_FULL_URL = SDC_HTTP_METHOD + "://%s:%s%s"; // ********************************************************************************** - final String UI_DOWNLOAD_RESOURCE_ARTIFACT = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/artifacts/%s"; - final String UI_DOWNLOAD_SERVICE_ARTIFACT = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/artifacts/%s"; + final String UI_DOWNLOAD_RESOURCE_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/artifacts/%s"; + final String UI_DOWNLOAD_SERVICE_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/artifacts/%s"; // ********************************************************************************************************** - final String UPDATE_PROPERTY = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/properties/%s"; + final String UPDATE_PROPERTY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/properties/%s"; - final String DELETE_PROPERTY = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/properties/%s"; + final String DELETE_PROPERTY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/properties/%s"; - final String GET_PROPERTY = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/properties/%s"; + final String GET_PROPERTY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/properties/%s"; // ***************************************************************************************************** - final String VALIDATE_RESOURCE_NAME = "http://%s:%s/sdc2/rest/v1/catalog/resources/validate-name/%s"; + final String VALIDATE_RESOURCE_NAME = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/validate-name/%s"; - final String CREATE_SERVICE = "http://%s:%s/sdc2/rest/v1/catalog/services"; - final String DELETE_SERVICE = "http://%s:%s/sdc2/rest/v1/catalog/services/%s"; - final String GET_SERVICE = "http://%s:%s/sdc2/rest/v1/catalog/services/%s"; - final String GET_SERVICE_BY_NAME_AND_VERSION = "http://%s:%s/sdc2/rest/v1/catalog/services/serviceName/%s/serviceVersion/%s"; + final String CREATE_SERVICE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services"; + final String DELETE_SERVICE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s"; + final String GET_SERVICE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s"; + final String GET_SERVICE_BY_NAME_AND_VERSION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/serviceName/%s/serviceVersion/%s"; - final String GET_SERVICES_REQUIRMENTS_CAPABILITIES = "http://%s:%s/sdc2/rest/v1/catalog/requirmentsCapabilities/services/%s"; + final String GET_SERVICES_REQUIRMENTS_CAPABILITIES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/requirmentsCapabilities/services/%s"; - final String CREATE_COMPONENT_INSTANCE = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance"; - final String DELETE_COMPONENT_INSTANCE = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/%s"; - final String UPDATE_COMPONENT_INSTANCE = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/%s"; - final String GET_COMPONENT_INSTANCES = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/componentInstances"; + final String CREATE_COMPONENT_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance"; + final String DELETE_COMPONENT_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/%s"; + final String UPDATE_COMPONENT_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/%s"; + final String GET_COMPONENT_INSTANCES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/componentInstances"; // Tal New API - final String UPDATE_MULTIPLE_COMPONENT_INSTANCE = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/multipleComponentInstance"; + final String UPDATE_MULTIPLE_COMPONENT_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/multipleComponentInstance"; - final String CHANGE__RESOURCE_INSTANCE_VERSION = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/%s/changeVersion"; + final String CHANGE__RESOURCE_INSTANCE_VERSION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/%s/changeVersion"; - final String CREATE_AND_ASSOCIATE_RESOURCE_INSTANCE = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/resourceInstance/createAndAssociate"; - final String ASSOCIATE__RESOURCE_INSTANCE = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/associate"; - final String DISSOCIATE__RESOURCE_INSTANCE = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/dissociate"; + final String CREATE_AND_ASSOCIATE_RESOURCE_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/resourceInstance/createAndAssociate"; + final String ASSOCIATE__RESOURCE_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/associate"; + final String DISSOCIATE__RESOURCE_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/dissociate"; - final String DISTRIBUTION_INIT = "http://%s:%s/init"; - final String DISTRIBUTION_INIT_RESET = "http://%s:%s/initReset"; - final String APPROVE_DISTRIBUTION = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/distribution-state/approve"; - final String REJECT_DISTRIBUTION = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/distribution-state/reject"; - final String DISTRIBUTION_DOWNLOAD_ARTIFACT = "http://%s:%s/download"; - final String ACTIVATE_DISTRIBUTION = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/distribution/%s/activate"; - final String DISTRIBUTION_SERVICE_LIST = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/distribution"; - final String DISTRIBUTION_SERVICE_MONITOR = "http://%s:%s/sdc2/rest/v1/catalog/services/distribution/%s"; + final String DISTRIBUTION_INIT = SDC_HTTP_METHOD + "://%s:%s/init"; + final String DISTRIBUTION_INIT_RESET = SDC_HTTP_METHOD + "://%s:%s/initReset"; + final String APPROVE_DISTRIBUTION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/distribution-state/approve"; + final String REJECT_DISTRIBUTION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/distribution-state/reject"; + final String DISTRIBUTION_DOWNLOAD_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/download"; + final String ACTIVATE_DISTRIBUTION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/distribution/%s/activate"; + final String DISTRIBUTION_SERVICE_LIST = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/distribution"; + final String DISTRIBUTION_SERVICE_MONITOR = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/distribution/%s"; - final String DEPLOY_SERVICE = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/distribution/%s/markDeployed"; - final String UPDATE_SERVICE_METADATA = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/metadata"; + final String DEPLOY_SERVICE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/distribution/%s/markDeployed"; + final String UPDATE_SERVICE_METADATA = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/metadata"; // Andrey changed name from ADD_PROPERTY_TO_RESOURCE_INSTANCE to // UPDATE_PROPERTY_TO_RESOURCE_INSTANCE - final String UPDATE_PROPERTY_TO_RESOURCE_INSTANCE = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/%s/property"; - final String DELETE_PROPERTY_FROM_RESOURCE_INSTANCE = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/resourceInstance/%s/property/%s"; - final String UPDATE_RESOURCE_INSTANCE_HEAT_ENV_PARAMS = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/resourceInstance/%s/artifacts/%s/heatParams"; + final String UPDATE_PROPERTY_TO_RESOURCE_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/%s/property"; + final String DELETE_PROPERTY_FROM_RESOURCE_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/resourceInstance/%s/property/%s"; + final String UPDATE_RESOURCE_INSTANCE_HEAT_ENV_PARAMS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/resourceInstance/%s/artifacts/%s/heatParams"; // Actions on artifact in resource instance - final String ADD_RESOURCE_INSTANCE_ARTIFACT = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/resourceInstance/%s/artifacts"; - final String UPDATE_RESOURCE_INSTANCE_ARTIFACT = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/resourceInstance/%s/artifacts/%s"; - final String DELETE_RESOURCE_INSTANCE_ARTIFACT = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/resourceInstance/%s/artifacts/%s"; + final String ADD_RESOURCE_INSTANCE_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/resourceInstance/%s/artifacts"; + final String UPDATE_RESOURCE_INSTANCE_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/resourceInstance/%s/artifacts/%s"; + final String DELETE_RESOURCE_INSTANCE_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/resourceInstance/%s/artifacts/%s"; // Attributes On Resource instance - public static final String UPDATE_ATTRIBUTE_ON_RESOURCE_INSTANCE = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/%s/attribute"; + public static final String UPDATE_ATTRIBUTE_ON_RESOURCE_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/%s/attribute"; // ("/services/{serviceId}/resourceInstances/{resourceInstanceId}/artifacts/{artifactId}") - final String DOWNLOAD_COMPONENT_INSTANCE_ARTIFACT = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/resourceInstances/%s/artifacts/%s"; + final String DOWNLOAD_COMPONENT_INSTANCE_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/resourceInstances/%s/artifacts/%s"; // -------------------------------service api // artifact----------------------------------------------------- - final String UPDATE_DELETE_SERVICE_API_ARTIFACT = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/artifacts/api/%s"; + final String UPDATE_DELETE_SERVICE_API_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/artifacts/api/%s"; - final String CREATE_ADDITIONAL_INFORMATION_RESOURCE = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/additionalinfo"; - final String UPDATE_ADDITIONAL_INFORMATION_RESOURCE = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/additionalinfo/%s"; + final String CREATE_ADDITIONAL_INFORMATION_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/additionalinfo"; + final String UPDATE_ADDITIONAL_INFORMATION_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/additionalinfo/%s"; final String DELETE_ADDITIONAL_INFORMATION_RESOURCE = UPDATE_ADDITIONAL_INFORMATION_RESOURCE; - final String GET_ADDITIONAL_INFORMATION_RESOURCE = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/additionalinfo/%s"; - final String GET_ALL_ADDITIONAL_INFORMATION_RESOURCE = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/additionalinfo"; + final String GET_ADDITIONAL_INFORMATION_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/additionalinfo/%s"; + final String GET_ALL_ADDITIONAL_INFORMATION_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/additionalinfo"; - final String CREATE_ADDITIONAL_INFORMATION_SERVICE = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/additionalinfo"; - final String UPDATE_ADDITIONAL_INFORMATION_SERVICE = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/additionalinfo/%s"; + final String CREATE_ADDITIONAL_INFORMATION_SERVICE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/additionalinfo"; + final String UPDATE_ADDITIONAL_INFORMATION_SERVICE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/additionalinfo/%s"; final String DELETE_ADDITIONAL_INFORMATION_SERVICE = UPDATE_ADDITIONAL_INFORMATION_SERVICE; - final String GET_ADDITIONAL_INFORMATION_SERVICE = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/additionalinfo/%s"; - final String GET_ALL_ADDITIONAL_INFORMATION_SERVICE = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/additionalinfo"; + final String GET_ADDITIONAL_INFORMATION_SERVICE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/additionalinfo/%s"; + final String GET_ALL_ADDITIONAL_INFORMATION_SERVICE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/additionalinfo"; - final String GET_COMPONENT_AUDIT_RECORDS = "http://%s:%s/sdc2/rest/v1/catalog/audit-records/%s/%s"; + final String GET_COMPONENT_AUDIT_RECORDS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/audit-records/%s/%s"; // CONSUMER - final String CREATE_CONSUMER = "http://%s:%s/sdc2/rest/v1/consumers"; - final String GET_CONSUMER = "http://%s:%s/sdc2/rest/v1/consumers/%s"; - final String DELETE_CONSUMER = "http://%s:%s/sdc2/rest/v1/consumers/%s"; + final String CREATE_CONSUMER = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/consumers"; + final String GET_CONSUMER = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/consumers/%s"; + final String DELETE_CONSUMER = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/consumers/%s"; // Categories - final String CREATE_CATEGORY = "http://%s:%s/sdc2/rest/v1/category/%s"; - final String GET_ALL_CATEGORIES = "http://%s:%s/sdc2/rest/v1/categories/%s"; - final String GET_ALL_CATEGORIES_FE = "http://%s:%s/sdc1/feProxy/rest/v1/categories/%s"; - final String DELETE_CATEGORY = "http://%s:%s/sdc2/rest/v1/category/%s/%s"; - final String CREATE_SUB_CATEGORY = "http://%s:%s/sdc2/rest/v1/category/%s/%s/subCategory"; - final String DELETE_SUB_CATEGORY = "http://%s:%s/sdc2/rest/v1/category/%s/%s/subCategory/%s"; - final String CREATE_GROUPING = "http://%s:%s/sdc2/rest/v1/category/%s/%s/subCategory/%s/grouping"; - final String DELETE_GROUPING = "http://%s:%s/sdc2/rest/v1/category/%s/%s/subCategory/%s/grouping/%s"; + final String CREATE_CATEGORY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/category/%s"; + final String GET_ALL_CATEGORIES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/categories/%s"; + final String GET_ALL_CATEGORIES_FE = SDC_HTTP_METHOD + "://%s:%s/sdc1/feProxy/rest/v1/categories/%s"; + final String DELETE_CATEGORY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/category/%s/%s"; + final String CREATE_SUB_CATEGORY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/category/%s/%s/subCategory"; + final String DELETE_SUB_CATEGORY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/category/%s/%s/subCategory/%s"; + final String CREATE_GROUPING = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/category/%s/%s/subCategory/%s/grouping"; + final String DELETE_GROUPING = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/category/%s/%s/subCategory/%s/grouping/%s"; // product - final String CREATE_PRODUCT = "http://%s:%s/sdc2/rest/v1/catalog/products"; - final String DELETE_PRODUCT = "http://%s:%s/sdc2/rest/v1/catalog/products/%s"; + final String CREATE_PRODUCT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/products"; + final String DELETE_PRODUCT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/products/%s"; // last %s is resourceId, productId - final String GET_PRODUCT = "http://%s:%s/sdc2/rest/v1/catalog/products/%s"; - final String UPDATE_PRODUCT = "http://%s:%s/sdc2/rest/v1/catalog/products/%s/metadata"; - final String GET_PRODUCT_BY_NAME_AND_VERSION = "http://%s:%s/sdc2/rest/v1/catalog/products/productName/%s/productVersion/%s"; + final String GET_PRODUCT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/products/%s"; + final String UPDATE_PRODUCT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/products/%s/metadata"; + final String GET_PRODUCT_BY_NAME_AND_VERSION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/products/productName/%s/productVersion/%s"; // groups - final String GET_GROUP_BY_ID = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/groups/%s"; - + final String GET_GROUP_BY_ID = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/groups/%s"; + //module property + final String RESOURCE_GROUP_PROPERTY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/groups/%s/properties"; // modules - final String GET_MODULE_BY_ID = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/groups/%s"; - + final String GET_MODULE_BY_ID = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/groups/%s"; + // inputs - final String ADD_INPUTS = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/create/inputs"; //{componentType}/{componentId}/create/inputs - final String DELETE_INPUT_BY_ID = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/delete/%s/input"; //{componentType}/{componentId}/delete/{inputId}/input - final String GET_COMPONENT_INPUTS = "http://%s:%s/sdc2/rest/v1/catalog/services/%s/inputs"; //services/{componentId}/inputs - final String GET_COMPONENT_INSTANCE_INPUTS = "http://%s:%s/sdc2/rest/v1/catalog/%s/%s/componentInstances/%s/%s/inputs"; //{componentType}/{componentId}/componentInstances/{instanceId}/{originComonentUid}/inputs - final String GET_INPUTS_FOR_COMPONENT_INPUT = "http://%s:%s/sdc2/rest/v1/catalog/resources/%s/groups/%s"; //{componentType}/{componentId}/inputs/{inputId}/inputs + final String ADD_INPUTS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/create/inputs"; //{componentType}/{componentId}/create/inputs + final String DELETE_INPUT_BY_ID = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/delete/%s/input"; //{componentType}/{componentId}/delete/{inputId}/input + final String GET_COMPONENT_INPUTS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/inputs"; //services/{componentId}/inputs + final String GET_COMPONENT_INSTANCE_INPUTS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/componentInstances/%s/%s/inputs"; //{componentType}/{componentId}/componentInstances/{instanceId}/{originComonentUid}/inputs + final String GET_INPUTS_FOR_COMPONENT_INPUT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/groups/%s"; //{componentType}/{componentId}/inputs/{inputId}/inputs // check version - final String ONBOARD_VERSION = "http://%s:%s/onboarding-api/docs/build-info.json"; - final String OS_VERSION = "http://%s:%s/sdc2/rest/version"; - + final String ONBOARD_VERSION = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/docs/build-info.json"; + final String OS_VERSION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/version"; + // amdocs APIs - final String GET_VENDOR_SOFTWARE_PRODUCT = "http://%s:%s/onboarding-api/v1.0/vendor-software-products/packages/%s"; - final String UPLOAD_SNMP_POLL_ARTIFACT = "http://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/0.1/components/%s/uploads/types/SNMP_POLL"; - final String UPLOAD_SNMP_TRAP_ARTIFACT = "http://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/0.1/components/%s/uploads/types/SNMP_TRAP"; - final String UPLOAD_VES_EVENTS_ARTIFACT = "http://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/0.1/components/%s/uploads/types/VES_EVENTS"; - final String UPLOAD_AMDOCS_ARTIFACT = "http://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/0.1/components/%s/uploads/types/%s"; - final String DELETE_AMDOCS_ARTIFACT_BY_TYPE = "http://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/0.1/components/%s/monitors/%s"; - final String GET_VSP_COMPONENTS = "http://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/0.1/components"; - final String CREATE_VENDOR_LISENCE_MODELS = "http://%s:%s/onboarding-api/v1.0/vendor-license-models"; - final String CREATE_VENDOR_LISENCE_AGREEMENT = "http://%s:%s/onboarding-api/v1.0/vendor-license-models/%s/versions/0.1/license-agreements"; - final String CREATE_VENDOR_LISENCE_FEATURE_GROUPS = "http://%s:%s/onboarding-api/v1.0/vendor-license-models/%s/versions/0.1/feature-groups"; - final String CREATE_VENDOR_LISENCE_ENTITLEMENT_POOL = "http://%s:%s/onboarding-api/v1.0/vendor-license-models/%s/versions/0.1/entitlement-pools"; - final String CREATE_VENDOR_LISENCE_KEY_GROUPS = "http://%s:%s/onboarding-api/v1.0/vendor-license-models/%s/versions/0.1/license-key-groups"; - final String CREATE_VENDOR_SOFTWARE_PRODUCT = "http://%s:%s/onboarding-api/v1.0/vendor-software-products"; - final String VALIDATE_UPLOAD = "http://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/0.1/orchestration-template-candidate/process"; - final String UPLOAD_HEAT_PACKAGE = "http://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s/orchestration-template-candidate"; - final String ACTION_ON_COMPONENT = "http://%s:%s/onboarding-api/v1.0/%s/%s/versions/%s/actions"; - final String UPDATE_VSP = "http://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s"; - final String GET_VSP_COMPONENT_BY_VERSION = "http://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s"; - final String GET_VLM_COMPONENT_BY_VERSION = "http://%s:%s/onboarding-api/v1.0/vendor-license-models/%s/versions/%s"; + final String GET_VENDOR_SOFTWARE_PRODUCT = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/packages/%s"; + final String UPLOAD_SNMP_POLL_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s/components/%s/uploads/types/SNMP_POLL"; + final String UPLOAD_SNMP_TRAP_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s/components/%s/uploads/types/SNMP_TRAP"; + final String UPLOAD_VES_EVENTS_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s/components/%s/uploads/types/VES_EVENTS"; + final String UPLOAD_AMDOCS_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s/components/%s/uploads/types/%s"; + final String DELETE_AMDOCS_ARTIFACT_BY_TYPE = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s/components/%s/monitors/%s"; + final String GET_VSP_COMPONENTS = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s/components"; + final String CREATE_VENDOR_LISENCE_MODELS = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-license-models"; + final String CREATE_VENDOR_LISENCE_AGREEMENT = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-license-models/%s/versions/%s/license-agreements"; + final String CREATE_VENDOR_LISENCE_FEATURE_GROUPS = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-license-models/%s/versions/%s/feature-groups"; + final String CREATE_VENDOR_LISENCE_ENTITLEMENT_POOL = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-license-models/%s/versions/%s/entitlement-pools"; + final String CREATE_VENDOR_LISENCE_KEY_GROUPS = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-license-models/%s/versions/%s/license-key-groups"; + final String CREATE_METHOD = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/%s/%s/versions/%s/"; + final String CREATE_VENDOR_SOFTWARE_PRODUCT = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products"; + final String VALIDATE_UPLOAD = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s/orchestration-template-candidate/process"; + final String UPLOAD_HEAT_PACKAGE = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s/orchestration-template-candidate"; + final String ACTION_ON_COMPONENT = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/%s/%s/versions/%s/actions"; + final String UPDATE_VSP = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s"; + final String GET_VSP_COMPONENT_BY_VERSION = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s"; + final String GET_VLM_COMPONENT_BY_VERSION = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-license-models/%s/versions/%s"; } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/Config.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/Config.java index 7bb4602433..590297e130 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/Config.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/Config.java @@ -92,7 +92,17 @@ public class Config { private String windowsDownloadDirectory; private boolean captureTraffic; private boolean useBrowserMobProxy; - + private String sdcHttpMethod; + private String localDataCenter; + + public String getLocalDataCenter() { + return localDataCenter; + } + + public void setLocalDataCenter(String localDataCenter) { + this.localDataCenter = localDataCenter; + } + private static Config configIt = null; private static Yaml yaml = new Yaml(); @@ -150,6 +160,8 @@ public class Config { if (configFile == null) { if (System.getProperty("os.name").contains("Windows")) { configFile = WINDOWS_CONFIG_FILE; + } else if (System.getProperty("os.name").contains("Mac")) { + configFile = WINDOWS_CONFIG_FILE; } else { throw new RuntimeException("Please Add Jvm Argument config.resource"); } @@ -246,6 +258,14 @@ public class Config { this.systemUnderDebug = systemUnderDebug; } + public String getSdcHttpMethod() { + return sdcHttpMethod; + } + + public void setSdcHttpMethod(String sdcHttpMethod) { + this.sdcHttpMethod = sdcHttpMethod; + } + public boolean getRerun() { return rerun; } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/dataProviders/OnbordingDataProviders.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/dataProviders/OnbordingDataProviders.java index 8a9171e5bd..58a11b012f 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/dataProviders/OnbordingDataProviders.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/dataProviders/OnbordingDataProviders.java @@ -1,14 +1,15 @@ package org.openecomp.sdc.ci.tests.dataProviders; -import static org.testng.Assert.assertFalse; +import org.openecomp.sdc.ci.tests.utils.general.FileHandling; +import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtils; +import org.testng.annotations.DataProvider; + import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.openecomp.sdc.ci.tests.utils.general.FileHandling; -import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtils; -import org.testng.annotations.DataProvider; +import static org.testng.Assert.assertFalse; public class OnbordingDataProviders { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/GroupHeatMetaDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/GroupHeatMetaDefinition.java index 03bedd6746..5ebb2608b7 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/GroupHeatMetaDefinition.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/GroupHeatMetaDefinition.java @@ -28,6 +28,8 @@ import java.util.Map; public class GroupHeatMetaDefinition { private int group = 0; + private String groupName; + // private List artifactList = new ArrayList(); private List artifactList = new ArrayList(); @Override @@ -75,7 +77,15 @@ public class GroupHeatMetaDefinition { this.group = group; } -// public List getArtifactList() { + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + // public List getArtifactList() { // return artifactList; // } // diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ImportReqDetails.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ImportReqDetails.java index 0089eec5a7..e7899eeeb4 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ImportReqDetails.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ImportReqDetails.java @@ -36,7 +36,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import org.codehaus.jackson.map.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectMapper; import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONException; import org.openecomp.sdc.be.model.User; @@ -45,6 +45,8 @@ import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; import org.yaml.snakeyaml.Yaml; +import com.fasterxml.jackson.databind.ObjectMapper; + public class ImportReqDetails extends ResourceReqDetails { private String payloadName; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/PropertyObject.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/PropertyObject.java new file mode 100644 index 0000000000..9fea62bba5 --- /dev/null +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/PropertyObject.java @@ -0,0 +1,90 @@ +package org.openecomp.sdc.ci.tests.datatypes; + +import java.util.ArrayList; +import java.util.List; + +public class PropertyObject { + + private String defaultValue; + private String name; + private String parentUniqueId; + private boolean password; + private boolean required; + private List Schema; + private String type; + private String uniqueId; + private boolean definition; + private Object value = null; + + + public PropertyObject() { + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + + public PropertyObject(String defaultValue, String name, String parentUniqueId, String uniqueId) { + this.defaultValue = defaultValue; + this.name = name; + this.parentUniqueId = parentUniqueId; + this.uniqueId = uniqueId; + this.password = false; + this.required = false; + this.type = "String"; + this.definition = false; + this.Schema = new ArrayList(); + } + + public String getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getParentUniqueId() { + return parentUniqueId; + } + + public void setParentUniqueId(String parentUniqueId) { + this.parentUniqueId = parentUniqueId; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getUniqueId() { + return uniqueId; + } + + public void setUniqueId(String uniqueId) { + this.uniqueId = uniqueId; + } +} + +class Schema { + + private List property; +} + +class Property {} + diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceReqDetails.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceReqDetails.java index 5a80fd14ca..e3517a8ab4 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceReqDetails.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceReqDetails.java @@ -29,7 +29,11 @@ public class ResourceReqDetails extends ComponentReqDetails { List derivedFrom; String vendorName; String vendorRelease; + String componentType = "RESOURCE"; + public String getComponentType() { + return componentType; + } // Unsettable/unupdatable fields Boolean isAbstract; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/VendorSoftwareProductObject.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/VendorSoftwareProductObject.java index 8b40210c0d..a6aba7f13c 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/VendorSoftwareProductObject.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/VendorSoftwareProductObject.java @@ -16,8 +16,8 @@ public class VendorSoftwareProductObject extends VendorSoftwareProductObjectReqD this.version = version; } - public VendorSoftwareProductObject(String name, String description, String category, String subCategory, String vendorId, String vendorName, LicensingVersion licensingVersion, LicensingData licensingData, String onboardingMethod, String networkPackageName, String onboardingOrigin, String vspId, String componentId, String attContact, String version) { - super(name, description, category, subCategory, vendorId, vendorName, licensingVersion, licensingData, onboardingMethod, networkPackageName, onboardingOrigin); + public VendorSoftwareProductObject(String name, String description, String category, String subCategory, String vendorId, String vendorName, String licensingVersion, LicensingData licensingData, String onboardingMethod, String networkPackageName, String onboardingOrigin, String icon, String vspId, String componentId, String attContact, String version) { + super(name, description, category, subCategory, vendorId, vendorName, licensingVersion, licensingData, onboardingMethod, networkPackageName, onboardingOrigin, icon); this.vspId = vspId; this.componentId = componentId; this.attContact = attContact; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/VendorSoftwareProductObjectReqDetails.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/VendorSoftwareProductObjectReqDetails.java index 10093c2a93..459bfaab2f 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/VendorSoftwareProductObjectReqDetails.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/VendorSoftwareProductObjectReqDetails.java @@ -8,11 +8,14 @@ public class VendorSoftwareProductObjectReqDetails { private String subCategory; private String vendorId; private String vendorName; - private LicensingVersion licensingVersion; +// private LicensingVersion licensingVersion; + private String licensingVersion; private LicensingData licensingData; private String onboardingMethod; private String networkPackageName; private String onboardingOrigin; + private String icon; + public String getIcon() { return icon; @@ -22,12 +25,10 @@ public class VendorSoftwareProductObjectReqDetails { this.icon = icon; } - private String icon; - public VendorSoftwareProductObjectReqDetails() { } - public VendorSoftwareProductObjectReqDetails(String name, String description, String category, String subCategory, String vendorId, String vendorName, LicensingVersion licensingVersion, LicensingData licensingData, String onboardingMethod, String networkPackageName, String onboardingOrigin) { + public VendorSoftwareProductObjectReqDetails(String name, String description, String category, String subCategory, String vendorId, String vendorName, String licensingVersion, LicensingData licensingData, String onboardingMethod, String networkPackageName, String onboardingOrigin, String icon) { this.name = name; this.description = description; this.category = category; @@ -39,6 +40,15 @@ public class VendorSoftwareProductObjectReqDetails { this.onboardingMethod = onboardingMethod; this.networkPackageName = networkPackageName; this.onboardingOrigin = onboardingOrigin; + this.icon = icon; + } + + public String getLicensingVersion() { + return licensingVersion; + } + + public void setLicensingVersion(String licensingVersion) { + this.licensingVersion = licensingVersion; } public String getName() { @@ -89,13 +99,13 @@ public class VendorSoftwareProductObjectReqDetails { this.vendorName = vendorName; } - public LicensingVersion getLicensingVersion() { - return licensingVersion; - } - - public void setLicensingVersion(LicensingVersion licensingVersion) { - this.licensingVersion = licensingVersion; - } +// public LicensingVersion getLicensingVersion() { +// return licensingVersion; +// } +// +// public void setLicensingVersion(LicensingVersion licensingVersion) { +// this.licensingVersion = licensingVersion; +// } public LicensingData getLicensingData() { return licensingData; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/GroupPropertyEnum.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/GroupPropertyEnum.java new file mode 100644 index 0000000000..4651995655 --- /dev/null +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/GroupPropertyEnum.java @@ -0,0 +1,46 @@ +package org.openecomp.sdc.ci.tests.datatypes.enums; + +import java.util.ArrayList; +import java.util.List; + +public enum GroupPropertyEnum { + + IS_BASE("isBase"), + MIN_VF_MODULE_INSTANCES("min_vf_module_instances"), + MAX_VF_MODULE_INSTANCES("max_vf_module_instances"), + VF_MODULE_LABEL("vf_module_label"), + VFC_LIST("vfc_list"), + VF_MODULE_TYPE("vf_module_type"), + VF_MODULE_DESCRIPTION("vf_module_description"), + INITIAL_COUNT("initial_count"), + VOLUME_GROUP("volume_group"), + AVAILABILITY_ZONE_COUNT("availability_zone_count"); + + private String propertyName; + + GroupPropertyEnum(String propertyName) { + this.propertyName = propertyName; + } + + public String getPropertyName() { + return propertyName; + } + + public static List getGroupPropertyNamesWithoutIsbase(){ + List groupPropertyNames = new ArrayList<>(); + + for(GroupPropertyEnum groupProperty : GroupPropertyEnum.values()) { + if (!groupProperty.getPropertyName().equals(GroupPropertyEnum.IS_BASE)){ + groupPropertyNames.add(groupProperty.getPropertyName()); + } + } + return groupPropertyNames; + } + + public static List getGroupPropertyNames(){ + List groupPropertyNames = GroupPropertyEnum.getGroupPropertyNamesWithoutIsbase(); + groupPropertyNames.add(GroupPropertyEnum.IS_BASE.getPropertyName()); + return groupPropertyNames; + } + +} diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ResourceCategoryEnum.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ResourceCategoryEnum.java index 1ba6c5c7f1..a0b13b7539 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ResourceCategoryEnum.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ResourceCategoryEnum.java @@ -20,6 +20,11 @@ package org.openecomp.sdc.ci.tests.datatypes.enums; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Random; + import java.util.Random; public enum ResourceCategoryEnum { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/UserRoleEnum.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/UserRoleEnum.java index 20a4b12a92..aa70c376bb 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/UserRoleEnum.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/UserRoleEnum.java @@ -26,7 +26,7 @@ public enum UserRoleEnum { // GOVERNOR("gv0001","David", "Shadmi"), OPS("op0001", "Steve", "Regev"), PRODUCT_STRATEGIST1("ps0001", "Eden","Rozin"), PRODUCT_STRATEGIST2("ps0002", "Ella", "Kvetny"), PRODUCT_STRATEGIST3("ps0003", "Geva", "Alon"), // PRODUCT_MANAGER1("pm0001", "Teddy", "Isashar"), PRODUCT_MANAGER2("pm0002", "Sarah", "Bettens"); ADMIN("jh0003", "Jimmy", "Hendrix"), DESIGNER("m08740", "Zero", "ASDCMech"), DESIGNER2("me0009", "Melissa","Etheridge"), DESIGNER3("cs0008", "Carlos", "Santana"),TESTER("jm0007", "Johnny", "Depp"), ADMIN4("km2000", "Kot", "May"), - GOVERNOR("gv0001","David", "Shadmi"), OPS("op0001", "Aretha", "Franklin"), PRODUCT_STRATEGIST1("ps0001", "Eden","Rozin"), PRODUCT_STRATEGIST2("ps0002", "Ella", "Kvetny"), PRODUCT_STRATEGIST3("ps0003", "Geva", "Alon"), + GOVERNOR("gv0001","David", "Shadmi"), OPS("af0006", "Aretha", "Franklin"), PRODUCT_STRATEGIST1("ps0001", "Eden","Rozin"), PRODUCT_STRATEGIST2("ps0002", "Ella", "Kvetny"), PRODUCT_STRATEGIST3("ps0003", "Geva", "Alon"), PRODUCT_MANAGER1("pm0001", "Teddy", "Isashar"), PRODUCT_MANAGER2("pm0002", "Sarah", "Bettens"); private String userId; private String firstName; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/http/HttpRequest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/http/HttpRequest.java index a8ca77d055..2435b10dd5 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/http/HttpRequest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/http/HttpRequest.java @@ -20,24 +20,6 @@ package org.openecomp.sdc.ci.tests.datatypes.http; -import java.io.BufferedReader; -import java.io.DataOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.StringWriter; -import java.net.HttpURLConnection; -import java.net.URI; -import java.net.URL; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Scanner; - -import javax.net.ssl.HttpsURLConnection; - -import org.apache.commons.codec.binary.Base64; import org.apache.commons.io.IOUtils; import org.apache.http.HttpEntity; import org.apache.http.annotation.NotThreadSafe; @@ -45,23 +27,29 @@ import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.entity.mime.MultipartEntityBuilder; -import org.apache.http.entity.mime.content.FileBody; -import org.apache.http.entity.mime.content.StringBody; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; -import org.apache.http.util.EntityUtils; +import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import sun.net.www.protocol.https.DefaultHostnameVerifier; -import com.google.gson.Gson; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URL; +import java.nio.charset.Charset; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; public class HttpRequest { static Logger logger = LoggerFactory.getLogger(HttpRequest.class.getName()); - - public RestResponse httpSendGet(String url, Map headers) throws IOException { + +// -----------------------------Http------------------------------------------------------------------------ + public RestResponse httpSendGetInternal(String url, Map headers) throws IOException { RestResponse restResponse = new RestResponse(); url = url.replaceAll("\\s", "%20"); @@ -69,15 +57,7 @@ public class HttpRequest { HttpURLConnection con = (HttpURLConnection) obj.openConnection(); // optional default is GET con.setRequestMethod("GET"); - // add request header - if (headers != null) { - for (Entry header : headers.entrySet()) { - String key = header.getKey(); - String value = header.getValue(); - con.setRequestProperty(key, value); - } - - } + addHttpRequestHEaders(headers, con); int responseCode = con.getResponseCode(); logger.debug("Send GET http request, url: {}",url); @@ -85,209 +65,246 @@ public class HttpRequest { StringBuffer response = new StringBuffer(); String result; - try { result = IOUtils.toString(con.getInputStream()); response.append(result); - - } catch (Exception e) { + } catch (Exception e) { + logger.debug("Fail with exception", e); } - try { - result = IOUtils.toString(con.getErrorStream()); response.append(result); - } catch (Exception e) { +// logger.debug("Fail with exception", e); } logger.debug("Response body: {}" ,response); // print result - - restResponse.setErrorCode(responseCode); - - if (response != null) { - restResponse.setResponse(response.toString()); - } - - restResponse.setErrorCode(responseCode); - Map> headerFields = con.getHeaderFields(); - restResponse.setHeaderFields(headerFields); - String responseMessage = con.getResponseMessage(); - restResponse.setResponseMessage(responseMessage); - + setHttpResponseToObject(restResponse, con, responseCode, response); con.disconnect(); return restResponse; } - public RestResponse httpsSendGet(String url, Map headers) throws IOException { + public RestResponse httpSendByMethodInternal(String url, String method, String body, Map headers) throws IOException { RestResponse restResponse = new RestResponse(); URL obj = new URL(url); - HttpsURLConnection con = (HttpsURLConnection) obj.openConnection(); - // optional default is GET - con.setRequestMethod("GET"); - // add request header - if (headers != null) { - for (Entry header : headers.entrySet()) { - String key = header.getKey(); - String value = header.getValue(); - con.setRequestProperty(key, value); - } - + HttpURLConnection con = (HttpURLConnection) obj.openConnection(); +// add request method + con.setRequestMethod(method); +// add request headers + addHttpRequestHEaders(headers, con); + 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 GET http request, url: {}",url); + 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"); - } - + StringBuffer response = generateHttpResponse(con, false); String result; - try { - result = IOUtils.toString(con.getErrorStream()); response.append(result); - - } catch (Exception e2) { - // result = null; + } catch (Exception e) { +// logger.debug("Fail with exception", e); } logger.debug("Response body: {}",response); +// print result + setHttpResponseToObject(restResponse, con, responseCode, response); + con.disconnect(); - // print result + return restResponse; + } - restResponse.setErrorCode(responseCode); + public RestResponse httpSendDelete(String url, Map headers) throws IOException { + if (url.matches("^(https)://.*$")){ + return httpsSendDelete(url, headers); + } + return httpSendDeleteInternal(url, headers); + } - if (response != null) { - restResponse.setResponse(response.toString()); + public RestResponse httpSendGet(String url, Map headers) throws IOException { + if (url.matches("^(https)://.*$")){ + return httpsSendGet(url, headers); } + return httpSendGetInternal(url, headers); + } - restResponse.setErrorCode(responseCode); - // restResponse.setResponse(result); - Map> headerFields = con.getHeaderFields(); - restResponse.setHeaderFields(headerFields); - String responseMessage = con.getResponseMessage(); - restResponse.setResponseMessage(responseMessage); + public RestResponse httpSendByMethod(String url, String method, String body, Map headers) throws IOException { + if (url.matches("^(https)://.*$")){ + return httpsSendByMethod(url, method, body, headers); + } + return httpSendByMethodInternal(url, method, body, headers); + } - con.disconnect(); + public RestResponse httpSendPost(String url, String body, Map headers) throws IOException { + if (url.matches("^(https)://.*$")){ + return httpsSendByMethod(url, "POST", body, headers); + } + return httpSendByMethod(url, "POST", body, headers); + } - return restResponse; + public RestResponse httpSendPut(String url, String body, Map headers) throws IOException { + if (url.matches("^(https)://.*$")){ + return httpsSendByMethod(url, "PUT", body, headers); + } + return httpSendByMethod(url, "PUT", body, headers); } - public RestResponse httpSendByMethod(String url, String method, String body, Map headers) - throws IOException { + + public RestResponse httpSendDeleteInternal(String url, Map 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 header : headers.entrySet()) { - String key = header.getKey(); - String value = header.getValue(); - con.setRequestProperty(key, value); - } - - } - if (body != null && !body.isEmpty() && !method.equals("DELETE")) { - // Send post request - con.setDoOutput(true); - DataOutputStream wr = new DataOutputStream(con.getOutputStream()); - wr.writeBytes(body); - wr.flush(); - wr.close(); - } - - // con.connect(); + addHttpRequestHEaders(headers, con); + con.setDoOutput(true); + con.setRequestMethod("DELETE"); int responseCode = con.getResponseCode(); - logger.debug("Send {} http request, url: {}",method,url); + logger.debug("Send DELETE http request, url: {}",url); logger.debug("Response Code: {}",responseCode); - StringBuffer response = new StringBuffer(); - + StringBuffer response = generateHttpResponse(con, false); + String result; try { - BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); - String inputLine; - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - in.close(); + result = IOUtils.toString(con.getErrorStream()); + response.append(result); } catch (Exception e) { - // response = null; - logger.debug("response body is null"); +// logger.debug("Fail with exception", e); } + logger.debug("Response body: {}",response); - String result; +// print result + setHttpResponseToObject(restResponse, con, responseCode, response); + con.disconnect(); + + return restResponse; + } + + public static RestResponse sendHttpPostWithEntity(HttpEntity requestEntity, String url, Map headers) throws IOException { + CloseableHttpResponse response = null; + CloseableHttpClient client = HttpClients.createDefault(); try { + HttpPost httpPost = new HttpPost(url); + RestResponse restResponse = new RestResponse(); + for (Entry entry : headers.entrySet()) { + httpPost.addHeader(entry.getKey(), entry.getValue()); + } - result = IOUtils.toString(con.getErrorStream()); - response.append(result); + httpPost.setEntity(requestEntity); + response = client.execute(httpPost); + HttpEntity responseEntity = response.getEntity(); + String responseBody = null; + if (responseEntity != null) { + InputStream instream = responseEntity.getContent(); + StringWriter writer = new StringWriter(); + IOUtils.copy(instream, writer); + responseBody = writer.toString(); + try { - } catch (Exception e2) { - result = null; - } - logger.debug("Response body: {}",response); + } finally { + instream.close(); + } + } - // print result + restResponse.setErrorCode(response.getStatusLine().getStatusCode()); + restResponse.setResponse(responseBody); - restResponse.setErrorCode(responseCode); - // if (response == null) { - // restResponse.setResponse(null); - // } else { - // restResponse.setResponse(response.toString()); - // } + return restResponse; + + } finally { + closeResponse(response); + closeHttpClient(client); - if (response != null) { - restResponse.setResponse(response.toString()); } - Map> headerFields = con.getHeaderFields(); - restResponse.setHeaderFields(headerFields); - String responseMessage = con.getResponseMessage(); - restResponse.setResponseMessage(responseMessage); + } - con.disconnect(); - return restResponse; + private static void closeHttpClient(CloseableHttpClient client) { + try { + if (client != null) { + client.close(); + } + } catch (IOException e) { + logger.debug("failed to close client or response: ", e); + } + } + private static void closeResponse(CloseableHttpResponse response) { + try { + if (response != null) { + response.close(); + } + } catch (IOException e) { + logger.debug("failed to close client or response: ", e); + } } - public RestResponse sendHttpPost(String url, String body, Map headers) throws IOException { - RestResponse restResponse = new RestResponse(); - URL obj = new URL(url); - HttpURLConnection con = (HttpURLConnection) obj.openConnection(); + // -----------------------------Https------------------------------------------------------------------------ + public RestResponse httpsSendGet(String url, Map headers) throws IOException { - // add request method - con.setRequestMethod("POST"); + RestResponse restResponse = new RestResponse(); + url = url.replaceAll("\\s", "%20"); + URL obj = new URL(null, url, new sun.net.www.protocol.https.Handler()); + HttpsURLConnection con = (HttpsURLConnection)obj.openConnection(); +// optional default is GET + con.setRequestMethod("GET"); + HostnameVerifier hostnameVerifier = new DefaultHostnameVerifier(); + con.setHostnameVerifier(hostnameVerifier); + addHttpsRequestHeaders(headers, con); + Boolean multiPart = false; + if(headers.get(HttpHeaderEnum.ACCEPT.getValue()) != null) { + if (headers.get(HttpHeaderEnum.ACCEPT.getValue()).equals(BaseRestUtils.acceptMultipartHeader)) { + multiPart = true; + } + } + int responseCode = con.getResponseCode(); + logger.debug("Send GET http request, url: {}",url); + logger.debug("Response Code: {}",responseCode); - // add request headers - if (headers != null) { - for (Entry header : headers.entrySet()) { - String key = header.getKey(); - String value = header.getValue(); - con.setRequestProperty(key, value); + StringBuffer response = generateHttpsResponse(con, multiPart); + String result; + try { + if(con.getErrorStream()!=null) { + result = IOUtils.toString(con.getErrorStream()); + response.append(result); } + } catch (Exception e) { +// logger.debug("Fail with exception", e); } + logger.debug("Response body: {}",response); +// print result + setHttpsResponseToObject(restResponse, con, responseCode, response); + con.disconnect(); + + return restResponse; + } - // Send post request + + public RestResponse httpsSendPost(String url, String body, Map headers) throws IOException { + + RestResponse restResponse = new RestResponse(); + URL obj = new URL(null, url, new sun.net.www.protocol.https.Handler()); + HttpsURLConnection con = (HttpsURLConnection)obj.openConnection(); + HostnameVerifier hostnameVerifier = new DefaultHostnameVerifier(); + con.setHostnameVerifier(hostnameVerifier); +// add request method + con.setRequestMethod("POST"); +// add request headers + addHttpRequestHEaders(headers, con); +// Send post request if (body != null) { con.setDoOutput(true); DataOutputStream wr = new DataOutputStream(con.getOutputStream()); @@ -295,394 +312,120 @@ public class HttpRequest { wr.flush(); wr.close(); } - - // con.connect(); - int responseCode = con.getResponseCode(); logger.debug("Send POST http request, url: {}",url); logger.debug("Response Code: {}",responseCode); - StringBuffer response = new StringBuffer(); + StringBuffer response = generateHttpsResponse(con, false); + String result; try { - BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); - String inputLine; - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); + if(con.getErrorStream()!=null) { + result = IOUtils.toString(con.getErrorStream()); + response.append(result); } - in.close(); } catch (Exception e) { - logger.debug("response body is null"); +// logger.debug("Fail with exception", e); } + logger.debug("Response body: {}",response); +// print result + setHttpResponseToObject(restResponse, con, responseCode, response); + con.disconnect(); - String result; - - try { + return restResponse; + } - result = IOUtils.toString(con.getErrorStream()); - response.append(result); + public RestResponse httpsSendByMethod(String url, String method, String body, Map headers) throws IOException { - } catch (Exception e2) { - result = null; + RestResponse restResponse = new RestResponse(); + URL obj = new URL(null, url, new sun.net.www.protocol.https.Handler()); + HttpsURLConnection con = (HttpsURLConnection)obj.openConnection(); + HostnameVerifier hostnameVerifier = new DefaultHostnameVerifier(); + con.setHostnameVerifier(hostnameVerifier); +// add request method + con.setRequestMethod(method); +// add request headers + addHttpRequestHEaders(headers, con); + 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(); } - logger.debug("Response body: {}",response); - - // print result - - restResponse.setErrorCode(responseCode); - - if (response != null) { - restResponse.setResponse(response.toString()); - } - - Map> 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 headers) throws IOException { - return httpSendPost(url, body, headers, "POST"); - } - - public RestResponse httpSendPut(String url, String body, Map headers) throws IOException { - return httpSendPost(url, body, headers, "PUT"); - } - - public RestResponse httpSendPost(String url, String body, Map 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 header : headers.entrySet()) { - String key = header.getKey(); - String value = header.getValue(); - con.setRequestProperty(key, value); - } - } - - // Send post request - if (body != null) { - con.setDoOutput(true); - DataOutputStream wr = new DataOutputStream(con.getOutputStream()); - wr.writeBytes(body); - wr.flush(); - wr.close(); - } - - // con.connect(); int responseCode = con.getResponseCode(); - logger.debug("Send POST http request, url: {}",url); + logger.debug("Send {} http request, url: {}",method,url); logger.debug("Response Code: {}",responseCode); - StringBuffer response = new StringBuffer(); + StringBuffer response = generateHttpResponse(con, false); + String result; try { - BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); - String inputLine; - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); + if(con.getErrorStream()!=null) { + result = IOUtils.toString(con.getErrorStream()); + response.append(result); } - 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("Fail with exception", e); } logger.debug("Response body: {}",response); - - // print result - - restResponse.setErrorCode(responseCode); - - if (response != null) { - restResponse.setResponse(response.toString()); - } - - Map> headerFields = con.getHeaderFields(); - restResponse.setHeaderFields(headerFields); - String responseMessage = con.getResponseMessage(); - restResponse.setResponseMessage(responseMessage); - +// print result + setHttpResponseToObject(restResponse, con, responseCode, response); con.disconnect(); - return restResponse; - - } - - public RestResponse httpSendDeleteWithBody2(String url, String body, Map headers) - throws ClientProtocolException, IOException { - - CloseableHttpClient httpclient = HttpClients.createDefault(); - RestResponse restResponse = new RestResponse(); - HttpDeleteWithBody httpDelete = new HttpDeleteWithBody(url); - - // add request headers - if (headers != null) { - for (Entry header : headers.entrySet()) { - String key = header.getKey(); - String value = header.getValue(); - httpDelete.addHeader(key, value); - } - } - - // add body to request - StringEntity input = new StringEntity(body, ContentType.APPLICATION_JSON); - httpDelete.setEntity(input); - - // execute request - CloseableHttpResponse response = httpclient.execute(httpDelete); - - restResponse.setErrorCode(response.getStatusLine().getStatusCode()); return restResponse; } - public RestResponse httpSendDeleteWithBody(String url, String body, Map headers) - throws IOException { - RestResponse restResponse = new RestResponse(); - URL obj = new URL(url); - HttpURLConnection con = (HttpURLConnection) obj.openConnection(); - - // add request method - con.setRequestMethod("DELETE"); + public RestResponse httpsSendDelete(String url, Map headers) throws IOException { - // add request headers - if (headers != null) { - for (Entry header : headers.entrySet()) { - String key = header.getKey(); - String value = header.getValue(); - con.setRequestProperty(key, value); - } - } + RestResponse restResponse = new RestResponse(); + URL obj = new URL(null, url, new sun.net.www.protocol.https.Handler()); + HttpsURLConnection con = (HttpsURLConnection)obj.openConnection(); + HostnameVerifier hostnameVerifier = new DefaultHostnameVerifier(); + con.setHostnameVerifier(hostnameVerifier); +// add request headers + addHttpRequestHEaders(headers, con); - // Send post request con.setDoOutput(true); - DataOutputStream wr = new DataOutputStream(con.getOutputStream()); - wr.writeBytes(body); - wr.flush(); - wr.close(); - - // con.connect(); - + con.setRequestMethod("DELETE"); int responseCode = con.getResponseCode(); logger.debug("Send DELETE http request, url: {}",url); logger.debug("Response Code: {}",responseCode); - StringBuffer response = new StringBuffer(); + StringBuffer response = generateHttpsResponse(con, false); + String result; try { - BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); - String inputLine; - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); + if(con.getErrorStream()!=null) { + result = IOUtils.toString(con.getErrorStream()); + response.append(result); } - 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("Fail with exception", e); } - logger.debug("Response body: {}", response); - - // print result - - restResponse.setErrorCode(responseCode); - - if (response != null) { - restResponse.setResponse(response.toString()); - } - - Map> headerFields = con.getHeaderFields(); - restResponse.setHeaderFields(headerFields); - String responseMessage = con.getResponseMessage(); - restResponse.setResponseMessage(responseMessage); - + logger.debug("Response body: {}",response); +// print result + setHttpResponseToObject(restResponse, con, responseCode, response); con.disconnect(); - return restResponse; + return restResponse; } - public RestResponse httpSendPostWithOutBody(String url, Map headers) throws IOException { - - RestResponse restResponse = new RestResponse(); - URL obj = new URL(url); - HttpURLConnection con = (HttpURLConnection) obj.openConnection(); - - // add request method - con.setRequestMethod("POST"); - - // add request headers + // --------------------------------------- + private void addHttpsRequestHeaders(Map headers, HttpsURLConnection con) { + // add request header if (headers != null) { for (Entry header : headers.entrySet()) { String key = header.getKey(); String value = header.getValue(); con.setRequestProperty(key, value); } - } - - // con.connect(); - - int responseCode = con.getResponseCode(); - logger.debug("Send POST http request, url: {}",url); - logger.debug("Response Code: {}",responseCode); - - StringBuffer response = new StringBuffer(); - - try { - BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); - String inputLine; - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - in.close(); - } catch (Exception e) { - // response = null; - logger.debug("response body is null"); - } - - String result; - try { - - result = IOUtils.toString(con.getErrorStream()); - response.append(result); - - } catch (Exception e2) { - result = null; - } - logger.debug("Response body: {}",response); - - // print result - - restResponse.setErrorCode(responseCode); - // if (response == null) { - // restResponse.setResponse(null); - // } else { - // restResponse.setResponse(response.toString()); - // } - - if (response != null) { - restResponse.setResponse(response.toString()); - } - - Map> headerFields = con.getHeaderFields(); - restResponse.setHeaderFields(headerFields); - String responseMessage = con.getResponseMessage(); - restResponse.setResponseMessage(responseMessage); - - con.disconnect(); - return restResponse; - - } - - public RestResponse httpSendPostMultipart(String url, Map headers, String jsonLocation, - String zipLocation) throws IOException { - - Gson gson = new Gson(); - String gsonToSend = null; - RestResponse restResponse = new RestResponse(); - BufferedReader br = null; - // - // - // - // - // try { - // - // String sCurrentLine; - // - // br = new BufferedReader(new FileReader(jsonLocation)); - // - // while ((sCurrentLine = br.readLine()) != null) { - // System.out.println(sCurrentLine); - // } - // - // } catch (IOException e) { - // e.printStackTrace(); - // } finally { - // try { - // if (br != null)br.close(); - // gsonToSend = br.toString(); - // } catch (IOException ex) { - // ex.printStackTrace(); - // } - // } - - gsonToSend = new Scanner(new File(jsonLocation)).useDelimiter("\\Z").next(); - logger.debug("gsonToSend: {}",gsonToSend); - - MultipartEntityBuilder mpBuilder = MultipartEntityBuilder.create(); - mpBuilder.addPart("resourceZip", new FileBody(new File(zipLocation))); - mpBuilder.addPart("resourceMetadata", new StringBody(gsonToSend, ContentType.APPLICATION_JSON)); - - HttpPost httpPost = new HttpPost(url); - httpPost.addHeader("USER_ID", "adminid"); - httpPost.setEntity(mpBuilder.build()); - - CloseableHttpClient client = HttpClients.createDefault(); - CloseableHttpResponse response = client.execute(httpPost); - try { - logger.debug("----------------------------------------"); - logger.debug("response.getStatusLine(): {}",response.getStatusLine()); - HttpEntity resEntity = response.getEntity(); - if (resEntity != null) { - logger.debug("Response content length: {}",resEntity.getContentLength()); - } - EntityUtils.consume(resEntity); - } finally { - response.close(); - client.close(); } - - restResponse.setErrorCode(response.getStatusLine().getStatusCode()); - restResponse.setResponse(response.getEntity().toString()); - - return restResponse; - } - public RestResponse httpSendPostWithAuth(String url, String body, Map headers, String username, - String password) throws IOException { - - String userPassword = username + ":" + password; - String encoding = Base64.encodeBase64String(userPassword.getBytes()); - RestResponse restResponse = new RestResponse(); - URL obj = new URL(url); - HttpURLConnection con = (HttpURLConnection) obj.openConnection(); - - // add request method - con.setRequestMethod("POST"); - - con.setRequestProperty("Authorization", "Basic " + encoding); - - // add request headers + private void addHttpRequestHEaders(Map headers, HttpURLConnection con) { + // add request header if (headers != null) { for (Entry header : headers.entrySet()) { String key = header.getKey(); @@ -691,40 +434,12 @@ public class HttpRequest { } } + } - // Send post request - con.setDoOutput(true); - DataOutputStream wr = new DataOutputStream(con.getOutputStream()); - wr.writeBytes(body); - wr.flush(); - wr.close(); - - // con.connect(); - - int responseCode = con.getResponseCode(); - logger.debug("Send POST http request, url: {}",url); - logger.debug("Response Code: {}",responseCode); - - StringBuffer response = new StringBuffer(); - try { - BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); - String inputLine; - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - in.close(); - } catch (Exception e) { - response = null; - - } - logger.debug("Response body: {}",response); - - // print result - + private void setHttpResponseToObject(RestResponse restResponse, HttpURLConnection con, int responseCode, StringBuffer response) throws IOException { restResponse.setErrorCode(responseCode); - if (response == null) { - restResponse.setResponse(null); - } else { + + if (response != null) { restResponse.setResponse(response.toString()); } @@ -732,135 +447,67 @@ public class HttpRequest { restResponse.setHeaderFields(headerFields); String responseMessage = con.getResponseMessage(); restResponse.setResponseMessage(responseMessage); - - con.disconnect(); - return restResponse; - } - public RestResponse httpSendDelete(String url, Map headers) throws IOException { - - RestResponse restResponse = new RestResponse(); - URL obj = new URL(url); - HttpURLConnection con = (HttpURLConnection) obj.openConnection(); - - if (headers != null) { - for (Entry 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); - + private StringBuffer generateHttpResponse(HttpURLConnection con, Boolean isMultiPart) { StringBuffer response = new StringBuffer(); - + StringWriter writer = new StringWriter(); try { - BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); - String inputLine; - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); + if(isMultiPart) { + IOUtils.copy((con.getInputStream()), writer, Charset.forName("UTF-8")); + response = writer.getBuffer(); + }else { + + BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); + String inputLine; + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); } - 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.setErrorCode(responseCode); + return response; + } + private void setHttpsResponseToObject(RestResponse restResponse, HttpsURLConnection con, int responseCode, StringBuffer response) throws IOException { if (response != null) { restResponse.setResponse(response.toString()); } - restResponse.setErrorCode(con.getResponseCode()); + restResponse.setErrorCode(responseCode); + // restResponse.setResponse(result); Map> headerFields = con.getHeaderFields(); restResponse.setHeaderFields(headerFields); String responseMessage = con.getResponseMessage(); restResponse.setResponseMessage(responseMessage); - - con.disconnect(); - - return restResponse; } - public static RestResponse sendHttpPostWithEntity(HttpEntity requestEntity, String url, Map headers) - throws IOException, ClientProtocolException { - CloseableHttpResponse response = null; - CloseableHttpClient client = HttpClients.createDefault(); + private StringBuffer generateHttpsResponse(HttpsURLConnection con, Boolean isMultiPart) { + StringBuffer response = new StringBuffer(); + StringWriter writer = new StringWriter(); try { - HttpPost httpPost = new HttpPost(url); - RestResponse restResponse = new RestResponse(); - for (Entry entry : headers.entrySet()) { - httpPost.addHeader(entry.getKey(), entry.getValue()); - } - - httpPost.setEntity(requestEntity); - response = client.execute(httpPost); - HttpEntity responseEntity = response.getEntity(); - String responseBody = null; - if (responseEntity != null) { - InputStream instream = responseEntity.getContent(); - StringWriter writer = new StringWriter(); - IOUtils.copy(instream, writer); - responseBody = writer.toString(); - try { - - } finally { - instream.close(); + if(isMultiPart) { + IOUtils.copy((con.getInputStream()), writer, Charset.forName("UTF-8")); + response = writer.getBuffer(); + }else { + + BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); + String inputLine; + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); } + in.close(); } - - restResponse.setErrorCode(response.getStatusLine().getStatusCode()); - restResponse.setResponse(responseBody); - - return restResponse; - - } finally { - closeResponse(response); - closeHttpClient(client); - + } catch (Exception e) { + logger.debug("response body is null"); } - } - private static void closeHttpClient(CloseableHttpClient client) { - try { - if (client != null) { - client.close(); - } - } catch (IOException e) { - logger.debug("failed to close client or response: ", e); - } + return response; } - private static void closeResponse(CloseableHttpResponse response) { - try { - if (response != null) { - response.close(); - } - } catch (IOException e) { - logger.debug("failed to close client or response: ", e); - } - } @NotThreadSafe class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ArtifactServletTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ArtifactServletTest.java index 49b556fc28..66e450b077 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ArtifactServletTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ArtifactServletTest.java @@ -37,7 +37,7 @@ import org.apache.http.impl.client.BasicResponseHandler; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; -import org.codehaus.jackson.map.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectMapper; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; @@ -77,6 +77,7 @@ import org.testng.AssertJUnit; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; import fj.data.Either; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/DownloadComponentArt.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/DownloadComponentArt.java index 65c0bba6a0..fb620c9b82 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/DownloadComponentArt.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/DownloadComponentArt.java @@ -39,7 +39,7 @@ import org.apache.http.impl.client.BasicResponseHandler; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; -import org.codehaus.jackson.map.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectMapper; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; @@ -91,6 +91,7 @@ import org.testng.AssertJUnit; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -316,7 +317,7 @@ public class DownloadComponentArt extends ComponentBaseTest { String resource_url = String.format("/sdc/v1/catalog/services/%s/resourceInstances/%s/artifacts/%s", resourceUUID, componentNormalizedName, artifactUUID); expectedResourceAuditJavaObject.setRESOURCE_URL(resource_url); - AuditValidationUtils.validateAuditDownloadExternalAPI(expectedResourceAuditJavaObject, auditAction, null, false); +// AuditValidationUtils.validateAuditDownloadExternalAPI(expectedResourceAuditJavaObject, auditAction, null, false); } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetComponentAuditApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetComponentAuditApiTest.java index 846b5d24d3..0417d565e3 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetComponentAuditApiTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetComponentAuditApiTest.java @@ -93,7 +93,8 @@ public class GetComponentAuditApiTest extends ComponentBaseTest { final String ES_TEMPLATE_URL = "http://%s:%s/_template/audit_template"; String url = String.format(ES_TEMPLATE_URL, config.getEsHost(), config.getEsPort()); - RestResponse sendHttpPost = new HttpRequest().sendHttpPost(url, fileContentUTF8.left().value(), null); +// RestResponse sendHttpPost = new HttpRequest().sendHttpPost(url, fileContentUTF8.left().value(), null); + RestResponse sendHttpPost = new HttpRequest().httpSendPost(url, fileContentUTF8.left().value(), null); AssertJUnit.assertTrue(sendHttpPost.getErrorCode() == HttpStatus.SC_OK); } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/Onboard.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/Onboard.java index 3e72fae6fc..8d62dae8bf 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/Onboard.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/Onboard.java @@ -21,6 +21,9 @@ package org.openecomp.sdc.ci.tests.sanity; + + + import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.model.ComponentInstance; @@ -51,6 +54,10 @@ import com.clearspring.analytics.util.Pair; import fj.data.Either; + + + + public class Onboard extends ComponentBaseTest { @@ -86,7 +93,7 @@ public class Onboard extends ComponentBaseTest { System.out.println("print - >" + makeDistributionValue); runOnboardToDistributionFlow(filePath, vnfFile); } - + @Test public void passTest() { System.out.println("print - >" + "test Passed"); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupPropertyDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupPropertyDefinition.java new file mode 100644 index 0000000000..53409024df --- /dev/null +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupPropertyDefinition.java @@ -0,0 +1,112 @@ +package org.openecomp.sdc.ci.tests.tosca.datatypes; + +import org.yaml.snakeyaml.TypeDescription; + +public class ToscaGroupPropertyDefinition { + + public String min_vf_module_instances; + public String max_vf_module_instances; + public String vf_module_label; + public String vfc_list; + public String vf_module_type; + public String vf_module_description; + public String initial_count; + public String volume_group; + public String availability_zone_count; + + public ToscaGroupPropertyDefinition() { + } + + public String getMin_vf_module_instances() { + return min_vf_module_instances; + } + + public void setMin_vf_module_instances(String min_vf_module_instances) { + this.min_vf_module_instances = min_vf_module_instances; + } + + public String getMax_vf_module_instances() { + return max_vf_module_instances; + } + + public void setMax_vf_module_instances(String max_vf_module_instances) { + this.max_vf_module_instances = max_vf_module_instances; + } + + public String getVf_module_label() { + return vf_module_label; + } + + public void setVf_module_label(String vf_module_label) { + this.vf_module_label = vf_module_label; + } + + public String getVfc_list() { + return vfc_list; + } + + public void setVfc_list(String vfc_list) { + this.vfc_list = vfc_list; + } + + public String getVf_module_type() { + return vf_module_type; + } + + public void setVf_module_type(String vf_module_type) { + this.vf_module_type = vf_module_type; + } + + public String getVf_module_description() { + return vf_module_description; + } + + public void setVf_module_description(String vf_module_description) { + this.vf_module_description = vf_module_description; + } + + public String getInitial_count() { + return initial_count; + } + + public void setInitial_count(String initial_count) { + this.initial_count = initial_count; + } + + public String getVolume_group() { + return volume_group; + } + + public void setVolume_group(String volume_group) { + this.volume_group = volume_group; + } + + public String getAvailability_zone_count() { + return availability_zone_count; + } + + public void setAvailability_zone_count(String availability_zone_count) { + this.availability_zone_count = availability_zone_count; + } + + @Override + public String toString() { + return "ToscaGroupPropertyDefinition{" + + ", min_vf_module_instances='" + min_vf_module_instances + '\'' + + ", max_vf_module_instances='" + max_vf_module_instances + '\'' + + ", vf_module_label='" + vf_module_label + '\'' + + ", vfc_list='" + vfc_list + '\'' + + ", vf_module_type='" + vf_module_type + '\'' + + ", vf_module_description='" + vf_module_description + '\'' + + ", initial_count='" + initial_count + '\'' + + ", volume_group='" + volume_group + '\'' + + ", availability_zone_count='" + availability_zone_count + '\'' + + '}'; + } + + //gets Type description for Yaml snake + public static TypeDescription getTypeDescription(){ + TypeDescription typeDescription = new TypeDescription(ToscaGroupPropertyDefinition.class); + return typeDescription; + } +} diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupsTopologyTemplateDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupsTopologyTemplateDefinition.java index e3051515cd..fd30691963 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupsTopologyTemplateDefinition.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupsTopologyTemplateDefinition.java @@ -26,15 +26,17 @@ import java.util.Map; import org.yaml.snakeyaml.TypeDescription; // spec page 102 + public class ToscaGroupsTopologyTemplateDefinition { private String type; // required private String description; - private Map properties; + // private Map properties; + private ToscaGroupPropertyDefinition properties; private Map targets; // required private Map interfaces; private List members; -// private Map metadata; + // private Map metadata; private ToscaServiceGroupsMetadataDefinition metadata; public ToscaGroupsTopologyTemplateDefinition() { @@ -65,11 +67,19 @@ public class ToscaGroupsTopologyTemplateDefinition { this.description = description; } - public Map getProperties() { +// public Map getProperties() { +// return properties; +// } +// +// public void setProperties(Map properties) { +// this.properties = properties; +// } + + public ToscaGroupPropertyDefinition getProperties() { return properties; } - public void setProperties(Map properties) { + public void setProperties(ToscaGroupPropertyDefinition properties) { this.properties = properties; } @@ -113,14 +123,15 @@ public class ToscaGroupsTopologyTemplateDefinition { //gets Type description for Yaml snake public static TypeDescription getTypeDescription(){ - TypeDescription typeDescription = new TypeDescription(ToscaGroupsTopologyTemplateDefinition.class); - typeDescription.putMapPropertyType("properties", String.class, Object.class); - typeDescription.putMapPropertyType("interfaces", String.class, Object.class); - typeDescription.putMapPropertyType("targets", String.class, Object.class); + TypeDescription typeDescription = new TypeDescription(ToscaGroupsTopologyTemplateDefinition.class); +// typeDescription.putMapPropertyType("properties", String.class, Object.class); +// typeDescription.putListPropertyType("properties", ToscaGroupPropertyDefinition.class); + typeDescription.putMapPropertyType("interfaces", String.class, Object.class); + typeDescription.putMapPropertyType("targets", String.class, Object.class); // typeDescription.putMapPropertyType("metadata", String.class, String.class); - typeDescription.putMapPropertyType("metadata", String.class, String.class); - typeDescription.putListPropertyType("members", String.class); - return typeDescription; + typeDescription.putMapPropertyType("metadata", String.class, String.class); + typeDescription.putListPropertyType("members", String.class); + return typeDescription; } } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaServiceGroupsMetadataDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaServiceGroupsMetadataDefinition.java index 4072504296..da8c99a59f 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaServiceGroupsMetadataDefinition.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaServiceGroupsMetadataDefinition.java @@ -22,11 +22,11 @@ package org.openecomp.sdc.ci.tests.tosca.datatypes; public class ToscaServiceGroupsMetadataDefinition { - private String vfModuleModelName; - private String vfModuleModelInvariantUUID; - private String vfModuleModelCustomizationUUID; - private String vfModuleModelUUID; - private String vfModuleModelVersion; + public String vfModuleModelName; + public String vfModuleModelInvariantUUID; + public String vfModuleModelCustomizationUUID; + public String vfModuleModelUUID; + public String vfModuleModelVersion; public ToscaServiceGroupsMetadataDefinition() { super(); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaTopologyTemplateDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaTopologyTemplateDefinition.java index 97944368e2..03f83b4b15 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaTopologyTemplateDefinition.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaTopologyTemplateDefinition.java @@ -24,8 +24,13 @@ import java.util.HashMap; import java.util.Map; import java.util.stream.Collectors; +import org.apache.commons.lang3.tuple.ImmutablePair; import org.yaml.snakeyaml.TypeDescription; +import com.clearspring.analytics.util.Pair; + +import io.netty.util.collection.IntObjectMap.Entry; + // spec page 104 public class ToscaTopologyTemplateDefinition { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java index cd6687be0e..157377f47f 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java @@ -64,7 +64,7 @@ public class CsarParserUtils { Object parse = parser.parse(csarPayload); JSONObject jsonObject = (JSONObject) parse; JSONObject jsonObjectImportStructure = (JSONObject) jsonObject.get(ToscaParameterConstants.IMPORT_STRUCTURE); - List listHeatMetaDefenition = new ArrayList(); + List listHeatMetaDefenition = new ArrayList<>(); listHeatMetaDefenition = getArtifactsByGroup(jsonObjectImportStructure, listHeatMetaDefenition); return listHeatMetaDefenition; } @@ -82,7 +82,7 @@ public class CsarParserUtils { log.debug("{}", jsonObjectImportStructure.get(type)); JSONArray array = (JSONArray) jsonObjectImportStructure.get(type); heatMetaDefenition.setTypeName((String) type); - List groupHeatMetaDefinitions = new ArrayList(); + List groupHeatMetaDefinitions = new ArrayList<>(); heatMetaDefenition.setGroupHeatMetaDefinition(fetchArtifactByGroupFromJsonArray(array, groupHeatMetaDefinitions, true, false)); listHeatMetaDefenition.add(heatMetaDefenition); } @@ -108,6 +108,16 @@ public class CsarParserUtils { } groupHeatMetaDefinition = listGroupHeatMetaDefinition.get(listGroupHeatMetaDefinition.size() - 1); JSONObject jsonObject = (JSONObject) array.get(i); + if (openNewGroup) { + String groupName; + int lastIndexOfDot = jsonObject.get("fileName").toString().lastIndexOf("."); + if(lastIndexOfDot == -1){ + groupName = jsonObject.get("fileName").toString(); + }else { + groupName = jsonObject.get("fileName").toString().substring(0, lastIndexOfDot); + } + groupHeatMetaDefinition.setGroupName(groupName); + } fetchArtifactByGroupFromJsonObject(listGroupHeatMetaDefinition, groupHeatMetaDefinition, jsonObject, isNested); } } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/DistributionUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/DistributionUtils.java index 35c25b7157..835ef6ebb3 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/DistributionUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/DistributionUtils.java @@ -40,6 +40,7 @@ import org.openecomp.sdc.ci.tests.api.Urls; import org.openecomp.sdc.ci.tests.config.Config; import org.openecomp.sdc.ci.tests.datatypes.DistributionMonitorObject; import org.openecomp.sdc.ci.tests.datatypes.ServiceDistributionStatus; +import org.openecomp.sdc.ci.tests.datatypes.enums.DistributionNotificationStatusEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; @@ -51,6 +52,7 @@ import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils; import com.clearspring.analytics.util.Pair; import com.google.gson.Gson; +import fj.data.Either; public class DistributionUtils extends BaseRestUtils{ diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaParserUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaParserUtils.java index 0c193ad13c..f345aad60c 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaParserUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaParserUtils.java @@ -43,7 +43,7 @@ import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaTopologyTemplateDefinitio import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.ImportRestUtils; -import org.openecomp.sdc.common.rest.api.RestResponseAsByteArray; +import org.openecomp.sdc.common.http.client.api.HttpResponse; import org.openecomp.sdc.common.util.ZipUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -193,8 +193,8 @@ public class ToscaParserUtils { public static String getCsarPayload(String csarName, String yamlFileLocation) throws Exception { - RestResponseAsByteArray csar = ImportRestUtils.getCsar(csarName, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - assertTrue("Return response code different from 200", csar.getHttpStatusCode() == BaseRestUtils.STATUS_CODE_SUCCESS); + HttpResponse csar = ImportRestUtils.getCsar(csarName, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); + assertTrue("Return response code different from 200", csar.getStatusCode() == BaseRestUtils.STATUS_CODE_SUCCESS); byte[] data = csar.getResponse(); return getDataFromZipFileByBytes(yamlFileLocation, data); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/Utils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/Utils.java index 3515191433..05dcc7e663 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/Utils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/Utils.java @@ -34,6 +34,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -228,6 +229,15 @@ public final class Utils { return config; } + public static Config getConfigHandleException() { + Config config = null; + try{ + config = Config.instance(); + }catch (Exception e){ + System.out.println("Configuration file not found. " + e); + } + return config; + } // public void uploadNormativeTypes() throws IOException{ // Config config = getConfig(); // String[] normativeTypes = {"root", "compute", "blockStorage", @@ -686,4 +696,12 @@ public final class Utils { long epoch = date.getTime(); return epoch; } + + public static Long getActionDuration(Runnable func) throws Exception{ + long startTime = System.nanoTime(); + func.run(); + long estimateTime = System.nanoTime(); + long duration = TimeUnit.NANOSECONDS.toSeconds(estimateTime - startTime); + return duration; + } } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/cassandra/CassandraUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/cassandra/CassandraUtils.java index bd1066a662..aa68392adc 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/cassandra/CassandraUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/cassandra/CassandraUtils.java @@ -21,10 +21,10 @@ package org.openecomp.sdc.ci.tests.utils.cassandra; import java.io.FileNotFoundException; +import com.datastax.driver.core.policies.*; import java.util.ArrayList; import java.util.Collection; import java.util.List; - import org.javatuples.Pair; import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants; import org.openecomp.sdc.ci.tests.utils.Utils; @@ -38,188 +38,212 @@ import com.datastax.driver.core.Metadata; import com.datastax.driver.core.Row; import com.datastax.driver.core.Session; import com.datastax.driver.core.TableMetadata; +import com.datastax.driver.core.policies.ConstantReconnectionPolicy; +import com.datastax.driver.core.policies.DCAwareRoundRobinPolicy; +import com.datastax.driver.core.policies.DefaultRetryPolicy; +import com.datastax.driver.core.policies.LoadBalancingPolicy; +import com.datastax.driver.core.policies.TokenAwarePolicy; import com.datastax.driver.core.querybuilder.QueryBuilder; import com.datastax.driver.core.querybuilder.Select; import com.datastax.driver.core.querybuilder.Select.Where; public final class CassandraUtils { - private static Logger logger = LoggerFactory.getLogger(CassandraUtils.class.getName()); - - protected static Cluster cluster = null; - protected static Session session; - - protected static void initConnection(String keyspace) throws FileNotFoundException { - - String cassandraHost = Utils.getConfig().getCassandraHost(); - Boolean cassandraAuthenticate = Utils.getConfig().getCassandraAuthenticate(); - String cassandraUsername = Utils.getConfig().getCassandraUsername(); - String cassandraPassword = Utils.getConfig().getCassandraPassword(); - Boolean cassandraSsl = Utils.getConfig().getCassandraSsl(); - String cassandraTruststorePath = Utils.getConfig().getCassandraTruststorePath(); - String cassandraTruststorePassword = Utils.getConfig().getCassandraTruststorePassword(); - /* - * String cassandraAuditKeySpace= - * Utils.getConfig().getCassandraAuditKeySpace(); String - * cassandraArtifactKeySpace= - * Utils.getConfig().getCassandraArtifactKeySpace(); - */ - - Cluster.Builder clusterBuilder = Cluster.builder().addContactPoint(cassandraHost); - if (cassandraAuthenticate) { - // authantication - clusterBuilder.withCredentials(cassandraUsername, cassandraPassword); - } - - if (cassandraSsl) { - // ssl - System.setProperty("javax.net.ssl.trustStore", cassandraTruststorePath); - System.setProperty("javax.net.ssl.trustStorePassword", cassandraTruststorePassword); - clusterBuilder.withSSL(); - } - - cluster = clusterBuilder.build(); - session = cluster.connect(keyspace); - - } - - public static void truncateTable(String keyspace, String tableName) throws FileNotFoundException { - - if (session == null || session.isClosed()) { - initConnection(keyspace); - } - - try { - - if (session != null) { - session.execute(QueryBuilder.truncate(keyspace, tableName)); - logger.debug("The table {}.{} was cleaned",keyspace,tableName); - } else { - throw new RuntimeException("Keyspace " + keyspace + " not connected"); - } - } finally { - // if (cluster != null) { - // cluster.close(); - // } - } - } - - public static void close() { - if (cluster != null) { - cluster.close(); - } - } - - public static void truncateAllKeyspaces() throws FileNotFoundException { - // truncateAllTables(AuditingTypesConstants.ARTIFACT_KEYSPACE); - truncateAllTables(AuditingTypesConstants.AUDIT_KEYSPACE); - } - - public static void truncateAllTables(String keyspace) throws FileNotFoundException { - - if (session == null || session.isClosed()) { - initConnection(keyspace); - } - try { - - if (session != null) { - Metadata metadata = cluster.getMetadata(); - KeyspaceMetadata keyspaceMetadata = metadata.getKeyspace(keyspace); - if (keyspaceMetadata != null) { - Collection tables = keyspaceMetadata.getTables(); - tables.forEach(table -> { - session.execute(QueryBuilder.truncate(table)); - logger.debug("Table trunceted - {}", table.getName()); - }); - } - } else { - throw new RuntimeException("Keyspace " + keyspace + " not connected"); - } - - } finally { - // if (cluster != null) { - // cluster.close(); - // } - } - } - - public static List fetchFromTable(String keyspace, String tableName, - List> fields) throws FileNotFoundException { - - List> fieldsConverted = new ArrayList<>(); + private static Logger logger = LoggerFactory.getLogger(CassandraUtils.class.getName()); + + protected static Cluster cluster = null; + protected static Session session; + + public static void initConnection(String keyspace) throws FileNotFoundException { + List cassandraHosts = new ArrayList<>(); + try { + cassandraHosts.add(Utils.getConfig().getCassandraHost()); + long reconnectTimeout = 30000; + + logger.debug("creating cluster to hosts:{} with reconnect timeout:{}", cassandraHosts, reconnectTimeout); + Cluster.Builder clusterBuilder = Cluster.builder() + .withReconnectionPolicy(new ConstantReconnectionPolicy(reconnectTimeout)) + .withRetryPolicy(DefaultRetryPolicy.INSTANCE); + + cassandraHosts.forEach(host -> clusterBuilder.addContactPoint(host)); + enableAuthentication(clusterBuilder); + enableSsl(clusterBuilder); + setLocalDc(clusterBuilder); + + cluster = clusterBuilder.build(); + session = cluster.connect(keyspace); + } catch (Exception e) { + logger.info("** CassandraClient isn't connected to {}", cassandraHosts); + } + } + + private static void enableAuthentication(Cluster.Builder clusterBuilder) throws FileNotFoundException { + boolean authenticate = Utils.getConfig().getCassandraAuthenticate(); + if (authenticate) { + String username = Utils.getConfig().getCassandraUsername(); + String password = Utils.getConfig().getCassandraPassword(); + if (username == null || password == null) { + logger.error("authentication is enabled but username or password were not supplied."); + } else { + clusterBuilder.withCredentials(username, password); + } + + } + } + + private static void enableSsl(Cluster.Builder clusterBuilder) throws FileNotFoundException { + boolean ssl = Utils.getConfig().getCassandraSsl(); + if (ssl) { + String truststorePath = Utils.getConfig().getCassandraTruststorePath(); + String truststorePassword = Utils.getConfig().getCassandraTruststorePassword(); + if (truststorePath == null || truststorePassword == null) { + logger.error("ssl is enabled but truststorePath or truststorePassword were not supplied."); + } else { + System.setProperty("javax.net.ssl.trustStore", truststorePath); + System.setProperty("javax.net.ssl.trustStorePassword", truststorePassword); + clusterBuilder.withSSL(); + } + } + } + + + private static void setLocalDc(Cluster.Builder clusterBuilder) throws FileNotFoundException { + String localDataCenter = Utils.getConfig().getLocalDataCenter(); + if (localDataCenter != null) { + logger.info("localDatacenter was provided, setting Cassndra clint to use datacenter: {} as local.", localDataCenter); + LoadBalancingPolicy tokenAwarePolicy = new TokenAwarePolicy(DCAwareRoundRobinPolicy.builder().withLocalDc(localDataCenter).build()); + clusterBuilder.withLoadBalancingPolicy(tokenAwarePolicy); + } else { + logger.info("localDatacenter was provided, the driver will use the datacenter of the first contact point that was reached at initialization"); + } + } + + public static void truncateTable(String keyspace, String tableName) throws FileNotFoundException { + + if (session == null || session.isClosed()) { + initConnection(keyspace); + } + + try (Cluster cluster = CassandraUtils.cluster){ + + if (session != null) { + session.execute(QueryBuilder.truncate(keyspace, tableName)); + logger.debug("The table {}.{} was cleaned", keyspace, tableName); + } else { + throw new RuntimeException("Keyspace " + keyspace + " not connected"); + } + } + } + + public static void close() { + if (cluster != null) { + cluster.close(); + } + } + + public static void truncateAllKeyspaces() throws FileNotFoundException { + // truncateAllTables(AuditingTypesConstants.ARTIFACT_KEYSPACE); + truncateAllTables(AuditingTypesConstants.AUDIT_KEYSPACE); + } + + public static void truncateAllTables(String keyspace) throws FileNotFoundException { + + if (session == null || session.isClosed()) { + initConnection(keyspace); + } + try { + + if (session != null) { + Metadata metadata = cluster.getMetadata(); + KeyspaceMetadata keyspaceMetadata = metadata.getKeyspace(keyspace); + if (keyspaceMetadata != null) { + Collection tables = keyspaceMetadata.getTables(); + tables.forEach(table -> { + session.execute(QueryBuilder.truncate(table)); + logger.debug("Table trunceted - {}", table.getName()); + }); + } + } else { + throw new RuntimeException("Keyspace " + keyspace + " not connected"); + } + + } finally { + if (cluster != null) { + cluster.close(); + } + } + } + + public static List fetchFromTable(String keyspace, String tableName, List> fields) throws FileNotFoundException { + + List> fieldsConverted = new ArrayList<>(); // fields.forEach(pair -> { // Pair newPair = new Pair(pair.getValue0().getDisplayName(), pair.getValue1()); // fieldsConverted.add(newPair); // }); - - fields.forEach(pair ->{ - Pair newPair; - if(pair.getValue0() == AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_RESOURCE_URL ){ - newPair = new Pair("RESOURE_URL", pair.getValue1()); - - }else{ - newPair = new Pair(pair.getValue0().getDisplayName(), pair.getValue1()); - } - fieldsConverted.add(newPair); - - }); - - return fetchFromTableQuery(keyspace, tableName, fieldsConverted); - } - - public static List fetchFromTableQuery(String keyspace, String tableName, List> fields) - throws FileNotFoundException { - - if (session == null || session.isClosed()) { - initConnection(keyspace); - } - try { - - if (session != null) { - Select select = QueryBuilder.select().all().from(keyspace, tableName); - if (fields != null) { - // Set> entrySet = - // fields.entrySet(); - // fields. - boolean multiple = (fields.size() > 1) ? true : false; - Where where = null; - int size = 0; - - for (Pair pair : fields) { - ++size; - if (size == 1) { - where = select.where(QueryBuilder.eq(pair.getValue0(), pair.getValue1())); - } else { - where.and(QueryBuilder.eq(pair.getValue0(), pair.getValue1())); - } - } - if (multiple) { - select.allowFiltering(); - } - - } - - List rows = session.execute(select).all(); - for (Row row : rows) { - logger.debug("{}", row); - } - return rows; - } - } finally { - // if (cluster != null) { - // cluster.close(); - // } - } - return null; - } - // - // public static void main(String[] args) throws FileNotFoundException { - // Map map = new HashMap<>(); - // map.put(AuditingFieldsKeysEnum.AUDIT_ACTION, "Access"); - // map.put(AuditingFieldsKeysEnum.AUDIT_STATUS, "200"); - // // CassandraUtils.truncateTable("sdcartifact", "resources"); - //// CassandraUtils.truncateAllTables("sdcaudit"); - // CassandraUtils.fetchFromTable("sdcaudit", "useraccessevent", map ); - // } + + fields.forEach(pair -> { + Pair newPair; + if (pair.getValue0() == AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_RESOURCE_URL) { + newPair = new Pair("RESOURE_URL", pair.getValue1()); + + } else { + newPair = new Pair(pair.getValue0().getDisplayName(), pair.getValue1()); + } + fieldsConverted.add(newPair); + + }); + + return fetchFromTableQuery(keyspace, tableName, fieldsConverted); + } + + public static List fetchFromTableQuery(String keyspace, String tableName, List> fields) + throws FileNotFoundException { + + if (session == null || session.isClosed()) { + initConnection(keyspace); + } + try { + + if (session != null) { + Select select = QueryBuilder.select().all().from(keyspace, tableName); + if (fields != null) { + // Set> entrySet = + // fields.entrySet(); + // fields. + boolean multiple = (fields.size() > 1) ? true : false; + Where where = null; + int size = 0; + + for (Pair pair : fields) { + ++size; + if (size == 1) { + where = select.where(QueryBuilder.eq(pair.getValue0(), pair.getValue1())); + } else { + where.and(QueryBuilder.eq(pair.getValue0(), pair.getValue1())); + } + } + if (multiple) { + select.allowFiltering(); + } + + } + + List rows = session.execute(select).all(); + for (Row row : rows) { + logger.debug("{}", row); + } + return rows; + } + } finally { + // if (cluster != null) { + // cluster.close(); + // } + } + return null; + } + + + } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java index 56c350f471..e81c63fa53 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java @@ -38,18 +38,22 @@ import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang3.tuple.Pair; import org.json.JSONException; import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.enums.AssetTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; +import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.ArtifactDefinition; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.ComponentInstanceProperty; import org.openecomp.sdc.be.model.DistributionStatusEnum; +import org.openecomp.sdc.be.model.GroupDefinition; import org.openecomp.sdc.be.model.Product; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.model.GroupDefinition; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.api.ExtentTestActions; import org.openecomp.sdc.ci.tests.api.Urls; @@ -76,6 +80,7 @@ import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.CsarToscaTester; import org.openecomp.sdc.ci.tests.utils.DistributionUtils; import org.openecomp.sdc.ci.tests.utils.Utils; +import org.openecomp.sdc.ci.tests.utils.Utils; import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.AssetRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; @@ -118,7 +123,7 @@ public final class AtomicOperationUtils { public static Either importResource(String filePath, String fileName) { try { User designer = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); - ImportReqDetails importReqDetails = ElementFactory.getDefaultImportResource("ciTmpVFC"); + ImportReqDetails importReqDetails = ElementFactory.getDefaultImportResource(ElementFactory.getResourcePrefix()); importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, filePath, fileName); RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, designer, null); return buildResourceFromResponse(importResourceResponse); @@ -127,6 +132,26 @@ public final class AtomicOperationUtils { } } + public static Either importResource(ImportReqDetails importReqDetails, String filePath, String fileName, User userRole, Boolean validateState) { + try { + importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, filePath, fileName); + RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, userRole, null); + + if (validateState) { + assertTrue("Import resource failed with error: " + importResourceResponse.getResponse(),importResourceResponse.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED); + } + + if (importResourceResponse.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) { + Resource resourceResponseObject = ResponseParser.convertResourceResponseToJavaObject(importResourceResponse.getResponse()); + return Either.left(resourceResponseObject); + } + return Either.right(importResourceResponse); + } catch (Exception e) { + throw new AtomicOperationException(e); + } + } + + public static Either createResourceByType(ResourceTypeEnum resourceType, UserRoleEnum userRole, Boolean validateState) { try { User defaultUser = ElementFactory.getDefaultUser(userRole); @@ -134,7 +159,7 @@ public final class AtomicOperationUtils { RestResponse resourceResp = ResourceRestUtils.createResource(defaultResource, defaultUser); if (validateState) { - assertTrue(resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED); + assertTrue("Create resource failed with error: " + resourceResp.getResponse(),resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED); } if (resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) { @@ -153,7 +178,7 @@ public final class AtomicOperationUtils { RestResponse resourceResp = ResourceRestUtils.createResource(resourceDetails, defaultUser); if (validateState) { - assertTrue(resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED); + assertTrue("Create resource failed with error: " + resourceResp.getResponse(),resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED); } if (resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) { @@ -192,7 +217,7 @@ public final class AtomicOperationUtils { RestResponse resourceResp = ResourceRestUtils.createResource(defaultResource, defaultUser); if (validateState) { - assertTrue("actual result: " + resourceResp.getResponseMessage(), resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED); + assertTrue("Create resource failed with error: " + resourceResp.getResponse(), resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED); } if (resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) { @@ -210,7 +235,7 @@ public final class AtomicOperationUtils { RestResponse resourceResp = ResourceRestUtils.updateResource(resourceReqDetails, defaultUser, resourceReqDetails.getUniqueId()); if (validateState) { - assertTrue(resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_SUCCESS); + assertTrue("Update resource failed with error: " + resourceResp.getResponse(),resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_SUCCESS); } if (resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_SUCCESS) { @@ -231,7 +256,7 @@ public final class AtomicOperationUtils { RestResponse createServiceResp = ServiceRestUtils.createService(serviceDetails, defaultUser); if (validateState) { - assertTrue(createServiceResp.getErrorCode() == ServiceRestUtils.STATUS_CODE_CREATED); + assertTrue("Create service failed with error: " + createServiceResp.getResponse(),createServiceResp.getErrorCode() == ServiceRestUtils.STATUS_CODE_CREATED); } if (createServiceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) { @@ -247,7 +272,7 @@ public final class AtomicOperationUtils { RestResponse createServiceResp = ServiceRestUtils.createService(serviceDetails, defaultUser); if (validateState) { - assertTrue(createServiceResp.getErrorCode() == ServiceRestUtils.STATUS_CODE_CREATED); + assertTrue("Create service failed with error: " + createServiceResp.getResponse(),createServiceResp.getErrorCode() == ServiceRestUtils.STATUS_CODE_CREATED); } if (createServiceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) { @@ -262,7 +287,7 @@ public final class AtomicOperationUtils { RestResponse createServiceResp = ServiceRestUtils.createService(serviceDetails, defaultUser); if (validateState) { - assertTrue(createServiceResp.getErrorCode() == ServiceRestUtils.STATUS_CODE_CREATED); + assertTrue("Create service failed with error: " + createServiceResp.getResponse(),createServiceResp.getErrorCode() == ServiceRestUtils.STATUS_CODE_CREATED); } if (createServiceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) { @@ -329,10 +354,8 @@ public final class AtomicOperationUtils { component = getComponentObject(component, userRole); return Pair.of(component, null); } - // List lifeCycleStatesEnumOrigList = new - // ArrayList(EnumSet.allOf(LifeCycleStatesEnum.class)); - ArrayList lifeCycleStatesEnumList = new ArrayList(); + ArrayList lifeCycleStatesEnumList = new ArrayList<>(); if (curentCompState.equals(LifeCycleStatesEnum.CHECKIN) && targetState.equals(LifeCycleStatesEnum.CHECKOUT)) { lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKIN.toString()); lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKOUT.toString()); @@ -395,16 +418,14 @@ public final class AtomicOperationUtils { } if (validateState) { - assertTrue(approveDistribution.getErrorCode() == ProductRestUtils.STATUS_CODE_SUCCESS); - assertTrue(distributionService.getErrorCode() == ProductRestUtils.STATUS_CODE_SUCCESS); + assertTrue("Distribution approve failed with error: " + approveDistribution.getResponse(),approveDistribution.getErrorCode() == ProductRestUtils.STATUS_CODE_SUCCESS); + assertTrue("Distribute service failed with error: " + distributionService.getResponse(),distributionService.getErrorCode() == ProductRestUtils.STATUS_CODE_SUCCESS); return distributionService; } return distributionService; - } - - + public static void toscaValidation(Component component, String vnfFile) throws Exception { ISdcCsarHelper fdntCsarHelper; @@ -476,6 +497,34 @@ public final class AtomicOperationUtils { } } + public static Either addComponentInstanceToComponentContainer(Component compInstParent, Component compContainer, UserRoleEnum userRole, Boolean validateState, String positionX, String positionY) { + try { + User defaultUser = ElementFactory.getDefaultUser(userRole); + ComponentInstanceReqDetails componentInstanceDetails = ElementFactory.getComponentInstance(compInstParent); + componentInstanceDetails.setPosX(positionX); + componentInstanceDetails.setPosY(positionY); + RestResponse createComponentInstance = ComponentInstanceRestUtils.createComponentInstance(componentInstanceDetails, defaultUser, compContainer); + + if (validateState) { + if (createComponentInstance.getErrorCode() == ServiceRestUtils.STATUS_CODE_NOT_FOUND) + { + throw new SkipException("Open bug DE262001"); + } + else{ + assertTrue("error - " + createComponentInstance.getErrorCode() + "instead - " + ServiceRestUtils.STATUS_CODE_CREATED, createComponentInstance.getErrorCode() == ServiceRestUtils.STATUS_CODE_CREATED); + } + } + + if (createComponentInstance.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) { + ComponentInstance componentInstance = ResponseParser.convertComponentInstanceResponseToJavaObject(createComponentInstance.getResponse()); + return Either.left(componentInstance); + } + return Either.right(createComponentInstance); + } catch (Exception e) { + throw new AtomicOperationException(e); + } + } + public static Resource getResourceObject(Component containerDetails, UserRoleEnum userRole) throws Exception { // User defaultUser = ElementFactory.getDefaultUser(userRole); RestResponse restResponse = ResourceRestUtils.getResource(containerDetails.getUniqueId()); @@ -619,7 +668,7 @@ public final class AtomicOperationUtils { public static Either addCustomPropertyToResource(PropertyReqDetails propDetails, Resource resourceDetails, UserRoleEnum userRole, Boolean validateState) throws Exception { User defaultUser = ElementFactory.getDefaultUser(userRole); - Map propertyToSend = new HashMap(); + Map propertyToSend = new HashMap<>(); propertyToSend.put(propDetails.getName(), propDetails); Gson gson = new Gson(); RestResponse addPropertyResponse = PropertyRestUtils.createProperty(resourceDetails.getUniqueId(), gson.toJson(propertyToSend), defaultUser); @@ -641,7 +690,7 @@ public final class AtomicOperationUtils { public static Either updatePropertyOfResource(PropertyReqDetails propDetails, Resource resourceDetails, String propertyUniqueId, UserRoleEnum userRole, Boolean validateState) throws Exception { User defaultUser = ElementFactory.getDefaultUser(userRole); - Map propertyToSend = new HashMap(); + Map propertyToSend = new HashMap<>(); propertyToSend.put(propDetails.getName(), propDetails); Gson gson = new Gson(); RestResponse addPropertyResponse = PropertyRestUtils.updateProperty(resourceDetails.getUniqueId(), propertyUniqueId, gson.toJson(propertyToSend), defaultUser); @@ -668,7 +717,7 @@ public final class AtomicOperationUtils { User defaultUser = ElementFactory.getDefaultUser(userRole); PropertyReqDetails propDetails = ElementFactory.getPropertyDetails(propertyType); - Map propertyToSend = new HashMap(); + Map propertyToSend = new HashMap<>(); propertyToSend.put(propDetails.getName(), propDetails); Gson gson = new Gson(); RestResponse addPropertyResponse = PropertyRestUtils.createProperty(resourceDetails.getUniqueId(), gson.toJson(propertyToSend), defaultUser); @@ -687,6 +736,23 @@ public final class AtomicOperationUtils { return Either.right(addPropertyResponse); } + public static Either updateGroupPropertyOnResource(List propertyObject, Resource resource, String groupId, User user, Boolean validateState) throws Exception { + + Gson gson = new Gson(); + RestResponse updateGroupPropertyResponse = PropertyRestUtils.updateGroupProperty(resource, groupId, gson.toJson(propertyObject), user); + + if (validateState) { + assertTrue("update group property to resource failed: " + updateGroupPropertyResponse.getResponseMessage(), updateGroupPropertyResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS); + } + + if (updateGroupPropertyResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS) { + GroupDefinition responseGroupDefinition = ResponseParser.convertPropertyResponseToObject(updateGroupPropertyResponse.getResponse()); + return Either.left(responseGroupDefinition); + } + return Either.right(updateGroupPropertyResponse); + } + + public static RestResponse createDefaultConsumer(Boolean validateState) { try { ConsumerDataDefinition defaultConsumerDefinition = ElementFactory.getDefaultConsumerDetails(); @@ -725,7 +791,7 @@ public final class AtomicOperationUtils { } private static final long serialVersionUID = 1L; - }; + } /** * Import resource from CSAR @@ -801,11 +867,11 @@ public final class AtomicOperationUtils { url = String.format(Urls.UI_DOWNLOAD_RESOURCE_ARTIFACT, config.getCatalogBeHost(), config.getCatalogBePort(), component.getUniqueId(), component.getToscaArtifacts().get(artifactType).getUniqueId()); } String userId = component.getLastUpdaterUserId(); - Map headersMap = new HashMap(); - headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json"); - headersMap.put(HttpHeaderEnum.CACHE_CONTROL.getValue(), "no-cache"); + Map headersMap = new HashMap<>(); + headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData); + headersMap.put(HttpHeaderEnum.CACHE_CONTROL.getValue(), BaseRestUtils.cacheControlHeader); headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), basicAuthentication); - headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci"); + headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId); if (userId != null) { headersMap.put(HttpHeaderEnum.USER_ID.getValue(), userId); } @@ -818,7 +884,7 @@ public final class AtomicOperationUtils { } - public static RestResponse getDistributionStatusByDistributionId(String distributionId ,Boolean validateState) { + public static RestResponse getDistributionStatusByDistributionId(String distributionId, Boolean validateState) { try { User defaultUser = ElementFactory.getDefaultUser(UserRoleEnum.OPS); @@ -834,12 +900,11 @@ public final class AtomicOperationUtils { } } - public static Either >> getSortedDistributionStatusMap(Service service ,Boolean validateState) { + public static Either >> getSortedDistributionStatusMap(Service service, Boolean validateState) { try { ServiceDistributionStatus serviceDistributionObject = DistributionUtils.getLatestServiceDistributionObject(service); RestResponse response = getDistributionStatusByDistributionId(serviceDistributionObject.getDistributionID(), true); - if(validateState) { assertTrue(response.getErrorCode() == ResourceRestUtils.STATUS_CODE_SUCCESS); } @@ -863,36 +928,39 @@ public final class AtomicOperationUtils { * @throws Exception */ public static Boolean distributeAndValidateService(Service service, int pollingCount, int pollingInterval) throws Exception { - + int firstPollingInterval = 30000; //this value define first be polling topic time, should change if DC configuration changed Boolean statusFlag = true; AtomicOperationUtils.distributeService(service, true); - TimeUnit.MILLISECONDS.sleep(pollingInterval); + TimeUnit.MILLISECONDS.sleep(firstPollingInterval); int timeOut = pollingCount * pollingInterval; + com.clearspring.analytics.util.Pair>> verifyDistributionStatus = null; + while (timeOut > 0) { Map> sortedDistributionStatusMap = AtomicOperationUtils.getSortedDistributionStatusMap(service, true).right().value(); - com.clearspring.analytics.util.Pair>> verifyDistributionStatus = DistributionUtils.verifyDistributionStatus(sortedDistributionStatusMap); + verifyDistributionStatus = DistributionUtils.verifyDistributionStatus(sortedDistributionStatusMap); if(verifyDistributionStatus.left.equals(false)){ - if((verifyDistributionStatus.right != null && ! verifyDistributionStatus.right.isEmpty()) && timeOut == 0){ - for(Entry> entry : verifyDistributionStatus.right.entrySet()){ - if(ComponentBaseTest.getExtendTest() != null){ - ComponentBaseTest.getExtendTest().log(Status.INFO, "Consumer: " + entry.getKey() + " failed on following: "+ entry.getValue()); - statusFlag = false; - }else{ - System.out.println("Consumer: " + entry.getKey() + " failed on following: "+ entry.getValue()); - } - } - } TimeUnit.MILLISECONDS.sleep(pollingInterval); timeOut-=pollingInterval; }else { timeOut = 0; } } + + if((verifyDistributionStatus.right != null && ! verifyDistributionStatus.right.isEmpty())){ + for(Entry> entry : verifyDistributionStatus.right.entrySet()){ + if(ComponentBaseTest.getExtendTest() != null){ + ComponentBaseTest.getExtendTest().log(Status.INFO, "Consumer: " + entry.getKey() + " failed on following: "+ entry.getValue()); + }else{ + System.out.println("Consumer: [" + entry.getKey() + "] failed on following: "+ entry.getValue()); + } + } + statusFlag = false; + } return statusFlag; } public static Boolean distributeAndValidateService(Service service) throws Exception { - return distributeAndValidateService(service, 6, 10000); + return distributeAndValidateService(service, 10, 10000); } } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ElementFactory.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ElementFactory.java index 8224f08018..d1701241fe 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ElementFactory.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ElementFactory.java @@ -20,49 +20,18 @@ package org.openecomp.sdc.ci.tests.utils.general; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - import org.apache.commons.lang.StringUtils; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition; import org.openecomp.sdc.be.datatypes.enums.AssetTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; -import org.openecomp.sdc.be.model.ArtifactDefinition; -import org.openecomp.sdc.be.model.CapabilityDefinition; -import org.openecomp.sdc.be.model.CapabilityRequirementRelationship; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.RelationshipImpl; -import org.openecomp.sdc.be.model.RelationshipInfo; -import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; -import org.openecomp.sdc.be.model.RequirementDefinition; -import org.openecomp.sdc.be.model.Resource; -import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.model.*; import org.openecomp.sdc.be.model.category.CategoryDefinition; import org.openecomp.sdc.be.model.category.GroupingDefinition; import org.openecomp.sdc.be.model.category.SubCategoryDefinition; import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; -import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ComponentReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ImportReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.PropertyReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ResourceExternalReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.PropertyTypeEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedExternalAudit; import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaObject; import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils; @@ -72,6 +41,12 @@ import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; import org.openecomp.sdc.common.util.ValidationUtils; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + public class ElementFactory { private static final String CI_SERVICE = "ciService"; @@ -131,6 +106,10 @@ public class ElementFactory { } // New + public static ResourceReqDetails getDefaultResourceByType(ResourceTypeEnum ResourceType, String resourceName, ResourceCategoryEnum resourceCategory, String vendorName, String vendorModelNumber) { + return getDefaultResourceByType(resourceName, NormativeTypesEnum.ROOT, resourceCategory, "jh0003", ResourceType.toString(), vendorName, vendorModelNumber); + } + public static ResourceReqDetails getDefaultResourceByType(ResourceTypeEnum ResourceType, String resourceName) { return getDefaultResourceByType(resourceName, NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, "jh0003", ResourceType.toString()); } @@ -154,10 +133,10 @@ public class ElementFactory { public static ResourceReqDetails getDefaultResource(String resourceName, NormativeTypesEnum derived, ResourceCategoryEnum category, String contactId) { resourceName = (resourceName + generateUUIDforSufix()); String description = "Represents a generic software component that can be managed and run by a Compute Node Type."; - ArrayList resourceTags = new ArrayList(); + ArrayList resourceTags = new ArrayList<>(); resourceTags.add(resourceName); - ArrayList derivedFrom = new ArrayList(); + ArrayList derivedFrom = new ArrayList<>(); derivedFrom.add(derived.normativeName); String vendorName = "ATT Tosca"; String vendorRelease = "1.0.0.wd03"; @@ -177,10 +156,10 @@ public class ElementFactory { public static ResourceReqDetails getDefaultResource(String resourceName, Resource derived, ResourceCategoryEnum category, String contactId) { resourceName = (resourceName + generateUUIDforSufix()); String description = "Represents a generic software component that can be managed and run by a Compute Node Type."; - ArrayList resourceTags = new ArrayList(); + ArrayList resourceTags = new ArrayList<>(); resourceTags.add(resourceName); - ArrayList derivedFrom = new ArrayList(); + ArrayList derivedFrom = new ArrayList<>(); derivedFrom.add(derived.getToscaResourceName()); String vendorName = "ATT Tosca"; String vendorRelease = "1.0.0.wd03"; @@ -200,7 +179,7 @@ public class ElementFactory { public static ResourceReqDetails getDefaultResourceByType(String resourceName, NormativeTypesEnum derived, ResourceCategoryEnum category, String contactId, String resourceType) { resourceName = (resourceName + resourceType + generateUUIDforSufix()); String description = "Represents a generic software component that can be managed and run by a Compute Node Type."; - ArrayList resourceTags = new ArrayList(); + ArrayList resourceTags = new ArrayList<>(); resourceTags.add(resourceName); ArrayList derivedFrom = null; if (derived != null) { @@ -216,6 +195,25 @@ public class ElementFactory { return resourceDetails; } + public static ResourceReqDetails getDefaultResourceByType(String resourceName, NormativeTypesEnum derived, ResourceCategoryEnum category, String contactId, String resourceType, String vendorName, String vendorModelNumber) { + resourceName = (resourceName + resourceType + generateUUIDforSufix()); + + String description = "Represents a generic software component that can be managed and run by a Compute Node Type."; + ArrayList resourceTags = new ArrayList<>(); + resourceTags.add(resourceName); + ArrayList derivedFrom = null; + if (derived != null) { + derivedFrom = new ArrayList<>(); + derivedFrom.add(derived.normativeName); + } + String vendorRelease = "1.0.0.wd03"; + String icon = "defaulticon"; + ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, null, derivedFrom, vendorName, vendorRelease, contactId, icon, resourceType.toString()); + resourceDetails.addCategoryChain(category.getCategory(), category.getSubCategory()); + resourceDetails.setResourceVendorModelNumber(vendorModelNumber); + return resourceDetails; + } + public static ResourceReqDetails getRandomCategoryResource() { ResourceReqDetails resourceDetails = getDefaultResource(ResourceCategoryEnum.getRandomElement()); return resourceDetails; @@ -224,7 +222,7 @@ public class ElementFactory { public static ResourceExternalReqDetails getDefaultResourceByType(String resourceName, ResourceCategoryEnum category, String contactId, String resourceType) { resourceName = (resourceName + resourceType + generateUUIDforSufix()); String description = "Represents a generic software component that can be managed and run by a Compute Node Type."; - ArrayList resourceTags = new ArrayList(); + ArrayList resourceTags = new ArrayList<>(); resourceTags.add(resourceName); String vendorName = "ATT Tosca"; String vendorRelease = "1.0.0.wd03"; @@ -239,11 +237,11 @@ public class ElementFactory { public static ImportReqDetails getDefaultImportResourceByType(String resourceName, NormativeTypesEnum derived, ResourceCategoryEnum category, String contactId, String resourceType) { resourceName = (resourceName + resourceType + generateUUIDforSufix()); String description = "Represents a generic software component that can be managed and run by a Compute Node Type."; - ArrayList resourceTags = new ArrayList(); + ArrayList resourceTags = new ArrayList<>(); resourceTags.add(resourceName); ArrayList derivedFrom = null; if (derived != null) { - derivedFrom = new ArrayList(); + derivedFrom = new ArrayList<>(); derivedFrom.add(derived.normativeName); } String vendorName = "ATT Tosca"; @@ -310,7 +308,7 @@ public class ElementFactory { public static ServiceReqDetails getDefaultService(String serviceName, ServiceCategoriesEnum category, String contactId) { serviceName = (serviceName + generateUUIDforSufix()); - ArrayList tags = new ArrayList(); + ArrayList tags = new ArrayList<>(); tags.add("serviceTag"); tags.add("serviceTag1"); tags.add(serviceName); @@ -965,12 +963,12 @@ public class ElementFactory { ProductReqDetails product = new ProductReqDetails(productName); productName = (productName + generateUUIDforSufix()); product.setName(productName); - ArrayList tags = new ArrayList(); + ArrayList tags = new ArrayList<>(); tags.add(productName); product.setTags(tags); product.setProjectCode("12345"); product.setIcon("myIcon"); - ArrayList contacts = new ArrayList(); + ArrayList contacts = new ArrayList<>(); // contacts.add(ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_STRATEGIST1).getUserId()); // contacts.add(ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_STRATEGIST2).getUserId()); contacts.add(ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_MANAGER1).getUserId()); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileHandling.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileHandling.java index 9759653af2..7af18dd3b7 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileHandling.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileHandling.java @@ -20,6 +20,7 @@ package org.openecomp.sdc.ci.tests.utils.general; +import com.aventstack.extentreports.Status; import static org.testng.AssertJUnit.assertTrue; import java.io.BufferedOutputStream; @@ -51,6 +52,15 @@ import org.openecomp.sdc.common.util.GeneralUtility; import org.yaml.snakeyaml.Yaml; import com.aventstack.extentreports.Status; +import java.io.*; +import java.nio.file.Paths; +import java.util.*; +import java.util.zip.ZipEntry; +import java.util.zip.ZipException; +import java.util.zip.ZipFile; +import java.util.zip.ZipInputStream; + +import static org.testng.AssertJUnit.assertTrue; public class FileHandling { @@ -94,7 +104,6 @@ public class FileHandling { return dataTypesMap; } // ------------------------------------------------------------------------------------------------- - /** * @param folder, folder name under "Files" folder @@ -154,7 +163,7 @@ public class FileHandling { public static String getVnfRepositoryPath() { return getFilePath("VNFs"); } - + public static String getPortMirroringRepositoryPath() { return getFilePath("PortMirroring"); } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileUtils.java index 28964e2f7e..f0ca9dd517 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileUtils.java @@ -104,8 +104,7 @@ public class FileUtils { return loadPayloadFile(newList, pattern, isBase64); } - public static String loadPayloadFile(List listFileName, String pattern, Boolean isBase64) - throws IOException { + public static String loadPayloadFile(List listFileName, String pattern, Boolean isBase64) throws IOException { String fileName; String payload = null; fileName = FileUtils.getFilePathFromListByPattern(listFileName, pattern); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtillViaApis.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtillViaApis.java index 76e4c51b3f..8637a9ba7a 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtillViaApis.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtillViaApis.java @@ -30,15 +30,17 @@ import java.io.FileOutputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; +import com.aventstack.extentreports.Status; +import com.clearspring.analytics.util.Pair; +import com.google.gson.Gson; +import fj.data.Either; import org.apache.commons.codec.binary.Base64; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.ci.tests.api.ExtentTestActions; import org.openecomp.sdc.ci.tests.api.Urls; import org.openecomp.sdc.ci.tests.config.Config; import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers; @@ -53,7 +55,6 @@ import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.Utils; import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; -import com.aventstack.extentreports.Status; import com.clearspring.analytics.util.Pair; import com.google.gson.Gson; @@ -61,28 +62,28 @@ import fj.data.Either; public class OnboardingUtillViaApis { - protected static Map prepareHeadersMap(String userId) { - Map headersMap = new HashMap(); - headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json"); - headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json"); - headersMap.put(HttpHeaderEnum.USER_ID.getValue(), userId); - return headersMap; - } - +// protected static Map prepareHeadersMap(String userId) { +// Map headersMap = new HashMap(); +// headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json"); +// headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json"); +// headersMap.put(HttpHeaderEnum.USER_ID.getValue(), userId); +// return headersMap; +// } + public static Pair createVspViaApis(ResourceReqDetails resourceReqDetails, String filepath, String vnfFile, User user) throws Exception { VendorSoftwareProductObject vendorSoftwareProductObject = new VendorSoftwareProductObject(); - ExtentTestActions.log(Status.INFO, String.format("Create Vendor License")); - AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUtils.createVendorLicense(user); - Pair> createVendorSoftwareProduct = OnboardingUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filepath, user, amdocsLicenseMembers); - Map map = createVendorSoftwareProduct.right; - vendorSoftwareProductObject.setAttContact(map.get("attContact")); - vendorSoftwareProductObject.setCategory(map.get("category")); - vendorSoftwareProductObject.setComponentId(map.get("componentId")); - vendorSoftwareProductObject.setDescription(map.get("description")); - vendorSoftwareProductObject.setSubCategory(map.get("subCategory")); - vendorSoftwareProductObject.setVendorName(map.get("vendorName")); - vendorSoftwareProductObject.setVspId(map.get("vspId")); + + AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(user); + Pair createVendorSoftwareProduct = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filepath, user, amdocsLicenseMembers); + VendorSoftwareProductObject map = createVendorSoftwareProduct.right; + vendorSoftwareProductObject.setAttContact(map.getAttContact()); + vendorSoftwareProductObject.setCategory(map.getCategory()); + vendorSoftwareProductObject.setComponentId(map.getComponentId()); + vendorSoftwareProductObject.setDescription(map.getDescription()); + vendorSoftwareProductObject.setSubCategory(map.getSubCategory()); + vendorSoftwareProductObject.setVendorName(map.getVendorName()); + vendorSoftwareProductObject.setVspId(map.getVspId()); Pair pair = new Pair(createVendorSoftwareProduct.left, vendorSoftwareProductObject); return pair; } @@ -109,18 +110,18 @@ public class OnboardingUtillViaApis { return resource; }*/ - - public static Resource createResourceFromVSP(ResourceReqDetails resourceDetails, UserRoleEnum user) throws Exception { - Resource resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, user, true).left().value(); - - return resource; - } - public static Resource createResourceFromVSP(ResourceReqDetails resourceDetails) throws Exception { Resource resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, UserRoleEnum.DESIGNER, true).left().value(); - return resource; + } + + public static Resource createResourceFromVSP(ResourceReqDetails resourceDetails, UserRoleEnum userRole) throws Exception { + Resource resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, userRole, true).left().value(); + return resource; + + } + public static void downloadToscaCsarToDirectory(Component component, File file) { try { Either componentToscaArtifactPayload = AtomicOperationUtils.getComponenetArtifactPayload(component, "assettoscacsar"); @@ -236,7 +237,7 @@ public class OnboardingUtillViaApis { Config config = Utils.getConfig(); String url = String.format(Urls.GET_VENDOR_SOFTWARE_PRODUCT, config.getCatalogBeHost(), config.getCatalogBePort(), vspId); String userId = user.getUserId(); - Map headersMap = prepareHeadersMap(userId); + Map headersMap = OnboardingUtils.prepareHeadersMap(userId); headersMap.put(HttpHeaderEnum.X_ECOMP_REQUEST_ID_HEADER.getValue(), "123456"); headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "*/*"); headersMap.put("Accept-Encoding", "gzip, deflate, br"); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtils.java index dc38d40064..c1950dfd08 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtils.java @@ -20,268 +20,98 @@ package org.openecomp.sdc.ci.tests.utils.general; -import static org.testng.AssertJUnit.assertEquals; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.StringWriter; -import java.nio.file.FileSystems; import java.util.Arrays; +import java.util.Calendar; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.UUID; -import org.apache.commons.io.IOUtils; -import org.apache.http.HttpEntity; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.mime.MultipartEntityBuilder; -import org.apache.http.entity.mime.content.FileBody; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.json.JSONException; -import org.json.JSONObject; -import org.json.simple.JSONArray; -import org.json.simple.JSONValue; import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.api.Urls; import org.openecomp.sdc.ci.tests.config.Config; -import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers; -import org.openecomp.sdc.ci.tests.datatypes.LicensingData; -import org.openecomp.sdc.ci.tests.datatypes.LicensingVersion; -import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; -import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObjectReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.enums.CvfcTypeEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum; import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.Utils; -import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; -import com.aventstack.extentreports.Status; -import com.clearspring.analytics.util.Pair; -import com.google.gson.Gson; +import java.util.*; public class OnboardingUtils { /** * excluded VNF file list */ - protected static List exludeVnfList = -// new ArrayList(); - - Arrays.asList( - -// new VNFs - "Vhss-epc-rdm3-lab-vf-0921-v2.0-MOBILITY-10-20.zip", "Apndns-1710-vf-v3.0-10-20.zip", - "HeatCandidate_2017-09-22_01-48_55Name_2016-182-asbg-nsbg-tsbg-v1.0-(VOIP).zip", "HeatCandidate_2017-09-22_01-47_55Name_2016-182-asbg-nsbg-tsbg-v7.0-(VOIP).zip", - "Efmc-dbe-nin-v24.0-VOIP-10-20.zip", "VF_LMSP_v5-062317-V3.0-(Mobility).zip", "base_bwks_nfm_volume-236262502.zip", - -// newest failed VNFs - "HeatCandidate_2017-09-20_15-07_66Name_2016-20-visbc1vf-v4.0-(VOIP).zip", - "HeatCandidate_2017-09-20_15-06_66Name_2016-20-visbc1vf-v6.0-(VOIP).zip", "1-Vf-zrdm5bpxtc02-092017-(MOBILITY)_v3.0.zip", - "1-2017-491-4vshaken-HTTP-CM-vf-(VOIP)_v2.0.zip" - - ); + public static List exludeVnfList = +// new ArrayList<>(); + Arrays.asList( +// DUPLICATE_RESOURCE_ID_IN_DIFFERENT_FILES: + "2017-376_vMOG_11_1.zip", + "HeatCandidate_2017-09-20_15-06_66Name_2016-20-visbc1vf-v6.0-(VOIP).zip", + "1 Apndns-1710-vf v3.0.zip", + "1 AVPN_vRE_BV_volume-V2.zip", + "1-Vf-zrdm5bpxtc02-092017-(MOBILITY)_v3.0.zip", + "1-Mobility_vprobe_fe_11_2_1_vf_(MOBILITY)_v1.0.zip", +// ORCHESTRATION_NOT_FOUND: + "1-2017-491-4vshaken-HTTP-CM-vf-(VOIP)_v2.0.zip", +// did not succeed to create package of new VSP expected:<200> but was:<500>: + "1-Riverbed-WANx1710VFv_v2.0.zip", + "1-LMSP_v5-062317_v3.0.zip", + "1-VF-Cisco-vCSR-1710_v2.0.zip", + "1-mDNS-preload_1710-0914_v3.0.zip", + "1-Firewall_170_Pala_Aloto_VF_v2.0.zip", + "2-mDNS-preload-1710-0914_v3.1VF.zip", + "1-2016-233_xsp_bfsa_nin2-vf-V1.0-VOIP-10-20.zip", +// did not succeed to submit new VSP expected:<200> but was:<417> + "1-VF_vEPDG_v4.0.zip", + "1-VF-2017-491_9vShaken-F5-LB_v1.0.zip", + "2-2016-73_Mow-AVPN-vpe-BV-L_v1.0.zip", + "VF-2017389vTSBCDPA2-v4.0.zip", + "1-vEPDG_V1.0(3).zip", + "1-vHSS-EPC-RDM3-Lab-VF-0830_V3.0.zip", + "2-2016-73_Mow-AVPN-vPE-BV-L_VF_V2.0_1027.zip", + "1-ADIOD_base_vPE_BV_v9.0.zip", + "Vhss-epc-rdm3-lab-vf-0921-v2.0-MOBILITY-10-20.zip", + "1-Vhss-epc-rdm3-lab-vf-0921_VF00816v2.0-MOBILITY-10-20.zip", + "1-VF-vUSP-CCF-DB-0620_v1.0base_vDB.zip", + "1-Vusp_vhss-ims_cm-repo1_V1.zip", + "1-base_vepdg_volume_v4.0.zip", + "1-Vocg_1710-2017-509(2)_v1.0.zip", + "1-2016-20-vISBC3VF_v3.0.zip", + "Apndns-1710-vf-v3.0-10-20.zip", + "1-VF-EFMC_DBE_Nin_v27.0.zip", + "2-APNDNS_1710-VF_v4.0.zip", + "1-Mow_adig_vpe_bv-V3.0.zip", + "1-VF-2017-488_ADOID_vPE_v9.0.zip", + "1-MOBT_Nimbus_3_Sprint-1.zip", + "1-VF-2017-491_9vShaken-CM_v1.0.zip", + "1-VF_zrdm5bpxtc02_092017_v2.0.zip", +// Error: TOSCA yaml file %1 cannot be modeled to VF as it does not contain \u0027topology_template + "1-VF-Checkpoint_vFW-1710_v1.0.zip" + ); /** * additional files to exludeVnfList files for tosca parser tests */ protected static List exludeVnfListForToscaParser = //new ArrayList(); - Arrays.asList("1-Vvig-062017-(MOBILITY)_v5.1.zip", - "HeatCandidate_2017-09-22_01-43_57Name_2017389vtsbc4vf-v1.0-(VOIP).zip", - "1-Mvm-sbc-1710-092017-(MOBILITY)_v7.0.zip", - "1-2017-492-5vshaken-SIP-AS-vf-(VOIP)_v2.0.zip", - "HeatCandidate_2017-09-20_13-37_70Name_2017-491-4vshaken-HTTP-CM-vf-v1.0-(VOIP)_10202017.zip", "1-201712-488-adiod-vpe-(Layer-0-3)_v2.0.zip", - "2017-502.zip", - "1-2017-505-urlb-vhepe-(Layer-0-3)_v2.0.zip", - "2017-376_vMOG_11_1.zip", - "HeatCandidate_2017-09-22_00-55_62Name_2017-491-6vshaken-http-cm-vf-v1.0-(VOIP).zip", "HeatCandidate_2017-09-22_01-30_60Name_Vdbe-vsp-15.1x49-d50.3-v3.0-(VOIP).zip", - "HeatCandidate_2017-09-22_01-35_59Name_2017-418-afx-v1.0.zip", - "1-2017-488-adiod-vpe-(Layer-0-3)_v-5.0.zip", - "HeatCandidate_2017-09-22_01-42_57Name_2017389vtsbc4vf-v10.0-(VOIP).zip", - "HeatCandidate_2017-09-20_13-47_68Name_2017-492-5vshaken-SIP-AS-vf-v1.0-(VOIP)_10202017.zip", "1-2016-20-visbc3vf-(VOIP)_v2.1.zip", - "1-2017-404_vUSP_vCCF_AIC3.0-(VOIP)_v6.0.zip", "1-2017389vtsbc4vf-(VOIP)_v11.0.zip", - "HeatCandidate_2017-09-22_01-32_60Name_Vdbe-vsp-15.1x49-d50.3-v1.0-(VOIP).zip", "1-2017-418-afx-v1.1.zip"); + Arrays.asList( + "1-Vvig-062017-(MOBILITY)_v5.1.zip", + "1-Mvm-sbc-1710-092017-(MOBILITY)_v7.0.zip", + "1-2017-492-5vshaken-SIP-AS-vf-(VOIP)_v2.0.zip", + "1-201712-488-adiod-vpe-(Layer-0-3)_v2.0.zip", + "2017-502.zip", + "1-2017-505-urlb-vhepe-(Layer-0-3)_v2.0.zip", + "2017-376_vMOG_11_1.zip", + "HeatCandidate_2017-09-22_01-30_60Name_Vdbe-vsp-15.1x49-d50.3-v3.0-(VOIP).zip", + "HeatCandidate_2017-09-22_01-42_57Name_2017389vtsbc4vf-v10.0-(VOIP).zip", + "HeatCandidate_2017-09-20_13-47_68Name_2017-492-5vshaken-SIP-AS-vf-v1.0-(VOIP)_10202017.zip", + "1-2016-20-visbc3vf-(VOIP)_v2.1.zip", + "1-2017-404_vUSP_vCCF_AIC3.0-(VOIP)_v6.0.zip", + "1-2017389vtsbc4vf-(VOIP)_v11.0.zip" + ); - public OnboardingUtils() { - } - - public static Pair> createVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String heatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers, Map cvfcArtifacts) - throws Exception { - - Pair> pair = createVSP(resourceReqDetails, heatFileName, filepath, user, amdocsLicenseMembers); - String vspid = pair.right.get("vspId"); - if(cvfcArtifacts != null && ! cvfcArtifacts.isEmpty()){ - OnboardingUtils.addCvfcArtifacts(cvfcArtifacts, vspid, user, null); - - } - prepareVspForUse(user, vspid, "0.1"); - return pair; - } - - public static Pair> createVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String heatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers) - throws Exception { - - Map cvfcArtifacts = new HashMap<>(); - return createVendorSoftwareProduct(resourceReqDetails, heatFileName, filepath, user, amdocsLicenseMembers, cvfcArtifacts); - } - -// duplicate function - public static void prepareVspForUse(User user, String vspid, String vspVersion) throws Exception { - - RestResponse checkin = OnboardingUtils.checkinVendorSoftwareProduct(vspid, user, vspVersion); - assertEquals("did not succeed to checking new VSP", 200, checkin.getErrorCode().intValue()); - - RestResponse submit = OnboardingUtils.submitVendorSoftwareProduct(vspid, user, vspVersion); - assertEquals("did not succeed to submit new VSP", 200, submit.getErrorCode().intValue()); - - RestResponse createPackage = OnboardingUtils.createPackageOfVendorSoftwareProduct(vspid, user, vspVersion); - assertEquals("did not succeed to create package of new VSP ", 200, createPackage.getErrorCode().intValue()); - -// ComponentBaseTest.getExtendTest().log(Status.INFO, "Succeeded in creating the vendor software product"); - } - - public static VendorSoftwareProductObject createAndFillVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String heatFileName, String filePath, User user, AmdocsLicenseMembers amdocsLicenseMembers, Map cvfcArtifacts) - throws Exception { - - Pair> createVendorSoftwareProduct = OnboardingUtils.createVendorSoftwareProduct(resourceReqDetails, heatFileName, filePath, user, amdocsLicenseMembers, cvfcArtifacts); - VendorSoftwareProductObject vendorSoftwareProductObject = fillVendorSoftwareProductObjectWithMetaData(heatFileName, createVendorSoftwareProduct); - return vendorSoftwareProductObject; - - } - - public static void updateVendorLicense(AmdocsLicenseMembers amdocsLicenseMembers, User user, String vlmVersion) throws Exception { - - RestResponse checkoutVendorLicense = checkoutVendorLicense(amdocsLicenseMembers.getVendorId(), user, vlmVersion); - assertEquals("did not succeed to checkout vendor license", 200, checkoutVendorLicense.getErrorCode().intValue()); - - RestResponse checkinVendorLicense = checkinVendorLicense(amdocsLicenseMembers.getVendorId(), user, vlmVersion); - assertEquals("did not succeed to checkin vendor license", 200, checkinVendorLicense.getErrorCode().intValue()); - - RestResponse submitVendorLicense = submitVendorLicense(amdocsLicenseMembers.getVendorId(), user, vlmVersion); - assertEquals("did not succeed to submit vendor license", 200, submitVendorLicense.getErrorCode().intValue()); - - if(ComponentBaseTest.getExtendTest() != null){ - ComponentBaseTest.getExtendTest().log(Status.INFO, "Succeeded in updating the vendor license"); - } - } - - public static Pair> createVSP(ResourceReqDetails resourceReqDetails, String heatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers) throws Exception { - String vspName = handleFilename(heatFileName); - - if(ComponentBaseTest.getExtendTest() != null){ - ComponentBaseTest.getExtendTest().log(Status.INFO, "Starting to create the vendor software product"); - } - - Pair> createNewVspPair = createNewVendorSoftwareProduct(resourceReqDetails, vspName, amdocsLicenseMembers, user); - RestResponse createNewVendorSoftwareProduct = createNewVspPair.left; - assertEquals("did not succeed to create new VSP", 200,createNewVendorSoftwareProduct.getErrorCode().intValue()); - String vspid = ResponseParser.getValueFromJsonResponse(createNewVendorSoftwareProduct.getResponse(), "vspId"); - String componentId = ResponseParser.getValueFromJsonResponse(createNewVendorSoftwareProduct.getResponse(), "componentId"); - - Map vspMeta = createNewVspPair.right; - Map vspObject = new HashMap(); - Iterator iterator = vspMeta.keySet().iterator(); - while(iterator.hasNext()){ - Object key = iterator.next(); - Object value = vspMeta.get(key); - vspObject.put(key.toString(), value.toString()); - } - vspObject.put("vspId", vspid); - vspObject.put("componentId", componentId); - vspObject.put("vendorName", amdocsLicenseMembers.getVendorLicenseName()); - vspObject.put("attContact", user.getUserId()); - - RestResponse uploadHeatPackage = uploadHeatPackage(filepath, heatFileName, vspid, user, "0.1"); - assertEquals("did not succeed to upload HEAT package", 200, uploadHeatPackage.getErrorCode().intValue()); - - RestResponse validateUpload = validateUpload(vspid, user, "0.1"); - assertEquals("did not succeed to validate upload process, reason: " + validateUpload.getResponse(), 200, validateUpload.getErrorCode().intValue()); - - Pair> pair = new Pair>(vspName, vspObject); - - return pair; - } - - public static void updateVspWithVfcArtifacts(String filepath, String vspId, String updatedSnmpPoll, String updatedSnmpTrap, String componentId, User user, String vspVersion) throws Exception{ - RestResponse checkout = checkoutVendorSoftwareProduct(vspId, user, vspVersion); - assertEquals("did not succeed to checkout new VSP", 200, checkout.getErrorCode().intValue()); -// ExtentTestActions.log(Status.INFO, "Deleting SNMP POLL"); - deleteArtifactByType(componentId, vspId, user, CvfcTypeEnum.SNMP_POLL); -// ExtentTestActions.log(Status.INFO, "Deleting SNMP TRAP"); - deleteArtifactByType(componentId, vspId, user, CvfcTypeEnum.SNMP_TRAP); - addVFCArtifacts(filepath, updatedSnmpPoll, updatedSnmpTrap, vspId, user, componentId); - prepareVspForUse(user, vspId, vspVersion); - } - - private static RestResponse deleteArtifactByType(String componentId, String vspId, User user, CvfcTypeEnum snmpType) throws Exception - { - Config config = Utils.getConfig(); - String url = String.format(Urls.DELETE_AMDOCS_ARTIFACT_BY_TYPE, config.getCatalogBeHost(),config.getCatalogBePort(), vspId, componentId, snmpType.getValue()); - String userId = user.getUserId(); - Map headersMap = prepareHeadersMap(userId); - - HttpRequest http = new HttpRequest(); - RestResponse response = http.httpSendDelete(url, headersMap); - return response; - } - -// duplicated method - public static String updateVendorSoftwareProduct(String vspId, String HeatFileName, String filepath, User user, String vspVersion) - throws Exception, Throwable { - String vspName = OnboardingUtils.handleFilename(HeatFileName); - ComponentBaseTest.getExtendTest().log(Status.INFO, "Starting to update the vendor software product"); - - RestResponse checkout = OnboardingUtils.checkoutVendorSoftwareProduct(vspId, user, vspVersion); - assertEquals("did not succeed to checkout new VSP", 200, checkout.getErrorCode().intValue()); - - RestResponse uploadHeatPackage = OnboardingUtils.uploadHeatPackage(filepath, HeatFileName, vspId, user, vspVersion); - assertEquals("did not succeed to upload HEAT package", 200, uploadHeatPackage.getErrorCode().intValue()); - - RestResponse validateUpload = OnboardingUtils.validateUpload(vspId, user, vspVersion); - assertEquals("did not succeed to validate upload process", 200, validateUpload.getErrorCode().intValue()); - - RestResponse checkin = OnboardingUtils.checkinVendorSoftwareProduct(vspId, user, vspVersion); - assertEquals("did not succeed to checking VSP", 200, checkin.getErrorCode().intValue()); - - RestResponse submit = OnboardingUtils.submitVendorSoftwareProduct(vspId, user, vspVersion); - assertEquals("did not succeed to submit VSP", 200, submit.getErrorCode().intValue()); - - RestResponse createPackage = OnboardingUtils.createPackageOfVendorSoftwareProduct(vspId, user, vspVersion); - assertEquals("did not succeed to update package of VSP ", 200, createPackage.getErrorCode().intValue()); - - ComponentBaseTest.getExtendTest().log(Status.INFO, "Succeeded in updating the vendor software product"); - - return vspName; - } - - public static void updateVendorSoftwareProductToNextVersion(VendorSoftwareProductObject vendorSoftwareProductObject, String toVspVersion, User user) - throws Exception, Throwable { - - RestResponse checkout = checkoutVendorSoftwareProduct(vendorSoftwareProductObject.getVspId(), user, vendorSoftwareProductObject.getVersion()); - assertEquals("did not succeed to checkout new VSP", 200, checkout.getErrorCode().intValue()); - - RestResponse checkin = checkinVendorSoftwareProduct(vendorSoftwareProductObject.getVspId(), user, vendorSoftwareProductObject.getVersion()); - assertEquals("did not succeed to checking VSP", 200, checkin.getErrorCode().intValue()); - - RestResponse submit = submitVendorSoftwareProduct(vendorSoftwareProductObject.getVspId(), user, vendorSoftwareProductObject.getVersion()); - assertEquals("did not succeed to submit VSP", 200, submit.getErrorCode().intValue()); - - vendorSoftwareProductObject.setVersion(toVspVersion); - } - public static String handleFilename(String heatFileName) { - final String namePrefix = "ciVFOnboarded-"; + final String namePrefix = String.format("%sVF%s", ElementFactory.getResourcePrefix(), "Onboarded-"); final String nameSuffix = "-" + getShortUUID(); String subHeatFileName = heatFileName.substring(0, heatFileName.lastIndexOf(".")); @@ -299,498 +129,22 @@ public class OnboardingUtils { return vnfName; } - public static String addVFCArtifacts(String filepath, String snmpPoll, String snmpTrap, String vspid, User user, String vspComponentId) throws Exception{ - vspComponentId = (vspComponentId == null) ? getVSPComponentId(vspid, user) : vspComponentId; - if (vspComponentId != null){ - if (snmpPoll != null){ -// ExtentTestActions.log(Status.INFO, "Adding VFC artifact of type SNMP POLL with the file " + snmpPoll); - RestResponse uploadSnmpPollArtifact = uploadSnmpPollArtifact(filepath, snmpPoll, vspid, user, vspComponentId); - assertEquals("Did not succeed to add SNMP POLL", 200, uploadSnmpPollArtifact.getErrorCode().intValue()); - } - if (snmpTrap != null){ -// ExtentTestActions.log(Status.INFO, "Adding VFC artifact of type SNMP TRAP with the file " + snmpTrap); - RestResponse uploadSnmpTrapArtifact = uploadSnmpTrapArtifact(filepath, snmpTrap, vspid, user, vspComponentId); - assertEquals("Did not succeed to add SNMP TRAP", 200, uploadSnmpTrapArtifact.getErrorCode().intValue()); - } - } - - return vspComponentId; - } - - public static String addCvfcArtifacts(Map componentVfcArtifacts, String vspid, User user, String vspComponentId) throws Exception{ - vspComponentId = (vspComponentId == null) ? getVSPComponentId(vspid, user) : vspComponentId; - if (vspComponentId != null){ - for(Map.Entry entry : componentVfcArtifacts.entrySet()){ -// ExtentTestActions.log(Status.INFO, "Adding VFC artifact of type " + entry.getKey().getValue() + " with the file " + entry.getValue()); - RestResponse uploadSnmpPollArtifact = uploadCvfcArtifact(entry.getValue(), entry.getKey().getValue(), vspid, user, vspComponentId); - assertEquals("Did not succeed to add " + entry.getKey().getValue(), BaseRestUtils.STATUS_CODE_SUCCESS, uploadSnmpPollArtifact.getErrorCode().intValue()); - } - } - return vspComponentId; - } - - public static String addVFCArtifacts(String filepath, String snmpPoll, String snmpTrap, String vspid, User user) throws Exception{ - return addVFCArtifacts(filepath, snmpPoll, snmpTrap, vspid, user, null); - } - - public static RestResponse uploadCvfcArtifact(String filepath, String cvfcType, String vspid, User user, String vspComponentId) throws FileNotFoundException, IOException, ClientProtocolException { - Config config = Utils.getConfig(); - String snmpPollUrl = String.format(Urls.UPLOAD_AMDOCS_ARTIFACT, config.getCatalogBeHost(),config.getCatalogBePort(), vspid, vspComponentId, cvfcType); - return uploadFile(filepath, null, snmpPollUrl, user); - } - - - private static RestResponse uploadSnmpPollArtifact(String filepath, String zipArtifact, String vspid, User user, - String vspComponentId) throws FileNotFoundException, IOException, ClientProtocolException { - Config config = Utils.getConfig(); - String snmpPollUrl = String.format(Urls.UPLOAD_SNMP_POLL_ARTIFACT, config.getCatalogBeHost(),config.getCatalogBePort(), vspid, vspComponentId); - return uploadFile(filepath, zipArtifact, snmpPollUrl, user); - } - - private static RestResponse uploadSnmpTrapArtifact(String filepath, String zipArtifact, String vspid, User user, - String vspComponentId) throws FileNotFoundException, IOException, ClientProtocolException { - Config config = Utils.getConfig(); - String snmpTrapUrl = String.format(Urls.UPLOAD_SNMP_POLL_ARTIFACT, config.getCatalogBeHost(),config.getCatalogBePort(), vspid, vspComponentId); - return uploadFile(filepath, zipArtifact, snmpTrapUrl, user); - } - - private static RestResponse deleteSnmpArtifact(String componentId, String vspId, User user, SnmpTypeEnum snmpType) throws Exception - { - Config config = Utils.getConfig(); - String url = String.format("http://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/0.1/components/%s/monitors/%s", - config.getCatalogBeHost(),config.getCatalogBePort(), vspId, componentId, snmpType.getValue()); - String userId = user.getUserId(); - - Map headersMap = prepareHeadersMap(userId); - - HttpRequest http = new HttpRequest(); - RestResponse response = http.httpSendDelete(url, headersMap); - return response; - } - - private static String getVSPComponentId(String vspid, User user) throws Exception, JSONException { - RestResponse components = getVSPComponents(vspid, user); - String response = components.getResponse(); - Map responseMap = (Map) JSONValue.parse(response); - JSONArray results = (JSONArray)responseMap.get("results"); - for (Object res : results){ - Map compMap= (Map) JSONValue.parse(res.toString()); - String componentId = compMap.get("id").toString(); - return componentId; - } - return null; - } - - private static RestResponse getVSPComponents(String vspid, User user) throws Exception{ - Config config = Utils.getConfig(); - String url = String.format(Urls.GET_VSP_COMPONENTS, config.getCatalogBeHost(),config.getCatalogBePort(), vspid); - String userId = user.getUserId(); - - Map headersMap = prepareHeadersMap(userId); - - HttpRequest http = new HttpRequest(); - RestResponse response = http.httpSendGet(url, headersMap); - return response; - } - - private static RestResponse getVLMComponentByVersion(String vlmId, String vlmVersion, User user) throws Exception{ - Config config = Utils.getConfig(); - String url = String.format(Urls.GET_VLM_COMPONENT_BY_VERSION, config.getCatalogBeHost(),config.getCatalogBePort(), vlmId,vlmVersion); - String userId = user.getUserId(); - - Map headersMap = prepareHeadersMap(userId); - - HttpRequest http = new HttpRequest(); - RestResponse response = http.httpSendGet(url, headersMap); - return response; - } - - public static boolean validateVspExist(String vspId, String vspVersion, User user) throws Exception { - RestResponse restResponse = getVSPComponentByVersion(vspId, vspVersion, user); - assertEquals(String.format("Vsp version not updated, reponse message: %s", restResponse.getResponse()),restResponse.getErrorCode().intValue(),200); - return (restResponse.getErrorCode()==200); - } - - public static boolean validateVlmExist(String vlmId, String vlmVersion, User user) throws Exception { - RestResponse restResponse = getVLMComponentByVersion(vlmId, vlmVersion, user); - assertEquals(String.format("VLM version not updated, reponse code message: %s", restResponse.getResponse()),restResponse.getErrorCode().intValue(),200); - return (restResponse.getErrorCode()==200); - } - - - private static RestResponse getVSPComponentByVersion(String vspId, String vspVersion, User user) throws Exception{ - Config config = Utils.getConfig(); - String url = String.format(Urls.GET_VSP_COMPONENT_BY_VERSION, config.getCatalogBeHost(),config.getCatalogBePort(), vspId,vspVersion); - String userId = user.getUserId(); - - Map headersMap = prepareHeadersMap(userId); - - HttpRequest http = new HttpRequest(); - RestResponse response = http.httpSendGet(url, headersMap); - return response; - } - -// Duplicate method - public static AmdocsLicenseMembers createVendorLicense(User user) throws Exception { - - AmdocsLicenseMembers amdocsLicenseMembers; -// ComponentBaseTest.getExtendTest().log(Status.INFO, "Starting to create the vendor license"); - String vendorLicenseName = "ciLicense" + OnboardingUtils.getShortUUID(); - RestResponse vendorLicenseResponse = OnboardingUtils.createVendorLicenseModels_1(vendorLicenseName, user); - assertEquals("did not succeed to create vendor license model", 200, vendorLicenseResponse.getErrorCode().intValue()); - String vendorId = ResponseParser.getValueFromJsonResponse(vendorLicenseResponse.getResponse(), "value"); - - RestResponse vendorKeyGroupsResponse = OnboardingUtils.createVendorKeyGroups_2(vendorId, user); - assertEquals("did not succeed to create vendor key groups", 200, vendorKeyGroupsResponse.getErrorCode().intValue()); - String keyGroupId = ResponseParser.getValueFromJsonResponse(vendorKeyGroupsResponse.getResponse(), "value"); - - RestResponse vendorEntitlementPool = OnboardingUtils.createVendorEntitlementPool_3(vendorId, user); - assertEquals("did not succeed to create vendor entitlement pool", 200, vendorEntitlementPool.getErrorCode().intValue()); - String entitlementPoolId = ResponseParser.getValueFromJsonResponse(vendorEntitlementPool.getResponse(), "value"); - - RestResponse vendorLicenseFeatureGroups = OnboardingUtils.createVendorLicenseFeatureGroups_4(vendorId, keyGroupId, entitlementPoolId, user); - assertEquals("did not succeed to create vendor license feature groups", 200, vendorLicenseFeatureGroups.getErrorCode().intValue()); - String featureGroupId = ResponseParser.getValueFromJsonResponse(vendorLicenseFeatureGroups.getResponse(), "value"); - - RestResponse vendorLicenseAgreement = OnboardingUtils.createVendorLicenseAgreement_5(vendorId, featureGroupId, user); - assertEquals("did not succeed to create vendor license agreement", 200, vendorLicenseAgreement.getErrorCode().intValue()); - String vendorLicenseAgreementId = ResponseParser.getValueFromJsonResponse(vendorLicenseAgreement.getResponse(), "value"); - - RestResponse checkinVendorLicense = OnboardingUtils.checkinVendorLicense(vendorId, user, "0.1"); - assertEquals("did not succeed to checkin vendor license", 200, checkinVendorLicense.getErrorCode().intValue()); - - RestResponse submitVendorLicense = OnboardingUtils.submitVendorLicense(vendorId, user, "0.1"); - assertEquals("did not succeed to submit vendor license", 200, submitVendorLicense.getErrorCode().intValue()); - -// ComponentBaseTest.getExtendTest().log(Status.INFO, "Succeeded in creating the vendor license"); - - amdocsLicenseMembers = new AmdocsLicenseMembers(vendorId, vendorLicenseName, vendorLicenseAgreementId, featureGroupId); - amdocsLicenseMembers.setVersion("1.0"); // Once object created and submitted, his initial version is 1.0 - - return amdocsLicenseMembers; - } public static String getShortUUID() { return UUID.randomUUID().toString().split("-")[0]; } - private static RestResponse actionOnComponent(String vspid, String action, String onboardComponent, User user, String componentVersion) - throws Exception { + private static RestResponse actionOnComponent(String vspid, String body, String onboardComponent, User user, String componentVersion) throws Exception { Config config = Utils.getConfig(); String url = String.format(Urls.ACTION_ON_COMPONENT, config.getCatalogBeHost(), config.getCatalogBePort(), onboardComponent, vspid, componentVersion); String userId = user.getUserId(); - - JSONObject jObject = new JSONObject(); - jObject.put("action", action); - - Map headersMap = prepareHeadersMap(userId); - - HttpRequest http = new HttpRequest(); - RestResponse response = http.httpSendPut(url, jObject.toString(), headersMap); - return response; - } - - - public static RestResponse checkinVendorLicense(String vspid, User user, String vlmVersion) throws Exception { - return actionOnComponent(vspid, "Checkin", "vendor-license-models", user, vlmVersion); - } - - public static RestResponse checkoutVendorLicense(String vspid, User user, String vlmVersion) throws Exception { - return actionOnComponent(vspid, "Checkout", "vendor-license-models", user, vlmVersion); - } - - public static RestResponse submitVendorLicense(String vspid, User user, String vlmVersion) throws Exception { - return actionOnComponent(vspid, "Submit", "vendor-license-models", user, vlmVersion); - } - - public static RestResponse createVendorLicenseModels_1(String name, User user) throws Exception { - Config config = Utils.getConfig(); - String url = String.format(Urls.CREATE_VENDOR_LISENCE_MODELS, config.getCatalogBeHost(), - config.getCatalogBePort()); - String userId = user.getUserId(); - - JSONObject jObject = new JSONObject(); - jObject.put("vendorName", name); - jObject.put("description", "new vendor license model"); - jObject.put("iconRef", "icon"); - - Map headersMap = prepareHeadersMap(userId); - - HttpRequest http = new HttpRequest(); - RestResponse response = http.httpSendPost(url, jObject.toString(), headersMap); - return response; - - } - - public static RestResponse createVendorLicenseAgreement_5(String vspid, String featureGroupId, User user) - throws Exception { - Config config = Utils.getConfig(); - String url = String.format(Urls.CREATE_VENDOR_LISENCE_AGREEMENT, config.getCatalogBeHost(), config.getCatalogBePort(), vspid); - String userId = user.getUserId(); - - JSONObject licenseTermpObject = new JSONObject(); - licenseTermpObject.put("choice", "Fixed_Term"); - licenseTermpObject.put("other", ""); - - JSONObject jObjectBody = new JSONObject(); - jObjectBody.put("name", "abc"); - jObjectBody.put("description", "new vendor license agreement"); - jObjectBody.put("requirementsAndConstrains", "abc"); - jObjectBody.put("licenseTerm", licenseTermpObject); - jObjectBody.put("addedFeatureGroupsIds", Arrays.asList(featureGroupId).toArray()); - - Map headersMap = prepareHeadersMap(userId); - - HttpRequest http = new HttpRequest(); - RestResponse response = http.httpSendPost(url, jObjectBody.toString(), headersMap); - return response; - } - - public static RestResponse createVendorLicenseFeatureGroups_4(String vspid, String licenseKeyGroupId, - String entitlementPoolId, User user) throws Exception { - Config config = Utils.getConfig(); - String url = String.format(Urls.CREATE_VENDOR_LISENCE_FEATURE_GROUPS, config.getCatalogBeHost(), config.getCatalogBePort(), vspid); - String userId = user.getUserId(); - - JSONObject jObject = new JSONObject(); - jObject.put("name", "xyz"); - jObject.put("description", "new vendor license feature groups"); - jObject.put("partNumber", "123abc456"); - jObject.put("manufacturerReferenceNumber", "5"); - jObject.put("addedLicenseKeyGroupsIds", Arrays.asList(licenseKeyGroupId).toArray()); - jObject.put("addedEntitlementPoolsIds", Arrays.asList(entitlementPoolId).toArray()); - - Map headersMap = prepareHeadersMap(userId); - - HttpRequest http = new HttpRequest(); - RestResponse response = http.httpSendPost(url, jObject.toString(), headersMap); - return response; - - } - - public static RestResponse createVendorEntitlementPool_3(String vspid, User user) throws Exception { - Config config = Utils.getConfig(); - String url = String.format(Urls.CREATE_VENDOR_LISENCE_ENTITLEMENT_POOL, config.getCatalogBeHost(), config.getCatalogBePort(), vspid); - String userId = user.getUserId(); - - JSONObject jEntitlementMetricObject = new JSONObject(); - jEntitlementMetricObject.put("choice", "CPU"); - jEntitlementMetricObject.put("other", ""); - - JSONObject jAggregationFunctionObject = new JSONObject(); - jAggregationFunctionObject.put("choice", "Peak"); - jAggregationFunctionObject.put("other", ""); - - JSONObject jOperationalScope = new JSONObject(); - jOperationalScope.put("choices", Arrays.asList("Availability_Zone").toArray()); - jOperationalScope.put("other", ""); - - JSONObject jTimeObject = new JSONObject(); - jTimeObject.put("choice", "Hour"); - jTimeObject.put("other", ""); - - JSONObject jObjectBody = new JSONObject(); - jObjectBody.put("name", "def"+ getShortUUID()); - jObjectBody.put("description", "new vendor license entitlement pool"); - jObjectBody.put("thresholdValue", "23"); - jObjectBody.put("thresholdUnits", "Absolute"); - jObjectBody.put("entitlementMetric", jEntitlementMetricObject); - jObjectBody.put("increments", "abcd"); - jObjectBody.put("aggregationFunction", jAggregationFunctionObject); - jObjectBody.put("operationalScope", jOperationalScope); - jObjectBody.put("time", jTimeObject); - jObjectBody.put("manufacturerReferenceNumber", "123aaa"); - - Map headersMap = prepareHeadersMap(userId); - - HttpRequest http = new HttpRequest(); - RestResponse response = http.httpSendPost(url, jObjectBody.toString(), headersMap); - return response; - } - - public static RestResponse createVendorKeyGroups_2(String vspid, User user) throws Exception { - Config config = Utils.getConfig(); - String url = String.format(Urls.CREATE_VENDOR_LISENCE_KEY_GROUPS, config.getCatalogBeHost(), config.getCatalogBePort(), vspid); - String userId = user.getUserId(); - - JSONObject jOperationalScope = new JSONObject(); - jOperationalScope.put("choices", Arrays.asList("Tenant").toArray()); - jOperationalScope.put("other", ""); - - JSONObject jObjectBody = new JSONObject(); - jObjectBody.put("name", "keyGroup" + getShortUUID()); - jObjectBody.put("description", "new vendor license key group"); - jObjectBody.put("operationalScope", jOperationalScope); - jObjectBody.put("type", "Universal"); - Map headersMap = prepareHeadersMap(userId); HttpRequest http = new HttpRequest(); - RestResponse response = http.httpSendPost(url, jObjectBody.toString(), headersMap); - return response; - } - - public static Pair> createNewVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String vspName, AmdocsLicenseMembers amdocsLicenseMembers, User user) throws Exception { - Map vspMetadta = new HashMap(); - - Config config = Utils.getConfig(); - String url = String.format(Urls.CREATE_VENDOR_SOFTWARE_PRODUCT, config.getCatalogBeHost(), config.getCatalogBePort()); - String userId = user.getUserId(); - VendorSoftwareProductObject vendorSoftwareProductObject = new VendorSoftwareProductObject(); - LicensingData licensingData = new LicensingData(amdocsLicenseMembers.getVendorLicenseAgreementId(), Arrays.asList(amdocsLicenseMembers.getFeatureGroupId())); - LicensingVersion licensingVersion = new LicensingVersion("1.0", "1.0"); - ResourceCategoryEnum resourceCategoryEnum = ResourceCategoryEnum.findEnumNameByValues(resourceReqDetails.getCategories().get(0).getName(), resourceReqDetails.getCategories().get(0).getSubcategories().get(0).getName()); - - vendorSoftwareProductObject.setLicensingVersion(licensingVersion); - - vendorSoftwareProductObject.setName(vspName); - vendorSoftwareProductObject.setDescription(resourceReqDetails.getDescription()); - vendorSoftwareProductObject.setCategory(resourceCategoryEnum.getCategoryUniqeId()); - vendorSoftwareProductObject.setSubCategory(resourceCategoryEnum.getSubCategoryUniqeId()); - vendorSoftwareProductObject.setOnboardingMethod("NetworkPackage"); - vendorSoftwareProductObject.setVendorName(amdocsLicenseMembers.getVendorLicenseName()); - vendorSoftwareProductObject.setVendorId(amdocsLicenseMembers.getVendorId()); - vendorSoftwareProductObject.setIcon("icon"); - vendorSoftwareProductObject.setLicensingData(licensingData); - - vspMetadta.put("description", resourceReqDetails.getDescription()); - vspMetadta.put("category", resourceCategoryEnum.getCategory()); - vspMetadta.put("subCategory", resourceCategoryEnum.getSubCategory()); - - Map headersMap = prepareHeadersMap(userId); - HttpRequest http = new HttpRequest(); - Gson gson = new Gson(); - String body = gson.toJson(vendorSoftwareProductObject); - - RestResponse response = http.httpSendPost(url, body, headersMap); - return new Pair>(response, vspMetadta); - } - - public static RestResponse validateUpload(String vspid, User user, String vspVersion) throws Exception { - Config config = Utils.getConfig(); - String url = String.format(Urls.VALIDATE_UPLOAD, config.getCatalogBeHost(), config.getCatalogBePort(), vspid,vspVersion); - - String userId = user.getUserId(); - - Map headersMap = prepareHeadersMap(userId); - HttpRequest http = new HttpRequest(); - - String body =null; - RestResponse response = http.httpSendPut(url, body, headersMap); - return response; } - public static RestResponse uploadHeatPackage(String filepath, String filename, String vspid, User user, String vspVersion) throws Exception { - Config config = Utils.getConfig(); - String url = String.format(Urls.UPLOAD_HEAT_PACKAGE, config.getCatalogBeHost(), config.getCatalogBePort(), vspid, vspVersion); - return uploadFile(filepath, filename, url, user); - } - - private static RestResponse uploadFile(String filepath, String filename, String url, User user) - throws FileNotFoundException, IOException, ClientProtocolException { - CloseableHttpResponse response = null; - - MultipartEntityBuilder mpBuilder = MultipartEntityBuilder.create(); - mpBuilder.addPart("upload", new FileBody(getTestZipFile(filepath, filename))); - - Map headersMap = prepareHeadersMap(user.getUserId()); - headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "multipart/form-data"); - - CloseableHttpClient client = HttpClients.createDefault(); - try { - HttpPost httpPost = new HttpPost(url); - RestResponse restResponse = new RestResponse(); - - Iterator iterator = headersMap.keySet().iterator(); - while (iterator.hasNext()) { - String key = iterator.next(); - String value = headersMap.get(key); - httpPost.addHeader(key, value); - } - httpPost.setEntity(mpBuilder.build()); - response = client.execute(httpPost); - HttpEntity entity = response.getEntity(); - String responseBody = null; - if (entity != null) { - InputStream instream = entity.getContent(); - try { - StringWriter writer = new StringWriter(); - IOUtils.copy(instream, writer); - responseBody = writer.toString(); - } finally { - instream.close(); - } - } - - restResponse.setErrorCode(response.getStatusLine().getStatusCode()); - restResponse.setResponse(responseBody); - - return restResponse; - - } finally { - closeResponse(response); - closeHttpClient(client); - - } - } - - private static void closeResponse(CloseableHttpResponse response) { - try { - if (response != null) { - response.close(); - } - } catch (IOException e) { - System.out.println(String.format("failed to close client or response: %s", e.getMessage())); - } - } - - private static void closeHttpClient(CloseableHttpClient client) { - try { - if (client != null) { - client.close(); - } - } catch (IOException e) { - System.out.println(String.format("failed to close client or response: %s", e.getMessage())); - } - } - -// private static File getTestZipFile(String filepath, String filename) throws IOException { -// Config config = Utils.getConfig(); -// String sourceDir = config.getImportResourceTestsConfigDir(); -// java.nio.file.Path filePath = FileSystems.getDefault().getPath(filepath + File.separator + filename); -// return filePath.toFile(); -// } - - private static File getTestZipFile(String filepath, String filename) throws IOException { - Config config = Utils.getConfig(); - String sourceDir = config.getImportResourceTestsConfigDir(); - java.nio.file.Path filePath; - if(filename == null){ - filePath = FileSystems.getDefault().getPath(filepath); - }else{ - filePath = FileSystems.getDefault().getPath(filepath + File.separator + filename); - } - return filePath.toFile(); - } - - public static RestResponse checkinVendorSoftwareProduct(String vspid, User user, String vspVersion) throws Exception { - return actionOnComponent(vspid, "Checkin", "vendor-software-products", user, vspVersion); - } - - public static RestResponse checkoutVendorSoftwareProduct(String vspid, User user, String vspVersion) throws Exception { - return actionOnComponent(vspid, "Checkout", "vendor-software-products", user, vspVersion); - } - - public static RestResponse submitVendorSoftwareProduct(String vspid, User user, String vspVersion) throws Exception { - return actionOnComponent(vspid, "Submit", "vendor-software-products", user, vspVersion); - } - - public static RestResponse createPackageOfVendorSoftwareProduct(String vspid, User user, String vspVersion) throws Exception { - return actionOnComponent(vspid, "Create_Package", "vendor-software-products", user, vspVersion); - } - protected static Map prepareHeadersMap(String userId) { Map headersMap = new HashMap(); headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json"); @@ -799,193 +153,7 @@ public class OnboardingUtils { return headersMap; } - public static VendorSoftwareProductObject updateVSPWithNewVLMParameters(VendorSoftwareProductObject vendorSoftwareProductObject, - AmdocsLicenseMembers amdocsLicenseMembers, User user, String vspCurrentVersion, String vspNextVersion) throws Exception { - - LicensingVersion licensingVersion = new LicensingVersion(amdocsLicenseMembers.getLicenseVersionId(),amdocsLicenseMembers.getLicenseVersionId()); - LicensingData licensingData = new LicensingData(amdocsLicenseMembers.getVendorLicenseAgreementId(), Arrays.asList(amdocsLicenseMembers.getFeatureGroupId())); - vendorSoftwareProductObject.setVendorId(amdocsLicenseMembers.getVendorId()); - vendorSoftwareProductObject.setVendorName(amdocsLicenseMembers.getVendorLicenseName()); - vendorSoftwareProductObject.setLicensingVersion(licensingVersion); - vendorSoftwareProductObject.setLicensingData(licensingData); - - VendorSoftwareProductObjectReqDetails vendorSoftwareProductObjectReqDetails = new VendorSoftwareProductObjectReqDetails( - vendorSoftwareProductObject.getName(), - vendorSoftwareProductObject.getDescription(), - vendorSoftwareProductObject.getCategory(), - vendorSoftwareProductObject.getSubCategory(), - vendorSoftwareProductObject.getVendorId(), - vendorSoftwareProductObject.getVendorName(), - licensingVersion, - licensingData, - vendorSoftwareProductObject.getOnboardingMethod(), - vendorSoftwareProductObject.getNetworkPackageName(), - vendorSoftwareProductObject.getOnboardingOrigin()); - - Gson gson = new Gson(); - String json = gson.toJson(vendorSoftwareProductObjectReqDetails); - - RestResponse checkout = checkoutVendorSoftwareProduct(vendorSoftwareProductObject.getVspId(), user, "1.0"); - assertEquals("did not succeed to checkout new VSP", 200, checkout.getErrorCode().intValue()); - - Config config = Utils.getConfig(); - String url = String.format(Urls.UPDATE_VSP, config.getCatalogBeHost(), config.getCatalogBePort(), vendorSoftwareProductObject.getVspId(), vspCurrentVersion); - String userId = user.getUserId(); - - Map headersMap = prepareHeadersMap(userId); - HttpRequest http = new HttpRequest(); - - RestResponse response = http.httpSendPut(url, json, headersMap); - - RestResponse checkin = checkinVendorSoftwareProduct(vendorSoftwareProductObject.getVspId(), user, vspCurrentVersion); - assertEquals("did not succeed to checking VSP", 200, checkin.getErrorCode().intValue()); - - RestResponse submit = submitVendorSoftwareProduct(vendorSoftwareProductObject.getVspId(), user, vspCurrentVersion); - assertEquals("did not succeed to submit VSP", 200, submit.getErrorCode().intValue()); - - vendorSoftwareProductObject.setVersion(vspNextVersion); - - return vendorSoftwareProductObject; - } - -// private static void importUpdateVSP(Pair> vsp, boolean isUpdate) throws Exception{ -// String vspName = vsp.left; -// Map vspMetadata = vsp.right; -// boolean vspFound = HomePage.searchForVSP(vspName); -// -// if (vspFound){ -// -// List elemenetsFromTable = HomePage.getElemenetsFromTable(); -//// WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), 30); -//// WebElement findElement = wait.until(ExpectedConditions.visibilityOf(elemenetsFromTable.get(1))); -//// findElement.click(); -// elemenetsFromTable.get(1).click(); -// GeneralUIUtils.waitForLoader(); -// -// if (isUpdate){ -// GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ImportVfRepository.UPDATE_VSP.getValue()); -// -// } -// else{ -// GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ImportVfRepository.IMPORT_VSP.getValue()); -// } -// -// String lifeCycleState = ResourceGeneralPage.getLifeCycleState(); -// boolean needCheckout = lifeCycleState.equals(LifeCycleStateEnum.CHECKIN.getValue()) || lifeCycleState.equals(LifeCycleStateEnum.CERTIFIED.getValue()); -// if (needCheckout) -// { -// try { -// ResourceGeneralPage.clickCheckoutButton(); -// Assert.assertTrue(ResourceGeneralPage.getLifeCycleState().equals(LifeCycleStateEnum.CHECKOUT.getValue()), "Did not succeed to checkout"); -// -// } catch (Exception e) { -// ExtentTestActions.log(Status.ERROR, "Did not succeed to checkout"); -// e.printStackTrace(); -// } -// GeneralUIUtils.waitForLoader(); -// } -// -// //Metadata verification -// VfVerificator.verifyOnboardedVnfMetadata(vspName, vspMetadata); -// -// ExtentTestActions.log(Status.INFO, "Clicking create/update VNF"); -// String duration = GeneralUIUtils.getActionDuration(() -> waitUntilVnfCreated()); -// ExtentTestActions.log(Status.INFO, "Succeeded in importing/updating " + vspName, duration); -// } -// else{ -// Assert.fail("Did not find VSP named " + vspName); -// } -// } -// private static void waitUntilVnfCreated() { -// GeneralUIUtils.clickOnElementByTestIdWithoutWait(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue()); -// GeneralUIUtils.waitForLoader(60*10); -// GeneralUIUtils.waitForAngular(); -// GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.CHECKIN_BUTTON.getValue()); -// } -// -// public static void updateVSP(Pair> vsp) throws Exception{ -// ExtentTestActions.log(Status.INFO, "Updating VSP " + vsp.left); -// importUpdateVSP(vsp, true); -// } -// -// public static void importVSP(Pair> vsp) throws Exception{ -// ExtentTestActions.log(Status.INFO, "Importing VSP " + vsp.left); -// importUpdateVSP(vsp, false); -// } -// -// public static void updateVnfAndValidate(String filepath, Pair> vsp, String updatedVnfFile, User user) throws Exception, Throwable { -// ExtentTestActions.log(Status.INFO, String.format("Going to update the VNF with %s......", updatedVnfFile)); -// System.out.println(String.format("Going to update the VNF with %s......", updatedVnfFile)); -// -// Map vspMap = vsp.right; -// String vspId = vspMap.get("vspId"); -// -// updateVendorSoftwareProduct(vspId, updatedVnfFile, filepath, user); -// HomePage.showVspRepository(); -// updateVSP(vsp); -// ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); -// DeploymentArtifactPage.verifyArtifactsExistInTable(filepath, updatedVnfFile); -// } -// -// public static Pair> onboardAndValidate(String filepath, String vnfFile, User user) throws Exception { -// ExtentTestActions.log(Status.INFO, String.format("Going to onboard the VNF %s", vnfFile)); -// System.out.println(String.format("Going to onboard the VNF %s", vnfFile)); -// -// AmdocsLicenseMembers amdocsLicenseMembers = createVendorLicense(user); -// Pair> createVendorSoftwareProduct = createVendorSoftwareProduct(vnfFile, filepath, user, amdocsLicenseMembers); -// String vspName = createVendorSoftwareProduct.left; -// -// DownloadManager.downloadCsarByNameFromVSPRepository(vspName, createVendorSoftwareProduct.right.get("vspId")); -// File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(); -// -// ExtentTestActions.log(Status.INFO, String.format("Searching for onboarded %s", vnfFile)); -// HomePage.showVspRepository(); -// ExtentTestActions.log(Status.INFO,String.format("Going to import %s", vnfFile.substring(0, vnfFile.indexOf(".")))); -// importVSP(createVendorSoftwareProduct); -// -// ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); -// -// // Verify deployment artifacts -// Map combinedMap = ArtifactFromCsar.combineHeatArtifacstWithFolderArtifacsToMap(latestFilefromDir.getAbsolutePath()); -// -// LinkedList deploymentArtifacts = ((LinkedList) combinedMap.get("Deployment")); -// ArtifactsCorrelationManager.addVNFartifactDetails(vspName, deploymentArtifacts); -// -// List heatEnvFilesFromCSAR = deploymentArtifacts.stream().filter(e -> e.getType().equals("HEAT_ENV")). -// map(e -> e.getFileName()). -// collect(Collectors.toList()); -// -// validateDeploymentArtifactsVersion(deploymentArtifacts, heatEnvFilesFromCSAR); -// -// DeploymentArtifactPage.verifyArtifactsExistInTable(filepath, vnfFile); -// return createVendorSoftwareProduct; -// } -// -// public static void validateDeploymentArtifactsVersion(LinkedList deploymentArtifacts, -// List heatEnvFilesFromCSAR) { -// String artifactVersion; -// String artifactName; -// -// for(HeatMetaFirstLevelDefinition deploymentArtifact: deploymentArtifacts) { -// artifactVersion = "1"; -// -// if(deploymentArtifact.getType().equals("HEAT_ENV")) { -// continue; -// } else if(deploymentArtifact.getFileName().contains(".")) { -// artifactName = deploymentArtifact.getFileName().trim().substring(0, deploymentArtifact.getFileName().lastIndexOf(".")); -// } else { -// artifactName = deploymentArtifact.getFileName().trim(); -// } -// -// if (heatEnvFilesFromCSAR.contains(artifactName + ".env")){ -// artifactVersion = "2"; -// } -// ArtifactUIUtils.validateArtifactNameVersionType(artifactName, artifactVersion, deploymentArtifact.getType()); -// } -// } - - /** * @return * The method returns VNF names list from Files directory under sdc-vnfs repository @@ -993,10 +161,29 @@ public class OnboardingUtils { public static List getVnfNamesFileList() { String filepath = FileHandling.getVnfRepositoryPath(); List fileNamesFromFolder = FileHandling.getZipFileNamesFromFolder(filepath); + //Please remove the hardcoded configuration ONAP Tal G!!!!!! fileNamesFromFolder.removeAll(exludeVnfList); + //List halfResourceListByDay = divideListByDayOfMonth(fileNamesFromFolder); + //System.out.println(halfResourceListByDay.toString()); return fileNamesFromFolder; } + /** + * @param vnfNamesFileList + * @return divide List according to day of month, if day of month is even as get first half part of the List, else - second + */ + public static List divideListByDayOfMonth(List vnfNamesFileList){ + + Calendar cal = Calendar.getInstance(); + int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH)+1; + int filesCount = vnfNamesFileList.size(); + if(dayOfMonth%2 == 0){ + return vnfNamesFileList.subList(0,filesCount/2); + }else{ + return vnfNamesFileList.subList(filesCount/2, filesCount); + } + } + /** * @return * The method returns VNF names list from Files directory under sdc-vnfs repository excluding zip files that known as failed in tosca parser @@ -1007,41 +194,6 @@ public class OnboardingUtils { return fileNamesFromFolder; } - public static VendorSoftwareProductObject fillVendorSoftwareProductObjectWithMetaData(String vnfFile, Pair> createVendorSoftwareProduct) { - VendorSoftwareProductObject vendorSoftwareProductObject = new VendorSoftwareProductObject(); - Map map = createVendorSoftwareProduct.right; - vendorSoftwareProductObject.setAttContact(map.get("attContact")); - vendorSoftwareProductObject.setCategory(map.get("category")); - vendorSoftwareProductObject.setComponentId(map.get("componentId")); - vendorSoftwareProductObject.setDescription(map.get("description")); - vendorSoftwareProductObject.setSubCategory(map.get("subCategory")); - vendorSoftwareProductObject.setVendorName(map.get("vendorName")); - vendorSoftwareProductObject.setVspId(map.get("vspId")); - vendorSoftwareProductObject.setName(createVendorSoftwareProduct.left); - String[] arrFileNameAndExtension = vnfFile.split("\\."); - vendorSoftwareProductObject.setOnboardingMethod("NetworkPackage"); - vendorSoftwareProductObject.setNetworkPackageName(arrFileNameAndExtension[0]); - vendorSoftwareProductObject.setOnboardingOrigin(arrFileNameAndExtension[1]); - - return vendorSoftwareProductObject; - } - - public static void updateVendorSoftwareProductToNextVersion(VendorSoftwareProductObject vendorSoftwareProductObject, String toVspVersion, User user, String filepath, String heatFileName) - throws Exception, Throwable { - - RestResponse checkout = checkoutVendorSoftwareProduct(vendorSoftwareProductObject.getVspId(), user, vendorSoftwareProductObject.getVersion()); - assertEquals("did not succeed to checkout new VSP", 200, checkout.getErrorCode().intValue()); - - RestResponse uploadHeatPackage = uploadHeatPackage(filepath, heatFileName, vendorSoftwareProductObject.getVspId(), user, "1.1"); - assertEquals("did not succeed to upload HEAT package", 200, uploadHeatPackage.getErrorCode().intValue()); - - RestResponse validateUpload = validateUpload(vendorSoftwareProductObject.getVspId(), user, "1.1"); - assertEquals("did not succeed to validate upload process, reason: " + validateUpload.getResponse(), 200, validateUpload.getErrorCode().intValue()); - - prepareVspForUse(user,vendorSoftwareProductObject.getVspId(),toVspVersion); - - vendorSoftwareProductObject.setVersion(toVspVersion); - } public static Object[][] filterObjectArrWithExcludedVnfs(Object[][] objectArr) { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/SnmpTypeEnum.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/SnmpTypeEnum.java index 366962ef0a..71038920ae 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/SnmpTypeEnum.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/SnmpTypeEnum.java @@ -20,6 +20,56 @@ package org.openecomp.sdc.ci.tests.utils.general; +import static org.testng.AssertJUnit.assertEquals; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.StringWriter; +import java.nio.file.FileSystems; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.stream.Collectors; + +import org.apache.commons.io.IOUtils; +import org.apache.http.HttpEntity; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.entity.mime.content.FileBody; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.json.JSONException; +import org.json.JSONObject; +import org.json.simple.JSONArray; +import org.json.simple.JSONValue; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.ci.tests.config.Config; +import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers; + +import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition; + +import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum; +import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest; +import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; +import org.openecomp.sdc.ci.tests.execute.devCI.ArtifactFromCsar; + + +import org.openecomp.sdc.ci.tests.utils.Utils; +import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; + +import org.testng.Assert; + +import com.aventstack.extentreports.Status; +import com.clearspring.analytics.util.Pair; + enum SnmpTypeEnum{ SNMP_POLL ("snmp"), SNMP_TRAP ("snmp-trap"); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/VendorLicenseModelRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/VendorLicenseModelRestUtils.java new file mode 100644 index 0000000000..ec368df621 --- /dev/null +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/VendorLicenseModelRestUtils.java @@ -0,0 +1,285 @@ +package org.openecomp.sdc.ci.tests.utils.general; + +import com.aventstack.extentreports.Status; +import org.json.JSONObject; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; +import org.openecomp.sdc.ci.tests.api.Urls; +import org.openecomp.sdc.ci.tests.config.Config; +import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers; +import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest; +import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; +import org.openecomp.sdc.ci.tests.utils.Utils; +import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; + +import java.util.Arrays; +import java.util.Map; + +import static org.testng.AssertJUnit.assertEquals; + +public class VendorLicenseModelRestUtils { + + public static void updateVendorLicense(AmdocsLicenseMembers amdocsLicenseMembers, User user, Boolean isVlmUpdated) throws Exception { + +// create major method + RestResponse creationMethodVendorLicense = creationMethodVendorLicense(amdocsLicenseMembers, user); + assertEquals("did not succeed to create method for vendor license", 200, creationMethodVendorLicense.getErrorCode().intValue()); + amdocsLicenseMembers.setVersion(ResponseParser.getValueFromJsonResponse(creationMethodVendorLicense.getResponse(), "id")); + + if(isVlmUpdated) { +// TODO update vlm do nothing +// commit + RestResponse commitVendorLicense = commitVendorLicense(amdocsLicenseMembers, user); + assertEquals("did not succeed to commit vendor license", 200, commitVendorLicense.getErrorCode().intValue()); + } + +// submit + RestResponse submitVendorLicense = submitVendorLicense(amdocsLicenseMembers, user); + assertEquals("did not succeed to submit vendor license", 200, submitVendorLicense.getErrorCode().intValue()); + + if(ComponentBaseTest.getExtendTest() != null){ + ComponentBaseTest.getExtendTest().log(Status.INFO, "Succeeded in updating the vendor license"); + } + } + + private static RestResponse getVLMComponentByVersion(String vlmId, String vlmVersion, User user) throws Exception{ + Config config = Utils.getConfig(); + String url = String.format(Urls.GET_VLM_COMPONENT_BY_VERSION, config.getCatalogBeHost(),config.getCatalogBePort(), vlmId,vlmVersion); + String userId = user.getUserId(); + + Map headersMap = OnboardingUtils.prepareHeadersMap(userId); + + HttpRequest http = new HttpRequest(); + RestResponse response = http.httpSendGet(url, headersMap); + return response; + } + + public static boolean validateVlmExist(String vlmId, String vlmVersion, User user) throws Exception { + RestResponse restResponse = getVLMComponentByVersion(vlmId, vlmVersion, user); + assertEquals(String.format("VLM version not updated, reponse code message: %s", restResponse.getResponse()),restResponse.getErrorCode().intValue(),200); + return (restResponse.getErrorCode()==200); + } + + public static AmdocsLicenseMembers createVendorLicense(User user) throws Exception { + + AmdocsLicenseMembers amdocsLicenseMembers; +// ComponentBaseTest.getExtendTest().log(Status.INFO, "Starting to create the vendor license"); + String vendorLicenseName = "ciLicense" + OnboardingUtils.getShortUUID(); + RestResponse vendorLicenseResponse = createVendorLicenseModels_1(vendorLicenseName, user); + assertEquals("did not succeed to create vendor license model", 200, vendorLicenseResponse.getErrorCode().intValue()); + String vendorId = ResponseParser.getValueFromJsonResponse(vendorLicenseResponse.getResponse(), "itemId"); + String versionId = ResponseParser.getValueFromJsonResponse(vendorLicenseResponse.getResponse(), "version:id"); + + RestResponse vendorKeyGroupsResponse = createVendorKeyGroups_2(vendorId, versionId, user); + assertEquals("did not succeed to create vendor key groups", 200, vendorKeyGroupsResponse.getErrorCode().intValue()); + String keyGroupId = ResponseParser.getValueFromJsonResponse(vendorKeyGroupsResponse.getResponse(), "value"); + + RestResponse vendorEntitlementPool = createVendorEntitlementPool_3(vendorId, versionId, user); + assertEquals("did not succeed to create vendor entitlement pool", 200, vendorEntitlementPool.getErrorCode().intValue()); + String entitlementPoolId = ResponseParser.getValueFromJsonResponse(vendorEntitlementPool.getResponse(), "value"); + + RestResponse vendorLicenseFeatureGroups = createVendorLicenseFeatureGroups_4(vendorId, versionId, keyGroupId, entitlementPoolId, user); + assertEquals("did not succeed to create vendor license feature groups", 200, vendorLicenseFeatureGroups.getErrorCode().intValue()); + String featureGroupId = ResponseParser.getValueFromJsonResponse(vendorLicenseFeatureGroups.getResponse(), "value"); + + RestResponse vendorLicenseAgreement = createVendorLicenseAgreement_5(vendorId, versionId, featureGroupId, user); + assertEquals("did not succeed to create vendor license agreement", 200, vendorLicenseAgreement.getErrorCode().intValue()); + String vendorLicenseAgreementId = ResponseParser.getValueFromJsonResponse(vendorLicenseAgreement.getResponse(), "value"); + +// RestResponse checkinVendorLicense = OnboardingUtils.checkinVendorLicense(vendorId, user, versionId); +// assertEquals("did not succeed to checkin vendor license", 200, checkinVendorLicense.getErrorCode().intValue()); + + amdocsLicenseMembers = new AmdocsLicenseMembers(vendorId, vendorLicenseName, vendorLicenseAgreementId, featureGroupId); + amdocsLicenseMembers.setVersion(versionId); // Once object created and submitted, his initial version is 1.0 + + RestResponse submitVendorLicense = submitVendorLicense(amdocsLicenseMembers, user); + assertEquals("did not succeed to submit vendor license", 200, submitVendorLicense.getErrorCode().intValue()); + +// ComponentBaseTest.getExtendTest().log(Status.INFO, "Succeeded in creating the vendor license"); + + return amdocsLicenseMembers; + } + + private static RestResponse actionOnComponent(String vspid, String body, String onboardComponent, User user, String componentVersion) throws Exception { + Config config = Utils.getConfig(); + String url = String.format(Urls.ACTION_ON_COMPONENT, config.getCatalogBeHost(), config.getCatalogBePort(), onboardComponent, vspid, componentVersion); + String userId = user.getUserId(); + Map headersMap = OnboardingUtils.prepareHeadersMap(userId); + + HttpRequest http = new HttpRequest(); + RestResponse response = http.httpSendPut(url, body, headersMap); + return response; + } + + private static RestResponse createMethodVendorLicense(String vendorId, String body, String onboardComponent, User user, String componentVersion) throws Exception { + Config config = Utils.getConfig(); + String url = String.format(Urls.CREATE_METHOD, config.getCatalogBeHost(), config.getCatalogBePort(), onboardComponent, vendorId, componentVersion); + String userId = user.getUserId(); + Map headersMap = OnboardingUtils.prepareHeadersMap(userId); + + HttpRequest http = new HttpRequest(); + RestResponse response = http.httpSendPost(url, body, headersMap); + return response; + } + + public static RestResponse submitVendorLicense(AmdocsLicenseMembers amdocsLicenseMembers, User user) throws Exception { + return actionOnComponent(amdocsLicenseMembers.getVendorId(), "{\"action\":\"Submit\"}", "vendor-license-models", user, amdocsLicenseMembers.getVersion()); + } + + /** + * @param amdocsLicenseMembers + * @param user + * @return + * checkOut exist VLM method + * @throws Exception + */ + public static RestResponse creationMethodVendorLicense(AmdocsLicenseMembers amdocsLicenseMembers, User user) throws Exception { + String messageBody = "{\"description\":\"2.0\",\"creationMethod\":\"major\"}"; + return createMethodVendorLicense(amdocsLicenseMembers.getVendorId(), messageBody, "items", user, amdocsLicenseMembers.getVersion()); + } + + public static RestResponse commitVendorLicense(AmdocsLicenseMembers amdocsLicenseMembers, User user) throws Exception { + String messageBody = "{\"action\":\"Commit\",\"commitRequest\":{\"message\":\"commit\"}}"; + return actionOnComponent(amdocsLicenseMembers.getVendorId(), messageBody, "items", user, amdocsLicenseMembers.getVersion()); + } + + public static RestResponse createVendorLicenseModels_1(String name, User user) throws Exception { + Config config = Utils.getConfig(); + String url = String.format(Urls.CREATE_VENDOR_LISENCE_MODELS, config.getCatalogBeHost(), config.getCatalogBePort()); + String userId = user.getUserId(); + + JSONObject jObject = new JSONObject(); + jObject.put("vendorName", name); + jObject.put("description", "new vendor license model"); + jObject.put("iconRef", "icon"); + + Map headersMap = OnboardingUtils.prepareHeadersMap(userId); + + HttpRequest http = new HttpRequest(); + RestResponse response = http.httpSendPost(url, jObject.toString(), headersMap); + return response; + + } + + public static RestResponse createVendorLicenseAgreement_5(String vspid, String versionId, String featureGroupId, User user) + throws Exception { + Config config = Utils.getConfig(); + String url = String.format(Urls.CREATE_VENDOR_LISENCE_AGREEMENT, config.getCatalogBeHost(), config.getCatalogBePort(), vspid, versionId); + String userId = user.getUserId(); + + JSONObject licenseTermpObject = new JSONObject(); + licenseTermpObject.put("choice", "Fixed_Term"); + licenseTermpObject.put("other", ""); + + JSONObject jObjectBody = new JSONObject(); + jObjectBody.put("name", "abc"); + jObjectBody.put("description", "new vendor license agreement"); + jObjectBody.put("requirementsAndConstrains", "abc"); + jObjectBody.put("licenseTerm", licenseTermpObject); + jObjectBody.put("addedFeatureGroupsIds", Arrays.asList(featureGroupId).toArray()); + + Map headersMap = OnboardingUtils.prepareHeadersMap(userId); + + HttpRequest http = new HttpRequest(); + RestResponse response = http.httpSendPost(url, jObjectBody.toString(), headersMap); + return response; + } + + public static RestResponse createVendorLicenseFeatureGroups_4(String vspid, String versionId, String licenseKeyGroupId, + String entitlementPoolId, User user) throws Exception { + Config config = Utils.getConfig(); + String url = String.format(Urls.CREATE_VENDOR_LISENCE_FEATURE_GROUPS, config.getCatalogBeHost(), config.getCatalogBePort(), vspid, versionId); + String userId = user.getUserId(); + + JSONObject jObject = new JSONObject(); + jObject.put("name", "xyz"); + jObject.put("description", "new vendor license feature groups"); + jObject.put("partNumber", "123abc456"); + jObject.put("manufacturerReferenceNumber", "5"); + jObject.put("addedLicenseKeyGroupsIds", Arrays.asList(licenseKeyGroupId).toArray()); + jObject.put("addedEntitlementPoolsIds", Arrays.asList(entitlementPoolId).toArray()); + + Map headersMap = OnboardingUtils.prepareHeadersMap(userId); + + HttpRequest http = new HttpRequest(); + RestResponse response = http.httpSendPost(url, jObject.toString(), headersMap); + return response; + + } + + public static RestResponse createVendorEntitlementPool_3(String vspid, String versionId, User user) throws Exception { + Config config = Utils.getConfig(); + String url = String.format(Urls.CREATE_VENDOR_LISENCE_ENTITLEMENT_POOL, config.getCatalogBeHost(), config.getCatalogBePort(), vspid, versionId); + String userId = user.getUserId(); + + JSONObject jEntitlementMetricObject = new JSONObject(); + jEntitlementMetricObject.put("choice", "CPU"); + jEntitlementMetricObject.put("other", ""); + + JSONObject jAggregationFunctionObject = new JSONObject(); + jAggregationFunctionObject.put("choice", "Peak"); + jAggregationFunctionObject.put("other", ""); + + JSONObject jOperationalScope = new JSONObject(); + jOperationalScope.put("choices", Arrays.asList("Availability_Zone").toArray()); + jOperationalScope.put("other", ""); + + JSONObject jTimeObject = new JSONObject(); + jTimeObject.put("choice", "Hour"); + jTimeObject.put("other", ""); + + JSONObject jObjectBody = new JSONObject(); + jObjectBody.put("name", "def"+ OnboardingUtils.getShortUUID()); + jObjectBody.put("description", "new vendor license entitlement pool"); + jObjectBody.put("thresholdValue", "23"); + jObjectBody.put("thresholdUnits", "Absolute"); + jObjectBody.put("entitlementMetric", jEntitlementMetricObject); + jObjectBody.put("increments", "abcd"); + jObjectBody.put("aggregationFunction", jAggregationFunctionObject); + jObjectBody.put("operationalScope", jOperationalScope); + jObjectBody.put("time", jTimeObject); + jObjectBody.put("manufacturerReferenceNumber", "123aaa"); + + Map headersMap = OnboardingUtils.prepareHeadersMap(userId); + + HttpRequest http = new HttpRequest(); + RestResponse response = http.httpSendPost(url, jObjectBody.toString(), headersMap); + return response; + } + + public static RestResponse createVendorKeyGroups_2(String vspid, String versionId, User user) throws Exception { + Config config = Utils.getConfig(); + String url = String.format(Urls.CREATE_VENDOR_LISENCE_KEY_GROUPS, config.getCatalogBeHost(), config.getCatalogBePort(), vspid, versionId); + String userId = user.getUserId(); + + JSONObject jOperationalScope = new JSONObject(); + jOperationalScope.put("choices", Arrays.asList("Tenant").toArray()); + jOperationalScope.put("other", ""); + + JSONObject jObjectBody = new JSONObject(); + jObjectBody.put("name", "keyGroup" + OnboardingUtils.getShortUUID()); + jObjectBody.put("description", "new vendor license key group"); + jObjectBody.put("operationalScope", jOperationalScope); + jObjectBody.put("type", "Universal"); + + Map headersMap = OnboardingUtils.prepareHeadersMap(userId); + + HttpRequest http = new HttpRequest(); + RestResponse response = http.httpSendPost(url, jObjectBody.toString(), headersMap); + return response; + } + + public static RestResponse validateUpload(String vspid, User user, String vspVersion) throws Exception { + String body = null; + Config config = Utils.getConfig(); + String url = String.format(Urls.VALIDATE_UPLOAD, config.getCatalogBeHost(), config.getCatalogBePort(), vspid,vspVersion); + String userId = user.getUserId(); + + Map headersMap = OnboardingUtils.prepareHeadersMap(userId); + HttpRequest http = new HttpRequest(); + RestResponse response = http.httpSendPut(url, body, headersMap); + + return response; + } + +} diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/VendorSoftwareProductRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/VendorSoftwareProductRestUtils.java new file mode 100644 index 0000000000..c3b0a28f03 --- /dev/null +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/VendorSoftwareProductRestUtils.java @@ -0,0 +1,697 @@ +package org.openecomp.sdc.ci.tests.utils.general; + +import com.aventstack.extentreports.Status; +import com.clearspring.analytics.util.Pair; +import com.google.gson.Gson; +import org.apache.commons.io.IOUtils; +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.entity.mime.content.FileBody; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.json.simple.JSONArray; +import org.json.simple.JSONValue; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; +import org.openecomp.sdc.ci.tests.api.Urls; +import org.openecomp.sdc.ci.tests.config.Config; +import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.enums.CvfcTypeEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; +import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum; +import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest; +import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; +import org.openecomp.sdc.ci.tests.utils.Utils; +import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; +import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.StringWriter; +import java.nio.file.FileSystems; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import static org.testng.AssertJUnit.assertEquals; + +public class VendorSoftwareProductRestUtils { + + public static Pair createVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String heatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers, Map cvfcArtifacts) + throws Exception { + + Pair pair = createVSP(resourceReqDetails, heatFileName, filepath, user, amdocsLicenseMembers); + if(cvfcArtifacts != null && ! cvfcArtifacts.isEmpty()){ + addCvfcArtifacts(cvfcArtifacts, user, pair.right); + } + prepareVspForUse(user, pair.right, true); + return pair; + } + + public static Pair createVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String heatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers) + throws Exception { + + Map cvfcArtifacts = new HashMap<>(); + return createVendorSoftwareProduct(resourceReqDetails, heatFileName, filepath, user, amdocsLicenseMembers, cvfcArtifacts); + } + + /** + * @param user user + * @param vendorSoftwareProductObject vendorSoftwareProductObject + * @param isVspUpdated - in case isVspUpdated = false the commit API should not be issued + * the method do commit, submit and create package + * @throws Exception + */ + public static void prepareVspForUse(User user, VendorSoftwareProductObject vendorSoftwareProductObject, Boolean isVspUpdated) throws Exception { + + if(isVspUpdated) { + RestResponse commit = commitVendorSoftwareProduct(vendorSoftwareProductObject, user); + assertEquals("did not succeed to commit new VSP", 200, commit.getErrorCode().intValue()); + } + RestResponse submit = submitVendorSoftwareProduct(vendorSoftwareProductObject.getVspId(), user, vendorSoftwareProductObject.getComponentId()); + assertEquals("did not succeed to submit new VSP", 200, submit.getErrorCode().intValue()); + + RestResponse createPackage = createPackageOfVendorSoftwareProduct(vendorSoftwareProductObject.getVspId(), user, vendorSoftwareProductObject.getComponentId()); + assertEquals("did not succeed to create package of new VSP ", 200, createPackage.getErrorCode().intValue()); + + } + + public static VendorSoftwareProductObject createAndFillVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String heatFileName, String filePath, User user, AmdocsLicenseMembers amdocsLicenseMembers, Map cvfcArtifacts) + throws Exception { + + Pair createVendorSoftwareProduct = createVendorSoftwareProduct(resourceReqDetails, heatFileName, filePath, user, amdocsLicenseMembers, cvfcArtifacts); + VendorSoftwareProductObject vendorSoftwareProductObject = fillVendorSoftwareProductObjectWithMetaData(heatFileName, createVendorSoftwareProduct); + return vendorSoftwareProductObject; + + } + + + public static Pair createVSP(ResourceReqDetails resourceReqDetails, String heatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers) throws Exception { + String vspName = handleFilename(heatFileName); + + if(ComponentBaseTest.getExtendTest() != null){ + ComponentBaseTest.getExtendTest().log(Status.INFO, "Starting to create the vendor software product"); + } + + Pair createNewVspPair = createNewVendorSoftwareProduct(resourceReqDetails, vspName, amdocsLicenseMembers, user); + assertEquals("did not succeed to create new VSP", 200,createNewVspPair.left.getErrorCode().intValue()); + + RestResponse uploadHeatPackage = uploadHeatPackage(filepath, heatFileName, createNewVspPair.right, user); + assertEquals("did not succeed to upload HEAT package", 200, uploadHeatPackage.getErrorCode().intValue()); + + RestResponse validateUpload = validateUpload(createNewVspPair.right, user); + assertEquals("did not succeed to validate upload process, reason: " + validateUpload.getResponse(), 200, validateUpload.getErrorCode().intValue()); + + Pair pair = new Pair<>(vspName, createNewVspPair.right); + return pair; + } + + public static void updateVspWithVfcArtifacts(String filepath, String updatedSnmpPoll, String updatedSnmpTrap, String componentInstanceId, User user, VendorSoftwareProductObject vendorSoftwareProductObject) throws Exception{ + RestResponse checkout = creationMethodVendorSoftwareProduct(vendorSoftwareProductObject, user); + assertEquals("did not succeed to checkout new VSP", 200, checkout.getErrorCode().intValue()); +// ExtentTestActions.log(Status.INFO, "Deleting SNMP POLL"); + deleteArtifactByType(componentInstanceId, vendorSoftwareProductObject, user, CvfcTypeEnum.SNMP_POLL); +// ExtentTestActions.log(Status.INFO, "Deleting SNMP TRAP"); + deleteArtifactByType(componentInstanceId, vendorSoftwareProductObject, user, CvfcTypeEnum.SNMP_TRAP); + addVFCArtifacts(filepath, updatedSnmpPoll, updatedSnmpTrap, vendorSoftwareProductObject, user, componentInstanceId); + prepareVspForUse(user, vendorSoftwareProductObject, true); + } + + private static RestResponse deleteArtifactByType(String componentInstanceId, VendorSoftwareProductObject vendorSoftwareProductObject, User user, CvfcTypeEnum snmpType) throws Exception + { + Config config = Utils.getConfig(); + String url = String.format(Urls.DELETE_AMDOCS_ARTIFACT_BY_TYPE, config.getCatalogBeHost(), config.getCatalogBePort(), vendorSoftwareProductObject.getVspId(), vendorSoftwareProductObject.getComponentId(), componentInstanceId, snmpType.getValue()); + String userId = user.getUserId(); + Map headersMap = OnboardingUtils.prepareHeadersMap(userId); + + HttpRequest http = new HttpRequest(); + RestResponse response = http.httpSendDelete(url, headersMap); + return response; + } + + public static void updateVendorSoftwareProductToNextVersion(VendorSoftwareProductObject vendorSoftwareProductObject, User user, Boolean isVspUpdated) throws Throwable { + + RestResponse createMethod = creationMethodVendorSoftwareProduct(vendorSoftwareProductObject, user); + assertEquals("did not succeed to createMethod for new VSP", 200, createMethod.getErrorCode().intValue()); + prepareVspForUse(user,vendorSoftwareProductObject, isVspUpdated); + + } + + public static String handleFilename(String heatFileName) { + final String namePrefix = String.format("%sVF%s", ElementFactory.getResourcePrefix(), "Onboarded-"); + final String nameSuffix = "-" + OnboardingUtils.getShortUUID(); + + String subHeatFileName = heatFileName.substring(0, heatFileName.lastIndexOf(".")); + + if ((namePrefix + subHeatFileName + nameSuffix).length() >= 50) { + subHeatFileName = subHeatFileName.substring(0, 50 - namePrefix.length() - nameSuffix.length()); + } + + if (subHeatFileName.contains("(") || subHeatFileName.contains(")")) { + subHeatFileName = subHeatFileName.replace("(", "-"); + subHeatFileName = subHeatFileName.replace(")", "-"); + } + + String vnfName = namePrefix + subHeatFileName + nameSuffix; + return vnfName; + } + + public static String addVFCArtifacts(String filepath, String snmpPoll, String snmpTrap, VendorSoftwareProductObject vendorSoftwareProductObject, User user, String componentInstanceId) throws Exception{ + componentInstanceId = (componentInstanceId == null) ? getVspComponentId(vendorSoftwareProductObject, user) : componentInstanceId; + if (componentInstanceId != null){ + if (snmpPoll != null){ +// ExtentTestActions.log(Status.INFO, "Adding VFC artifact of type SNMP POLL with the file " + snmpPoll); + RestResponse uploadSnmpPollArtifact = uploadSnmpPollArtifact(filepath, snmpPoll, vendorSoftwareProductObject, user, componentInstanceId); + assertEquals("Did not succeed to add SNMP POLL", 200, uploadSnmpPollArtifact.getErrorCode().intValue()); + } + if (snmpTrap != null){ +// ExtentTestActions.log(Status.INFO, "Adding VFC artifact of type SNMP TRAP with the file " + snmpTrap); + RestResponse uploadSnmpTrapArtifact = uploadSnmpTrapArtifact(filepath, snmpTrap, vendorSoftwareProductObject, user, componentInstanceId); + assertEquals("Did not succeed to add SNMP TRAP", 200, uploadSnmpTrapArtifact.getErrorCode().intValue()); + } + } + + return componentInstanceId; + } + + public static String addCvfcArtifacts(Map componentVfcArtifacts, User user, VendorSoftwareProductObject vendorSoftwareProductObject) throws Exception{ + String componentInstanceId = getVspComponentId(vendorSoftwareProductObject, user); + if (componentInstanceId != null){ + for(Map.Entry entry : componentVfcArtifacts.entrySet()){ +// ExtentTestActions.log(Status.INFO, "Adding VFC artifact of type " + entry.getKey().getValue() + " with the file " + entry.getValue()); + RestResponse uploadSnmpPollArtifact = uploadCvfcArtifact(entry.getValue(), entry.getKey().getValue(), user, vendorSoftwareProductObject, componentInstanceId); + assertEquals("Did not succeed to add " + entry.getKey().getValue(), BaseRestUtils.STATUS_CODE_SUCCESS, uploadSnmpPollArtifact.getErrorCode().intValue()); + } + } + return componentInstanceId; + } + + public static String addVFCArtifacts(String filepath, String snmpPoll, String snmpTrap, VendorSoftwareProductObject vendorSoftwareProductObject, User user) throws Exception{ + return addVFCArtifacts(filepath, snmpPoll, snmpTrap, vendorSoftwareProductObject, user, null); + } + + public static RestResponse uploadCvfcArtifact(String filepath, String cvfcType, User user, VendorSoftwareProductObject vendorSoftwareProductObject, String componentInstanceId) throws IOException { + Config config = Utils.getConfig(); + String snmpPollUrl = String.format(Urls.UPLOAD_AMDOCS_ARTIFACT, config.getCatalogBeHost(),config.getCatalogBePort(), vendorSoftwareProductObject.getVspId(), vendorSoftwareProductObject.getComponentId(), componentInstanceId, cvfcType); + return uploadFile(filepath, null, snmpPollUrl, user); + } + + + private static RestResponse uploadSnmpPollArtifact(String filepath, String zipArtifact, VendorSoftwareProductObject vendorSoftwareProductObject, User user, String componentInstanceId) throws IOException { + Config config = Utils.getConfig(); + String snmpPollUrl = String.format(Urls.UPLOAD_SNMP_POLL_ARTIFACT, config.getCatalogBeHost(),config.getCatalogBePort(), vendorSoftwareProductObject.getVspId(), vendorSoftwareProductObject.getComponentId(), componentInstanceId); + return uploadFile(filepath, zipArtifact, snmpPollUrl, user); + } + + private static RestResponse uploadSnmpTrapArtifact(String filepath, String zipArtifact, VendorSoftwareProductObject vendorSoftwareProductObject, User user, String vspComponentId) throws IOException { + Config config = Utils.getConfig(); + String snmpTrapUrl = String.format(Urls.UPLOAD_SNMP_POLL_ARTIFACT, config.getCatalogBeHost(),config.getCatalogBePort(), vendorSoftwareProductObject.getVspId(), vendorSoftwareProductObject.getComponentId(), vspComponentId); + return uploadFile(filepath, zipArtifact, snmpTrapUrl, user); + } + + private static RestResponse deleteSnmpArtifact(String componentId, String vspId, User user, SnmpTypeEnum snmpType) throws Exception + { + Config config = Utils.getConfig(); + String url = String.format(Urls.DELETE_AMDOCS_ARTIFACT_BY_TYPE, config.getCatalogBeHost(),config.getCatalogBePort(), vspId, componentId, snmpType.getValue()); + String userId = user.getUserId(); + + Map headersMap = OnboardingUtils.prepareHeadersMap(userId); + + HttpRequest http = new HttpRequest(); + RestResponse response = http.httpSendDelete(url, headersMap); + return response; + } + + + /** + * @param vendorSoftwareProductObject VendorSoftwareProductObject + * @param user user object + * @return return first found component instance Id from list + * @throws Exception Exception + */ + private static String getVspComponentId(VendorSoftwareProductObject vendorSoftwareProductObject, User user) throws Exception { + RestResponse componentList = getVSPComponents(vendorSoftwareProductObject, user); + String response = componentList.getResponse(); + Map responseMap = (Map) JSONValue.parse(response); + JSONArray results = (JSONArray)responseMap.get("results"); + for (Object res : results){ + Map componentMap = (Map) JSONValue.parse(res.toString()); + String componentInstanceId = componentMap.get("id").toString(); + return componentInstanceId; + } + return null; + } + + private static RestResponse getVSPComponents(VendorSoftwareProductObject vendorSoftwareProductObject, User user) throws Exception{ + Config config = Utils.getConfig(); + String url = String.format(Urls.GET_VSP_COMPONENTS, config.getCatalogBeHost(),config.getCatalogBePort(), vendorSoftwareProductObject.getVspId(), vendorSoftwareProductObject.getComponentId()); + Map headersMap = OnboardingUtils.prepareHeadersMap(user.getUserId()); + + HttpRequest http = new HttpRequest(); + RestResponse response = http.httpSendGet(url, headersMap); + return response; + } + + + + public static boolean validateVspExist(VendorSoftwareProductObject vendorSoftwareProductObject, User user) throws Exception { + RestResponse restResponse = getVSPComponentByVersion(vendorSoftwareProductObject, user); + assertEquals(String.format("Vsp version not updated, reponse message: %s", restResponse.getResponse()),restResponse.getErrorCode().intValue(),200); + return (restResponse.getErrorCode()==200); + } + + + private static RestResponse getVSPComponentByVersion(VendorSoftwareProductObject vendorSoftwareProductObject, User user) throws Exception{ + Config config = Utils.getConfig(); + String url = String.format(Urls.GET_VSP_COMPONENT_BY_VERSION, config.getCatalogBeHost(),config.getCatalogBePort(), vendorSoftwareProductObject.getVspId(), vendorSoftwareProductObject.getComponentId()); + String userId = user.getUserId(); + + Map headersMap = OnboardingUtils.prepareHeadersMap(userId); + + HttpRequest http = new HttpRequest(); + RestResponse response = http.httpSendGet(url, headersMap); + return response; + } + + private static RestResponse actionOnComponent(String vspid, String body, String onboardComponent, User user, String componentVersion) throws Exception { + Config config = Utils.getConfig(); + String url = String.format(Urls.ACTION_ON_COMPONENT, config.getCatalogBeHost(), config.getCatalogBePort(), onboardComponent, vspid, componentVersion); + String userId = user.getUserId(); + Map headersMap = OnboardingUtils.prepareHeadersMap(userId); + + HttpRequest http = new HttpRequest(); + RestResponse response = http.httpSendPut(url, body, headersMap); + return response; + } + + public static Pair createNewVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String vspName, AmdocsLicenseMembers amdocsLicenseMembers, User user) throws Exception { + + Config config = Utils.getConfig(); + String url = String.format(Urls.CREATE_VENDOR_SOFTWARE_PRODUCT, config.getCatalogBeHost(), config.getCatalogBePort()); + String userId = user.getUserId(); + VendorSoftwareProductObject vendorSoftwareProductObject = new VendorSoftwareProductObject(); + LicensingData licensingData = new LicensingData(amdocsLicenseMembers.getVendorLicenseAgreementId(), Arrays.asList(amdocsLicenseMembers.getFeatureGroupId())); + ResourceCategoryEnum resourceCategoryEnum = ResourceCategoryEnum.findEnumNameByValues(resourceReqDetails.getCategories().get(0).getName(), resourceReqDetails.getCategories().get(0).getSubcategories().get(0).getName()); + + vendorSoftwareProductObject.setName(vspName); + vendorSoftwareProductObject.setDescription(resourceReqDetails.getDescription()); + vendorSoftwareProductObject.setCategory(resourceCategoryEnum.getCategoryUniqeId()); + vendorSoftwareProductObject.setSubCategory(resourceCategoryEnum.getSubCategoryUniqeId()); + vendorSoftwareProductObject.setOnboardingMethod("NetworkPackage"); + vendorSoftwareProductObject.setVendorName(amdocsLicenseMembers.getVendorLicenseName()); + vendorSoftwareProductObject.setVendorId(amdocsLicenseMembers.getVendorId()); + vendorSoftwareProductObject.setIcon("icon"); + vendorSoftwareProductObject.setLicensingData(licensingData); + vendorSoftwareProductObject.setLicensingVersion(amdocsLicenseMembers.getVersion()); + + Map headersMap = OnboardingUtils.prepareHeadersMap(userId); + HttpRequest http = new HttpRequest(); + Gson gson = new Gson(); + String body = gson.toJson(vendorSoftwareProductObject); + + RestResponse response = http.httpSendPost(url, body, headersMap); + + vendorSoftwareProductObject.setVspId(ResponseParser.getValueFromJsonResponse(response.getResponse(), "itemId")); + vendorSoftwareProductObject.setComponentId(ResponseParser.getValueFromJsonResponse(response.getResponse(), "version:id")); +// vendorSoftwareProductObject.setVersion(ResponseParser.getValueFromJsonResponse(response.getResponse(), "version:name")); + vendorSoftwareProductObject.setAttContact(user.getUserId()); + + return new Pair<>(response, vendorSoftwareProductObject); + } + + public static RestResponse validateUpload(VendorSoftwareProductObject vendorSoftwareProductObject, User user) throws Exception { + Config config = Utils.getConfig(); + String url = String.format(Urls.VALIDATE_UPLOAD, config.getCatalogBeHost(), config.getCatalogBePort(), vendorSoftwareProductObject.getVspId(), vendorSoftwareProductObject.getComponentId()); + String userId = user.getUserId(); + + Map headersMap = OnboardingUtils.prepareHeadersMap(userId); + HttpRequest http = new HttpRequest(); + RestResponse response = http.httpSendPut(url, null, headersMap); + + return response; + } + + public static RestResponse uploadHeatPackage(String filepath, String filename, VendorSoftwareProductObject vendorSoftwareProductObject, User user) throws Exception { + Config config = Utils.getConfig(); + String url = String.format(Urls.UPLOAD_HEAT_PACKAGE, config.getCatalogBeHost(), config.getCatalogBePort(), vendorSoftwareProductObject.getVspId(), vendorSoftwareProductObject.getComponentId()); + return uploadFile(filepath, filename, url, user); + } + + private static RestResponse uploadFile(String filepath, String filename, String url, User user) throws IOException{ + CloseableHttpResponse response = null; + + MultipartEntityBuilder mpBuilder = MultipartEntityBuilder.create(); + mpBuilder.addPart("upload", new FileBody(getTestZipFile(filepath, filename))); + + Map headersMap = OnboardingUtils.prepareHeadersMap(user.getUserId()); + headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "multipart/form-data"); + + CloseableHttpClient client = HttpClients.createDefault(); + try { + HttpPost httpPost = new HttpPost(url); + RestResponse restResponse = new RestResponse(); + + Iterator iterator = headersMap.keySet().iterator(); + while (iterator.hasNext()) { + String key = iterator.next(); + String value = headersMap.get(key); + httpPost.addHeader(key, value); + } + httpPost.setEntity(mpBuilder.build()); + response = client.execute(httpPost); + HttpEntity entity = response.getEntity(); + String responseBody = null; + if (entity != null) { + InputStream instream = entity.getContent(); + try { + StringWriter writer = new StringWriter(); + IOUtils.copy(instream, writer); + responseBody = writer.toString(); + } finally { + instream.close(); + } + } + + restResponse.setErrorCode(response.getStatusLine().getStatusCode()); + restResponse.setResponse(responseBody); + + return restResponse; + + } finally { + closeResponse(response); + closeHttpClient(client); + + } + } + + private static void closeResponse(CloseableHttpResponse response) { + try { + if (response != null) { + response.close(); + } + } catch (IOException e) { + System.out.println(String.format("failed to close client or response: %s", e.getMessage())); + } + } + + private static void closeHttpClient(CloseableHttpClient client) { + try { + if (client != null) { + client.close(); + } + } catch (IOException e) { + System.out.println(String.format("failed to close client or response: %s", e.getMessage())); + } + } + + private static File getTestZipFile(String filepath, String filename) throws IOException { + Config config = Utils.getConfig(); + String sourceDir = config.getImportResourceTestsConfigDir(); + java.nio.file.Path filePath; + if(filename == null){ + filePath = FileSystems.getDefault().getPath(filepath); + }else{ + filePath = FileSystems.getDefault().getPath(filepath + File.separator + filename); + } + return filePath.toFile(); + } + + public static RestResponse checkinVendorSoftwareProduct(User user, VendorSoftwareProductObject vendorSoftwareProductObject) throws Exception { + Config config = Utils.getConfig(); + String url = String.format(Urls.UPDATE_VSP, config.getCatalogBeHost(), config.getCatalogBePort(), vendorSoftwareProductObject.getVspId(), vendorSoftwareProductObject.getComponentId()); + + String userId = user.getUserId(); + Map headersMap = OnboardingUtils.prepareHeadersMap(userId); +// unset vspId, componentId, attContact, onboardingMethod + String vspId = vendorSoftwareProductObject.getVspId(); + String componentId = vendorSoftwareProductObject.getComponentId(); + String attContact = vendorSoftwareProductObject.getAttContact(); + String onboardingMethod = vendorSoftwareProductObject.getOnboardingMethod(); + vendorSoftwareProductObject.setVspId(null); + vendorSoftwareProductObject.setComponentId(null); + vendorSoftwareProductObject.setAttContact(null); + vendorSoftwareProductObject.setOnboardingMethod(null); + Gson gson = new Gson(); + String body = gson.toJson(vendorSoftwareProductObject); + HttpRequest http = new HttpRequest(); + RestResponse response = http.httpSendPut(url, body, headersMap); +// set back vspId, componentId, attContact, onboardingMethod + vendorSoftwareProductObject.setVspId(vspId); + vendorSoftwareProductObject.setComponentId(componentId); + vendorSoftwareProductObject.setAttContact(attContact); + vendorSoftwareProductObject.setOnboardingMethod(onboardingMethod); + + return response; + } + + public static RestResponse commitVendorSoftwareProduct(VendorSoftwareProductObject vendorSoftwareProductObject, User user) throws Exception { + String messageBody = "{\"action\":\"Commit\",\"commitRequest\":{\"message\":\"commit\"}}"; + return actionOnComponent(vendorSoftwareProductObject.getVspId(), messageBody, "items", user, vendorSoftwareProductObject.getComponentId()); + } + + public static RestResponse submitVendorSoftwareProduct(String vspid, User user, String componentId) throws Exception { + return actionOnComponent(vspid, "{\"action\":\"Submit\"}", "vendor-software-products", user, componentId); + } + + public static RestResponse createPackageOfVendorSoftwareProduct(String vspid, User user, String componentId) throws Exception { + return actionOnComponent(vspid, "{\"action\":\"Create_Package\"}", "vendor-software-products", user, componentId); + } + + public static RestResponse creationMethodVendorSoftwareProduct(VendorSoftwareProductObject vendorSoftwareProductObject, User user) throws Exception { + String messageBody = "{\"description\":\"2.0\",\"creationMethod\":\"major\"}"; + return createMethodVendorSoftwareProduct(vendorSoftwareProductObject, messageBody, "items", user); + } + + private static RestResponse createMethodVendorSoftwareProduct(VendorSoftwareProductObject vendorSoftwareProductObject, String body, String onboardComponent, User user) throws Exception { + Config config = Utils.getConfig(); + String url = String.format(Urls.CREATE_METHOD, config.getCatalogBeHost(), config.getCatalogBePort(), onboardComponent, vendorSoftwareProductObject.getVspId(), vendorSoftwareProductObject.getComponentId()); + String userId = user.getUserId(); + Map headersMap = OnboardingUtils.prepareHeadersMap(userId); + + HttpRequest http = new HttpRequest(); + RestResponse response = http.httpSendPost(url, body, headersMap); + if(response.getErrorCode().intValue() == 200) { + vendorSoftwareProductObject.setComponentId(ResponseParser.getValueFromJsonResponse(response.getResponse(), "id")); + } + return response; + } + + public static VendorSoftwareProductObject updateVSPWithNewVLMParameters(VendorSoftwareProductObject vendorSoftwareProductObject, AmdocsLicenseMembers amdocsLicenseMembers, User user) throws Exception { + + RestResponse createMethod = creationMethodVendorSoftwareProduct(vendorSoftwareProductObject, user); + assertEquals("did not succeed to checkout new VSP", 200, createMethod.getErrorCode().intValue()); +// vendorSoftwareProductObject.setComponentId(ResponseParser.getValueFromJsonResponse(createMethod.getResponse(), "id")); + + String licensingVersion = amdocsLicenseMembers.getVersion(); + LicensingData licensingData = new LicensingData(amdocsLicenseMembers.getVendorLicenseAgreementId(), Arrays.asList(amdocsLicenseMembers.getFeatureGroupId())); + vendorSoftwareProductObject.setVendorId(amdocsLicenseMembers.getVendorId()); + vendorSoftwareProductObject.setVendorName(amdocsLicenseMembers.getVendorLicenseName()); + vendorSoftwareProductObject.setLicensingVersion(licensingVersion); + vendorSoftwareProductObject.setLicensingData(licensingData); + + VendorSoftwareProductObjectReqDetails vendorSoftwareProductObjectReqDetails = new VendorSoftwareProductObjectReqDetails( + vendorSoftwareProductObject.getName(), vendorSoftwareProductObject.getDescription(), vendorSoftwareProductObject.getCategory(), + vendorSoftwareProductObject.getSubCategory(), vendorSoftwareProductObject.getVendorId(), vendorSoftwareProductObject.getVendorName(), + vendorSoftwareProductObject.getLicensingVersion(), vendorSoftwareProductObject.getLicensingData(), + null, null, null, vendorSoftwareProductObject.getIcon() ); + + Gson gson = new Gson(); + String body = gson.toJson(vendorSoftwareProductObjectReqDetails); + RestResponse updateResponse = updateVendorSoftwareProduct(vendorSoftwareProductObject, body, user); + assertEquals("did not succeed to update VSP", 200, updateResponse.getErrorCode().intValue()); + + prepareVspForUse(user, vendorSoftwareProductObject, true); + + return vendorSoftwareProductObject; + } + + public static RestResponse updateVendorSoftwareProduct(VendorSoftwareProductObject vendorSoftwareProductObject, String body, User user) throws Exception { + + Config config = Utils.getConfig(); + String url = String.format(Urls.UPDATE_VSP, config.getCatalogBeHost(), config.getCatalogBePort(), vendorSoftwareProductObject.getVspId(), vendorSoftwareProductObject.getComponentId()); + String userId = user.getUserId(); + + Map headersMap = OnboardingUtils.prepareHeadersMap(userId); + HttpRequest http = new HttpRequest(); + + RestResponse response = http.httpSendPut(url, body, headersMap); + return response; + } + +// private static void importUpdateVSP(Pair> vsp, boolean isUpdate) throws Exception{ +// String vspName = vsp.left; +// Map vspMetadata = vsp.right; +// boolean vspFound = HomePage.searchForVSP(vspName); +// +// if (vspFound){ +// +// List elemenetsFromTable = HomePage.getElemenetsFromTable(); +//// WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), 30); +//// WebElement findElement = wait.until(ExpectedConditions.visibilityOf(elemenetsFromTable.get(1))); +//// findElement.click(); +// elemenetsFromTable.get(1).click(); +// GeneralUIUtils.waitForLoader(); +// +// if (isUpdate){ +// GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ImportVfRepository.UPDATE_VSP.getValue()); +// +// } +// else{ +// GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ImportVfRepository.IMPORT_VSP.getValue()); +// } +// +// String lifeCycleState = ResourceGeneralPage.getLifeCycleState(); +// boolean needCheckout = lifeCycleState.equals(LifeCycleStateEnum.CHECKIN.getValue()) || lifeCycleState.equals(LifeCycleStateEnum.CERTIFIED.getValue()); +// if (needCheckout) +// { +// try { +// ResourceGeneralPage.clickCheckoutButton(); +// Assert.assertTrue(ResourceGeneralPage.getLifeCycleState().equals(LifeCycleStateEnum.CHECKOUT.getValue()), "Did not succeed to checkout"); +// +// } catch (Exception e) { +// ExtentTestActions.log(Status.ERROR, "Did not succeed to checkout"); +// e.printStackTrace(); +// } +// GeneralUIUtils.waitForLoader(); +// } +// +// //Metadata verification +// VfVerificator.verifyOnboardedVnfMetadata(vspName, vspMetadata); +// +// ExtentTestActions.log(Status.INFO, "Clicking create/update VNF"); +// String duration = GeneralUIUtils.getActionDuration(() -> waitUntilVnfCreated()); +// ExtentTestActions.log(Status.INFO, "Succeeded in importing/updating " + vspName, duration); +// } +// else{ +// Assert.fail("Did not find VSP named " + vspName); +// } +// } + +// private static void waitUntilVnfCreated() { +// GeneralUIUtils.clickOnElementByTestIdWithoutWait(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue()); +// GeneralUIUtils.waitForLoader(60*10); +// GeneralUIUtils.waitForAngular(); +// GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.CHECKIN_BUTTON.getValue()); +// } +// +// public static void updateVSP(Pair> vsp) throws Exception{ +// ExtentTestActions.log(Status.INFO, "Updating VSP " + vsp.left); +// importUpdateVSP(vsp, true); +// } +// +// public static void importVSP(Pair> vsp) throws Exception{ +// ExtentTestActions.log(Status.INFO, "Importing VSP " + vsp.left); +// importUpdateVSP(vsp, false); +// } +// +// public static void updateVnfAndValidate(String filepath, Pair> vsp, String updatedVnfFile, User user) throws Exception, Throwable { +// ExtentTestActions.log(Status.INFO, String.format("Going to update the VNF with %s......", updatedVnfFile)); +// System.out.println(String.format("Going to update the VNF with %s......", updatedVnfFile)); +// +// Map vspMap = vsp.right; +// String vspId = vspMap.get("vspId"); +// +// updateVendorSoftwareProduct(vspId, updatedVnfFile, filepath, user); +// HomePage.showVspRepository(); +// updateVSP(vsp); +// ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); +// DeploymentArtifactPage.verifyArtifactsExistInTable(filepath, updatedVnfFile); +// } +// +// public static Pair> onboardAndValidate(String filepath, String vnfFile, User user) throws Exception { +// ExtentTestActions.log(Status.INFO, String.format("Going to onboard the VNF %s", vnfFile)); +// System.out.println(String.format("Going to onboard the VNF %s", vnfFile)); +// +// AmdocsLicenseMembers amdocsLicenseMembers = createVendorLicense(user); +// Pair> createVendorSoftwareProduct = createVendorSoftwareProduct(vnfFile, filepath, user, amdocsLicenseMembers); +// String vspName = createVendorSoftwareProduct.left; +// +// DownloadManager.downloadCsarByNameFromVSPRepository(vspName, createVendorSoftwareProduct.right.get("vspId")); +// File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(); +// +// ExtentTestActions.log(Status.INFO, String.format("Searching for onboarded %s", vnfFile)); +// HomePage.showVspRepository(); +// ExtentTestActions.log(Status.INFO,String.format("Going to import %s", vnfFile.substring(0, vnfFile.indexOf(".")))); +// importVSP(createVendorSoftwareProduct); +// +// ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); +// +// // Verify deployment artifacts +// Map combinedMap = ArtifactFromCsar.combineHeatArtifacstWithFolderArtifacsToMap(latestFilefromDir.getAbsolutePath()); +// +// LinkedList deploymentArtifacts = ((LinkedList) combinedMap.get("Deployment")); +// ArtifactsCorrelationManager.addVNFartifactDetails(vspName, deploymentArtifacts); +// +// List heatEnvFilesFromCSAR = deploymentArtifacts.stream().filter(e -> e.getType().equals("HEAT_ENV")). +// map(e -> e.getFileName()). +// collect(Collectors.toList()); +// +// validateDeploymentArtifactsVersion(deploymentArtifacts, heatEnvFilesFromCSAR); +// +// DeploymentArtifactPage.verifyArtifactsExistInTable(filepath, vnfFile); +// return createVendorSoftwareProduct; +// } +// +// public static void validateDeploymentArtifactsVersion(LinkedList deploymentArtifacts, +// List heatEnvFilesFromCSAR) { +// String artifactVersion; +// String artifactName; +// +// for(HeatMetaFirstLevelDefinition deploymentArtifact: deploymentArtifacts) { +// artifactVersion = "1"; +// +// if(deploymentArtifact.getType().equals("HEAT_ENV")) { +// continue; +// } else if(deploymentArtifact.getFileName().contains(".")) { +// artifactName = deploymentArtifact.getFileName().trim().substring(0, deploymentArtifact.getFileName().lastIndexOf(".")); +// } else { +// artifactName = deploymentArtifact.getFileName().trim(); +// } +// +// if (heatEnvFilesFromCSAR.contains(artifactName + ".env")){ +// artifactVersion = "2"; +// } +// ArtifactUIUtils.validateArtifactNameVersionType(artifactName, artifactVersion, deploymentArtifact.getType()); +// } +// } + + + public static VendorSoftwareProductObject fillVendorSoftwareProductObjectWithMetaData(String vnfFile, Pair createVendorSoftwareProduct) { + VendorSoftwareProductObject vendorSoftwareProductObject = new VendorSoftwareProductObject(); + VendorSoftwareProductObject map = createVendorSoftwareProduct.right; + vendorSoftwareProductObject.setAttContact(map.getAttContact()); + vendorSoftwareProductObject.setCategory(map.getCategory()); + vendorSoftwareProductObject.setComponentId(map.getComponentId()); + vendorSoftwareProductObject.setDescription(map.getDescription()); + vendorSoftwareProductObject.setSubCategory(map.getSubCategory()); + vendorSoftwareProductObject.setVendorName(map.getVendorName()); + vendorSoftwareProductObject.setVspId(map.getVspId()); + vendorSoftwareProductObject.setName(createVendorSoftwareProduct.left); + String[] arrFileNameAndExtension = vnfFile.split("\\."); + vendorSoftwareProductObject.setOnboardingMethod("NetworkPackage"); + vendorSoftwareProductObject.setNetworkPackageName(arrFileNameAndExtension[0]); + vendorSoftwareProductObject.setOnboardingOrigin(arrFileNameAndExtension[1]); + + return vendorSoftwareProductObject; + } + + public static void updateVendorSoftwareProductToNextVersion(VendorSoftwareProductObject vendorSoftwareProductObject, User user, String filepath, String heatFileName) throws Throwable { + + RestResponse createMethod = creationMethodVendorSoftwareProduct(vendorSoftwareProductObject, user); + assertEquals("did not succeed to createMethod for new VSP", 200, createMethod.getErrorCode().intValue()); + + RestResponse uploadHeatPackage = uploadHeatPackage(filepath, heatFileName, vendorSoftwareProductObject, user); + assertEquals("did not succeed to upload HEAT package", 200, uploadHeatPackage.getErrorCode().intValue()); + + RestResponse validateUpload = validateUpload(vendorSoftwareProductObject, user); + assertEquals("did not succeed to validate upload process, reason: " + validateUpload.getResponse(), 200, validateUpload.getErrorCode().intValue()); + + prepareVspForUse(user,vendorSoftwareProductObject, true); + } + + +} diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ArtifactRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ArtifactRestUtils.java index a7ab544725..448442e112 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ArtifactRestUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ArtifactRestUtils.java @@ -50,15 +50,12 @@ import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.Utils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; -import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.util.ValidationUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.AssertJUnit; import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; public class ArtifactRestUtils extends BaseRestUtils { private static Logger logger = LoggerFactory.getLogger(ArtifactRestUtils.class.getName()); @@ -68,7 +65,7 @@ public class ArtifactRestUtils extends BaseRestUtils { // Delete Artifact on rI of the asset public static RestResponse externalAPIDeleteArtifactOfComponentInstanceOnAsset(Component component, User user, ComponentInstance resourceInstance, String artifactUUID) throws IOException { Config config = Utils.getConfig(); - String resourceType = null; + String resourceType; String resourceUUID = component.getUUID(); String resourceInstanceName = resourceInstance.getNormalizedName(); @@ -88,7 +85,7 @@ public class ArtifactRestUtils extends BaseRestUtils { // Delete Artifact of the asset public static RestResponse externalAPIDeleteArtifactOfTheAsset(Component component, User user, String artifactUUID) throws IOException { Config config = Utils.getConfig(); - String resourceType = null; + String resourceType; String resourceUUID = component.getUUID(); System.out.println(component.getComponentType()); @@ -110,7 +107,7 @@ public class ArtifactRestUtils extends BaseRestUtils { // Update Artifact on rI of the asset public static RestResponse externalAPIUpdateArtifactOfComponentInstanceOnAsset(Component component, User user, ArtifactReqDetails artifactReqDetails, ComponentInstance resourceInstance, String artifactUUID) throws IOException { Config config = Utils.getConfig(); - String resourceType = null; + String resourceType; String resourceUUID = component.getUUID(); String resourceInstanceName = resourceInstance.getNormalizedName(); @@ -130,7 +127,7 @@ public class ArtifactRestUtils extends BaseRestUtils { // Update Artifact of the asset public static RestResponse externalAPIUpdateArtifactOfTheAsset(Component component, User user, ArtifactReqDetails artifactReqDetails, String artifactUUID) throws IOException { Config config = Utils.getConfig(); - String resourceType = null; + String resourceType; String resourceUUID = component.getUUID(); System.out.println(component.getComponentType()); @@ -150,7 +147,7 @@ public class ArtifactRestUtils extends BaseRestUtils { // Upload Artifact on rI of the asset public static RestResponse externalAPIUploadArtifactOfComponentInstanceOnAsset(Component component, User user, ArtifactReqDetails artifactReqDetails, ComponentInstance resourceInstance) throws IOException { Config config = Utils.getConfig(); - String resourceType = null; + String resourceType; String resourceUUID = component.getUUID(); String resourceInstanceName = resourceInstance.getNormalizedName(); @@ -170,7 +167,7 @@ public class ArtifactRestUtils extends BaseRestUtils { // Upload Artifact of the asset public static RestResponse externalAPIUploadArtifactOfTheAsset(Component component, User user, ArtifactReqDetails artifactReqDetails) throws IOException { Config config = Utils.getConfig(); - String resourceType = null; + String resourceType; String resourceUUID = component.getUUID(); System.out.println(component.getComponentType()); @@ -190,7 +187,7 @@ public class ArtifactRestUtils extends BaseRestUtils { // Upload Artifact of the asset with invalid checksum public static RestResponse externalAPIUploadArtifactWithInvalidCheckSumOfComponentInstanceOnAsset(Component component, User user, ArtifactReqDetails artifactReqDetails, ComponentInstance resourceInstance) throws IOException { Config config = Utils.getConfig(); - String resourceType = null; + String resourceType; String resourceUUID = component.getUUID(); String resourceInstanceName = resourceInstance.getNormalizedName(); @@ -210,7 +207,7 @@ public class ArtifactRestUtils extends BaseRestUtils { // Upload Artifact of the asset with invalid checksum public static RestResponse externalAPIUploadArtifactWithInvalidCheckSumOfTheAsset(Component component, User user, ArtifactReqDetails artifactReqDetails) throws IOException { Config config = Utils.getConfig(); - String resourceType = null; + String resourceType; String resourceUUID = component.getUUID(); System.out.println(component.getComponentType()); @@ -232,7 +229,7 @@ public class ArtifactRestUtils extends BaseRestUtils { // public static RestResponse getResourceDeploymentArtifactExternalAPI(String resourceUUID, String artifactUUID,User sdncModifierDetails, String resourceType) throws IOException { Config config = Utils.getConfig(); - String url = null; + String url; if (resourceType.toUpperCase().equals("SERVICE")) { url = String.format(Urls.GET_DOWNLOAD_SERVICE_ARTIFACT_OF_ASSET, config.getCatalogBeHost(), config.getCatalogBePort(), resourceUUID, artifactUUID); @@ -241,11 +238,12 @@ public class ArtifactRestUtils extends BaseRestUtils { url = String.format(Urls.GET_DOWNLOAD_RESOURCE_ARTIFACT_OF_ASSET, config.getCatalogBeHost(), config.getCatalogBePort(), resourceUUID, artifactUUID); } - Map headersMap = new HashMap(); + Map headersMap = new HashMap<>(); headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId()); headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader); - headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci"); + headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId); + headersMap.put(HttpHeaderEnum.ACCEPT.getValue(),acceptMultipartHeader); HttpRequest http = new HttpRequest(); @@ -265,7 +263,7 @@ public class ArtifactRestUtils extends BaseRestUtils { public static RestResponse getComponentInstanceDeploymentArtifactExternalAPI(String resourceUUID, String componentNormalizedName, String artifactUUID,User sdncModifierDetails, String resourceType) throws IOException { Config config = Utils.getConfig(); - String url = null; + String url; if (resourceType.toLowerCase().equals("service")) { url = String.format(Urls.GET_DOWNLOAD_SERVICE_ARTIFACT_OF_COMPONENT_INSTANCE, config.getCatalogBeHost(), config.getCatalogBePort(), resourceUUID, componentNormalizedName, artifactUUID); @@ -274,11 +272,12 @@ public class ArtifactRestUtils extends BaseRestUtils { url = String.format(Urls.GET_DOWNLOAD_RESOURCE_ARTIFACT_OF_COMPONENT_INSTANCE, config.getCatalogBeHost(), config.getCatalogBePort(), resourceUUID, componentNormalizedName, artifactUUID); } - Map headersMap = new HashMap(); + Map headersMap = new HashMap<>(); headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId()); headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader); - headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci"); + headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId); + headersMap.put(HttpHeaderEnum.ACCEPT.getValue(),acceptMultipartHeader); HttpRequest http = new HttpRequest(); @@ -443,7 +442,7 @@ public class ArtifactRestUtils extends BaseRestUtils { public static Map getHeadersMap(User sdncModifierDetails) { - Map headersMap = new HashMap(); + Map headersMap = new HashMap<>(); headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptJsonHeader); @@ -602,9 +601,9 @@ public class ArtifactRestUtils extends BaseRestUtils { public static RestResponse uploadDeploymentArtifact(ArtifactReqDetails artifactDetails, Component component, User sdncModifierDetails) throws IOException { Config config = Utils.getConfig(); - Map additionalHeaders = null; + Map additionalHeaders; String checksum = ResponseParser.calculateMD5Header(artifactDetails); - additionalHeaders = new HashMap(); + additionalHeaders = new HashMap<>(); additionalHeaders.put(HttpHeaderEnum.Content_MD5.getValue(), checksum); ComponentTypeEnum componentType = component.getComponentType(); @@ -614,26 +613,26 @@ public class ArtifactRestUtils extends BaseRestUtils { switch (componentType){ case RESOURCE: - { - url = String.format(Urls.UPDATE_OR_DELETE_ARTIFACT_OF_SERVICE, config.getCatalogBeHost(),config.getCatalogBePort(), component.getUniqueId(), artifactDetails.getUniqueId()); - - break; - } - case SERVICE: { - - break; - } - - case PRODUCT: { - - break; - } - - default: {//dummy - assertTrue("failed on enum selection", false); - - break; - } + { + url = String.format(Urls.UPDATE_OR_DELETE_ARTIFACT_OF_SERVICE, config.getCatalogBeHost(),config.getCatalogBePort(), component.getUniqueId(), artifactDetails.getUniqueId()); + + break; + } + case SERVICE: { + + break; + } + + case PRODUCT: { + + break; + } + + default: {//dummy + assertTrue("failed on enum selection", false); + + break; + } } @@ -654,9 +653,9 @@ public class ArtifactRestUtils extends BaseRestUtils { public static RestResponse uploadArtifact(ArtifactReqDetails artifactDetails, Component component, User sdncModifierDetails) throws IOException { Config config = Utils.getConfig(); List placeHolderlst = Utils.getListOfResPlaceHoldersDepArtTypes(); - Map additionalHeaders = null; - String checksum = null; - String url= null; + Map additionalHeaders; + String checksum; + String url; // // // if (artifactDetails.getArtifactGroupType() != null @@ -676,7 +675,7 @@ public class ArtifactRestUtils extends BaseRestUtils { // // else { checksum = ResponseParser.calculateMD5Header(artifactDetails); - additionalHeaders = new HashMap(); + additionalHeaders = new HashMap<>(); additionalHeaders.put(HttpHeaderEnum.Content_MD5.getValue(), checksum); url = String.format(Urls.UPLOAD_DELETE_ARTIFACT_OF_COMPONENT, config.getCatalogBeHost(), config.getCatalogBePort(), ComponentTypeEnum.findParamByType(component.getComponentType()), @@ -700,13 +699,13 @@ public class ArtifactRestUtils extends BaseRestUtils { //*************** PRIVATE ************** private static RestResponse deleteInformationalArtifact(User sdncModifierDetails, String url) throws IOException { - Map additionalHeaders = null; + Map additionalHeaders; - additionalHeaders = new HashMap(); + additionalHeaders = new HashMap<>(); additionalHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader); - additionalHeaders.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci"); + additionalHeaders.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId); return sendDelete(url, sdncModifierDetails.getUserId(), additionalHeaders); @@ -729,12 +728,12 @@ public class ArtifactRestUtils extends BaseRestUtils { private static RestResponse uploadInformationalArtifact(ArtifactReqDetails artifactDetails, User sdncModifierDetails, String checksum, String url) throws IOException { Map additionalHeaders = null; if (checksum != null && !checksum.isEmpty()) { - additionalHeaders = new HashMap(); + additionalHeaders = new HashMap<>(); additionalHeaders.put(HttpHeaderEnum.Content_MD5.getValue(), checksum); } additionalHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader); - additionalHeaders.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci"); + additionalHeaders.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId); Gson gson = new Gson(); // System.out.println("ArtifactDetails: "+ jsonBody); @@ -749,10 +748,10 @@ public class ArtifactRestUtils extends BaseRestUtils { } private static RestResponse addArtifactToInstance(ArtifactReqDetails artifactDetails, User sdncModifierDetails, String checksum, String url) throws IOException { - Map additionalHeaders = null; - additionalHeaders = new HashMap(); + Map additionalHeaders; + additionalHeaders = new HashMap<>(); if (checksum != null && !checksum.isEmpty()) { - additionalHeaders = new HashMap(); + additionalHeaders = new HashMap<>(); additionalHeaders.put(HttpHeaderEnum.Content_MD5.getValue(), checksum); } additionalHeaders.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json, text/plain, */*"); @@ -769,8 +768,8 @@ public class ArtifactRestUtils extends BaseRestUtils { } private static RestResponse updateDeploymentArtifact(ArtifactDefinition artifactDefinition, User sdncModifierDetails, String url) throws IOException { - Map additionalHeaders = null; - additionalHeaders = new HashMap(); + Map additionalHeaders; + additionalHeaders = new HashMap<>(); additionalHeaders.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json, text/plain, */*"); additionalHeaders.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json;charset=UTF-8"); @@ -782,9 +781,9 @@ public class ArtifactRestUtils extends BaseRestUtils { } private static RestResponse updateDeploymentArtifact(ArtifactReqDetails artifactDetails, User sdncModifierDetails, String url) throws IOException { - Map additionalHeaders = null; + Map additionalHeaders; - additionalHeaders = new HashMap(); + additionalHeaders = new HashMap<>(); additionalHeaders.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json, text/plain, */*"); additionalHeaders.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json;charset=UTF-8"); // additionalHeaders.put(HttpHeaderEnum..getValue(), "application/json;charset=UTF-8"); @@ -805,7 +804,7 @@ public class ArtifactRestUtils extends BaseRestUtils { private static RestResponse downloadArtifact(String url, User user, Map addionalHeaders,boolean addEcompHeader) throws IOException { if(addEcompHeader){ - addionalHeaders.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), ecomp); + addionalHeaders.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId); } return downloadArtifact(url, user, addionalHeaders, acceptOctetStream); } @@ -906,29 +905,5 @@ public class ArtifactRestUtils extends BaseRestUtils { } - - public static ArtifactDefinition getArtifactDataFromJson(String json) { - Gson gson = new Gson(); - JsonObject jsonElement = new JsonObject(); - jsonElement = gson.fromJson(json, jsonElement.getClass()); - ArtifactDefinition artifact = new ArtifactDefinition(); - String payload = null; - JsonElement artifactPayload = jsonElement.get(Constants.ARTIFACT_PAYLOAD_DATA); - if (artifactPayload != null && !artifactPayload.isJsonNull()) { - payload = artifactPayload.getAsString(); - } - jsonElement.remove(Constants.ARTIFACT_PAYLOAD_DATA); - artifact = gson.fromJson(jsonElement, ArtifactDefinition.class); - artifact.setPayloadData(payload); - - /*atifact.setArtifactName(UPLOAD_ARTIFACT_NAME); -artifact.setArtifactDisplayName("configure"); -artifact.setArtifactType("SHELL"); -artifact.setMandatory(false); -artifact.setDescription("ff"); -artifact.setPayloadData(UPLOAD_ARTIFACT_PAYLOAD); -artifact.setArtifactLabel("configure");*/ - return artifact; - } } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AssetRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AssetRestUtils.java index 4ade9eb16c..13cfb8fb63 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AssetRestUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AssetRestUtils.java @@ -31,7 +31,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.UUID; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; @@ -39,7 +38,7 @@ import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; -import org.codehaus.jackson.map.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectMapper; import org.openecomp.sdc.be.datatypes.enums.AssetTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; @@ -78,8 +77,6 @@ public class AssetRestUtils extends BaseRestUtils { static ObjectMapper objectMapper = new ObjectMapper(); static Logger logger = LoggerFactory.getLogger(AssetRestUtils.class.getName()); - static final String contentTypeHeaderData = "application/json"; - static final String acceptHeaderDate = "application/json"; static final String basicAuthentication = "Basic Y2k6MTIzNDU2"; // /sdc/v1/catalog/{services/resources}/{componentUUID}/artifacts/{artifactUUID} static final String COMPONENT_ARTIFACT_URL = "/sdc/v1/catalog/%s/%s/artifacts/%s"; @@ -93,7 +90,7 @@ public class AssetRestUtils extends BaseRestUtils { assetType.getValue(), uuid); HttpGet httpGet = new HttpGet(url); - httpGet.addHeader(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci"); + httpGet.addHeader(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId); httpGet.addHeader(HttpHeaderEnum.AUTHORIZATION.getValue(), basicAuthentication); logger.debug("Send GET request to get Tosca model: {}", url); @@ -101,18 +98,27 @@ public class AssetRestUtils extends BaseRestUtils { return httpclient.execute(httpGet); } + public static File getToscaModelCsarFile(AssetTypeEnum assetType, String uuid) throws IOException { + return getToscaModelCsarFile(assetType, uuid, ""); + } + public static File getToscaModelCsarFile(AssetTypeEnum assetType, String uuid, String fileName) throws IOException { + File myFile; Config config = Utils.getConfig(); CloseableHttpClient httpclient = HttpClients.createDefault(); String url = String.format(Urls.GET_TOSCA_MODEL, config.getCatalogBeHost(), config.getCatalogBePort(), assetType.getValue(), uuid); HttpGet httpGet = new HttpGet(url); - - String csarDir = FileHandling.getCreateDirByName("outputCsar"); - File myFile = new File(csarDir+ File.separator + "tmpCSAR_" + fileName + ".csar"); + + if(fileName.isEmpty()) { + myFile = new File("tmpCSAR"); + } else { + String csarDir = FileHandling.getCreateDirByName("outputCsar"); + myFile = new File(csarDir+ File.separator + "tmpCSAR_" + fileName + ".csar"); + } - httpGet.addHeader(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci"); + httpGet.addHeader(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId); httpGet.addHeader(HttpHeaderEnum.AUTHORIZATION.getValue(), basicAuthentication); logger.debug("Send GET request to get Tosca model: {}", url); @@ -127,19 +133,17 @@ public class AssetRestUtils extends BaseRestUtils { } return myFile; } - - - + public static RestResponse getRestResponseComponentToscaModel(AssetTypeEnum assetType, String uuid) throws IOException { Config config = Utils.getConfig(); String url = String.format(Urls.GET_TOSCA_MODEL, config.getCatalogBeHost(), config.getCatalogBePort(), assetType.getValue(), uuid); - Map headersMap = new HashMap(); + Map headersMap = new HashMap<>(); headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader); - headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci"); + headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId); HttpRequest http = new HttpRequest(); @@ -158,16 +162,16 @@ public class AssetRestUtils extends BaseRestUtils { public static RestResponse getComponentListByAssetType(boolean isBasicAuthentication, AssetTypeEnum assetType, String... filterArrayString) throws IOException { Config config = Utils.getConfig(); - Map headersMap = new HashMap(); - headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); - headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate); + Map headersMap = new HashMap<>(); + headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData); + headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData); if (isBasicAuthentication) { headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), basicAuthentication); } - headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci"); + headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId); HttpRequest http = new HttpRequest(); - String url = String.format(Urls.GET_ASSET_LIST, config.getCatalogBeHost(), config.getCatalogBePort(), + String url = String.format(Urls.GET_ASSET_LIST, config.getCatalogBeHost(), config.getCatalogBePort(), assetType.getValue()); if (filterArrayString != null && filterArrayString.length > 0) { url = buildUrlWithFilter(url, filterArrayString); @@ -180,11 +184,11 @@ public class AssetRestUtils extends BaseRestUtils { public static RestResponse getFilteredComponentList(AssetTypeEnum assetType, String query) throws IOException { Config config = Utils.getConfig(); - Map headersMap = new HashMap(); - headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); - headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate); + Map headersMap = new HashMap<>(); + headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData); + headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData); headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), basicAuthentication); - headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci"); + headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId); HttpRequest http = new HttpRequest(); @@ -217,13 +221,13 @@ public class AssetRestUtils extends BaseRestUtils { AssetTypeEnum assetType, String uuid) throws IOException { Config config = Utils.getConfig(); - Map headersMap = new HashMap(); - headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); - headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate); + Map headersMap = new HashMap<>(); + headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData); + headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData); if (isBasicAuthentication) { headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), basicAuthentication); } - headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci"); + headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId); HttpRequest http = new HttpRequest(); String url = String.format(Urls.GET_ASSET_METADATA, config.getCatalogBeHost(), config.getCatalogBePort(), @@ -628,8 +632,5 @@ public class AssetRestUtils extends BaseRestUtils { } return null; } - private static String getShortUUID() { - return UUID.randomUUID().toString().split("-")[0]; - } } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AutomationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AutomationUtils.java index 2e27907fb5..65ab6c920a 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AutomationUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AutomationUtils.java @@ -61,11 +61,19 @@ public class AutomationUtils extends BaseRestUtils { - public static void createVersionsInfoFile(String filepath, String onboardVersion, String osVersion, String envData, String suiteName) - throws FileNotFoundException, IOException { + public static void createVersionsInfoFile(String filepath, String onboardVersion, String osVersion, String envData, String suiteName) throws IOException { + File myFoo = new File(filepath); + FileOutputStream fooStream = new FileOutputStream(myFoo, false); // true to append + String versions = ("onboardVersion=\""+ onboardVersion+ "\"\n" + "osVersion=\"" + osVersion + "\"\n" + "env=\""+ envData + "\"\n" + "suiteName=\""+ suiteName+ "\"\n"); + byte[] myBytes = versions.getBytes(); + fooStream.write(myBytes); + fooStream.close(); + } + + public static void createVersionsInfoFile(String filepath, String onboardVersion, String osVersion, String envData, String suiteName, String reportStartTime) throws IOException { File myFoo = new File(filepath); FileOutputStream fooStream = new FileOutputStream(myFoo, false); // true to append - String versions = ("onboardVesrion=\""+ onboardVersion+ "\"\n" + "osVersion=\"" + osVersion + "\"\n" + "env=\""+ envData + "\"\n" + "suiteName=\""+ suiteName+ "\"\n"); + String versions = ("onboardVersion=\""+ onboardVersion+ "\"\n" + "osVersion=\"" + osVersion + "\"\n" + "env=\""+ envData + "\"\n" + "suiteName=\""+ suiteName+ "\"\n" + "reportStartTime=\""+ reportStartTime+ "\"\n"); byte[] myBytes = versions.getBytes(); fooStream.write(myBytes); fooStream.close(); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/BaseRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/BaseRestUtils.java index 4ea404784a..4ec0353abd 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/BaseRestUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/BaseRestUtils.java @@ -45,10 +45,13 @@ public class BaseRestUtils extends BaseValidationUtils { public static final String acceptHeaderData = "application/json"; public static final String acceptJsonHeader = "application/json"; public static final String acceptOctetHeader = "application/octet-stream"; + public static final String acceptMultipartHeader = "application/octet-stream"; public static final String authorizationHeader = "Basic " + Base64.encodeBase64String("ci:123456".getBytes()); public static final String acceptOctetStream = "application/octet-stream"; public static final String ecomp = "ecomp"; public static final String authorizationPrefixString = "Basic "; + public static final String xEcompInstanceId = "a1bd39f6-d55e-45b2-9207-156216af5cb5"; + public static final String cacheControlHeader = "no-cache"; public static final String RESOURCE_COMPONENT_TYPE = "resources"; public static final String PRODUCT_COMPONENT_TYPE = "products"; @@ -86,7 +89,7 @@ public class BaseRestUtils extends BaseValidationUtils { } protected static Map prepareHeadersMap(String userId, String accept) { - Map headersMap = new HashMap(); + Map headersMap = new HashMap<>(); if (contentTypeHeaderData != null) { headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); } @@ -257,7 +260,7 @@ public class BaseRestUtils extends BaseValidationUtils { String userCredentials = userName + ":" + password; encodeBase64 = Base64.encodeBase64(userCredentials.getBytes()); String encodedUserCredentials = authorizationPrefixString + new String(encodeBase64); - Map authorizationHeader = new HashMap(); + Map authorizationHeader = new HashMap<>(); authorizationHeader.put(HttpHeaderEnum.AUTHORIZATION.getValue(), encodedUserCredentials); return authorizationHeader; } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CatalogRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CatalogRestUtils.java index 449b6beca5..b09ba10df1 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CatalogRestUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CatalogRestUtils.java @@ -67,7 +67,7 @@ public class CatalogRestUtils extends BaseRestUtils { String url = String.format(Urls.GET_ALL_CATEGORIES_FE, config.getCatalogFeHost(), config.getCatalogFePort(), BaseRestUtils.RESOURCE_COMPONENT_TYPE); - Map additionalHeaders = new HashMap(); + Map additionalHeaders = new HashMap<>(); additionalHeaders.put(HttpHeaderEnum.X_ECOMP_REQUEST_ID_HEADER.getValue(), uuid); return sendGet(url, UserRoleEnum.DESIGNER.getUserId(), additionalHeaders); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ComponentInstanceRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ComponentInstanceRestUtils.java index 1b550e4fff..64b576e3e2 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ComponentInstanceRestUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ComponentInstanceRestUtils.java @@ -43,7 +43,7 @@ import org.openecomp.sdc.ci.tests.utils.Utils; import com.google.gson.Gson; public class ComponentInstanceRestUtils extends BaseRestUtils { - public static String acceptHeaderDate = "application/json"; +// public static String acceptHeaderDate = "application/json"; static Config config = Config.instance(); public static Gson gson = new Gson(); @@ -87,7 +87,7 @@ public class ComponentInstanceRestUtils extends BaseRestUtils { Config config = Utils.getConfig(); - Map headersMap = new HashMap(); + Map headersMap = new HashMap<>(); headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderData); headersMap.put(HttpHeaderEnum.USER_ID.getValue(), user.getUserId()); @@ -207,7 +207,7 @@ public class ComponentInstanceRestUtils extends BaseRestUtils { Config config = Utils.getConfig(); - Map headersMap = new HashMap(); + Map headersMap = new HashMap<>(); headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderData); headersMap.put(HttpHeaderEnum.USER_ID.getValue(), user.getUserId()); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ConsumerRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ConsumerRestUtils.java index 0aadfdbaeb..5e35327305 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ConsumerRestUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ConsumerRestUtils.java @@ -20,12 +20,9 @@ package org.openecomp.sdc.ci.tests.utils.rest; -import static org.testng.AssertJUnit.assertEquals; - -import java.util.Map; - -import org.codehaus.jackson.map.DeserializationConfig; -import org.codehaus.jackson.map.ObjectMapper; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.Gson; import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition; import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.ci.tests.api.Urls; @@ -34,7 +31,9 @@ import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.Utils; -import com.google.gson.Gson; +import java.util.Map; + +import static org.testng.AssertJUnit.assertEquals; public class ConsumerRestUtils extends BaseRestUtils { @@ -123,9 +122,8 @@ public class ConsumerRestUtils extends BaseRestUtils { String bodyToParse = restResponse.getResponse(); ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); try { - mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); ConsumerDataDefinition component = mapper.readValue(bodyToParse, ConsumerDataDefinition.class); return component; } catch (Exception e) { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/EcompUserRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/EcompUserRestUtils.java index 458aa4a91c..9fdab02bb1 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/EcompUserRestUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/EcompUserRestUtils.java @@ -44,8 +44,6 @@ public class EcompUserRestUtils extends BaseRestUtils { static Gson gson = new Gson(); static Logger logger = LoggerFactory.getLogger(EcompUserRestUtils.class.getName()); - static String contentTypeHeaderData = "application/json"; - static String acceptHeaderDate = "application/json"; static String ecompUsername = "12345"; static String ecompPassword = "12345"; @@ -58,9 +56,9 @@ public class EcompUserRestUtils extends BaseRestUtils { public static RestResponse pushUser(EcompUser ecompUser) throws IOException { Config config = Utils.getConfig(); - Map headersMap = new HashMap(); - headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); - headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate); + Map headersMap = new HashMap<>(); + headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData); + headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData); headersMap.put(HttpHeaderEnum.ECOMP_USERNAME.getValue(), ecompUsername); headersMap.put(HttpHeaderEnum.ECOMP_PASSWORD.getValue(), ecompPassword); @@ -84,9 +82,9 @@ public class EcompUserRestUtils extends BaseRestUtils { public static RestResponse editUser(String loginId, EcompUser ecompUser) throws IOException { Config config = Utils.getConfig(); - Map headersMap = new HashMap(); - headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); - headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate); + Map headersMap = new HashMap<>(); + headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData); + headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData); headersMap.put(HttpHeaderEnum.ECOMP_USERNAME.getValue(), ecompUsername); headersMap.put(HttpHeaderEnum.ECOMP_PASSWORD.getValue(), ecompPassword); @@ -110,9 +108,9 @@ public class EcompUserRestUtils extends BaseRestUtils { public static RestResponse getUser(String loginId) throws IOException { Config config = Utils.getConfig(); - Map headersMap = new HashMap(); - headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); - headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate); + Map headersMap = new HashMap<>(); + headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData); + headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData); headersMap.put(HttpHeaderEnum.ECOMP_USERNAME.getValue(), ecompUsername); headersMap.put(HttpHeaderEnum.ECOMP_PASSWORD.getValue(), ecompPassword); @@ -130,9 +128,9 @@ public class EcompUserRestUtils extends BaseRestUtils { public static RestResponse getAllUsers() throws IOException { Config config = Utils.getConfig(); - Map headersMap = new HashMap(); - headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); - headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate); + Map headersMap = new HashMap<>(); + headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData); + headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData); headersMap.put(HttpHeaderEnum.ECOMP_USERNAME.getValue(), ecompUsername); headersMap.put(HttpHeaderEnum.ECOMP_PASSWORD.getValue(), ecompPassword); @@ -150,9 +148,9 @@ public class EcompUserRestUtils extends BaseRestUtils { public static RestResponse getAllAvailableRoles() throws IOException { Config config = Utils.getConfig(); - Map headersMap = new HashMap(); - headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); - headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate); + Map headersMap = new HashMap<>(); + headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData); + headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData); headersMap.put(HttpHeaderEnum.ECOMP_USERNAME.getValue(), ecompUsername); headersMap.put(HttpHeaderEnum.ECOMP_PASSWORD.getValue(), ecompPassword); @@ -174,9 +172,9 @@ public class EcompUserRestUtils extends BaseRestUtils { public static RestResponse pushUserRoles(String loginId, List roles) throws IOException { Config config = Utils.getConfig(); - Map headersMap = new HashMap(); - headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); - headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate); + Map headersMap = new HashMap<>(); + headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData); + headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData); headersMap.put(HttpHeaderEnum.ECOMP_USERNAME.getValue(), ecompUsername); headersMap.put(HttpHeaderEnum.ECOMP_PASSWORD.getValue(), ecompPassword); @@ -204,9 +202,9 @@ public class EcompUserRestUtils extends BaseRestUtils { public static RestResponse getUserRoles(String loginId) throws IOException { Config config = Utils.getConfig(); - Map headersMap = new HashMap(); - headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); - headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate); + Map headersMap = new HashMap<>(); + headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData); + headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData); headersMap.put(HttpHeaderEnum.ECOMP_USERNAME.getValue(), ecompUsername); headersMap.put(HttpHeaderEnum.ECOMP_PASSWORD.getValue(), ecompPassword); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/GroupRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/GroupRestUtils.java index d79c8e002c..f55cdbd035 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/GroupRestUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/GroupRestUtils.java @@ -36,7 +36,6 @@ import org.openecomp.sdc.ci.tests.utils.Utils; import com.google.gson.Gson; public class GroupRestUtils extends BaseRestUtils { - public static String acceptHeaderDate = "application/json"; static Config config = Config.instance(); public static Gson gson = new Gson(); @@ -44,7 +43,7 @@ public class GroupRestUtils extends BaseRestUtils { Config config = Utils.getConfig(); - Map headersMap = new HashMap(); + Map headersMap = new HashMap<>(); headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderData); headersMap.put(HttpHeaderEnum.USER_ID.getValue(), user.getUserId()); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ImportRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ImportRestUtils.java index 0be438470d..40dc060993 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ImportRestUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ImportRestUtils.java @@ -48,7 +48,6 @@ import org.apache.http.entity.mime.content.StringBody; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.codehaus.jettison.json.JSONException; -import org.openecomp.sdc.be.dao.rest.HttpRestClient; import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.ci.tests.api.Urls; import org.openecomp.sdc.ci.tests.config.Config; @@ -61,7 +60,7 @@ import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.Utils; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; -import org.openecomp.sdc.common.rest.api.RestResponseAsByteArray; +import org.openecomp.sdc.common.http.client.api.HttpResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -351,7 +350,7 @@ public class ImportRestUtils extends BaseRestUtils { } } - public static RestResponseAsByteArray getCsar(String csarUid, User sdncModifierDetails) throws Exception { + public static HttpResponse getCsar(String csarUid, User sdncModifierDetails) throws Exception { Config config = Utils.getConfig(); String url = String.format(Urls.GET_CSAR_USING_SIMULATOR, config.getCatalogBeHost(), config.getCatalogBePort(), @@ -367,17 +366,11 @@ public class ImportRestUtils extends BaseRestUtils { // System.out.println(url); // System.out.println(userBodyJson); - HttpRestClient httpRestClient = new HttpRestClient(); - for (Map.Entry mapEntry : headersMap.entrySet()) { downloadCsarHeaders.put(mapEntry.getKey(), mapEntry.getValue()); } - RestResponseAsByteArray doGetAsByteArray = httpRestClient.doGetAsByteArray(url, downloadCsarHeaders); - // RestResponse getCsar = http.httpSendGet(url, headersMap); - - return doGetAsByteArray; - + return org.openecomp.sdc.common.http.client.api.HttpRequest.getAsByteArray(url, downloadCsarHeaders); } private static File getGroupTypeZipFile(String elementName) throws IOException { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/LifecycleRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/LifecycleRestUtils.java index 39afff9022..9c0b7a89e0 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/LifecycleRestUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/LifecycleRestUtils.java @@ -111,10 +111,10 @@ public class LifecycleRestUtils extends BaseRestUtils { Config config = Utils.getConfig(); String url = String.format(Urls.POST_EXTERNAL_API_CHANGE_LIFE_CYCLE_OF_ASSET, config.getCatalogBeHost(), config.getCatalogBePort(), assetTypeEnum.getValue(), assetUUID, lifeCycleStatesEnum.getState()); - Map additionalHeaders = new HashMap(); + Map additionalHeaders = new HashMap<>(); additionalHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader); - additionalHeaders.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci"); + additionalHeaders.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId); String jsonBody = "{\"userRemarks\": \"" + comment + "\"}"; @@ -361,7 +361,7 @@ public class LifecycleRestUtils extends BaseRestUtils { } private static Map prepareHeadersMap(User sdncModifierDetails) { - Map headersMap = new HashMap(); + Map headersMap = new HashMap<>(); headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderData); headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId()); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/PropertyRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/PropertyRestUtils.java index 33704a5128..d507c2cb23 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/PropertyRestUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/PropertyRestUtils.java @@ -20,32 +20,28 @@ package org.openecomp.sdc.ci.tests.utils.rest; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - +import com.google.gson.Gson; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.ComponentInstance; -import org.openecomp.sdc.be.model.ComponentInstanceInput; -import org.openecomp.sdc.be.model.ComponentInstanceProperty; -import org.openecomp.sdc.be.model.PropertyDefinition; -import org.openecomp.sdc.be.model.Resource; -import org.openecomp.sdc.be.model.Service; -import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.model.*; import org.openecomp.sdc.ci.tests.api.Urls; import org.openecomp.sdc.ci.tests.config.Config; +import org.openecomp.sdc.ci.tests.datatypes.PropertyObject; +import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum; import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum; import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest; +import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.common.util.GeneralUtility; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.openecomp.sdc.ci.tests.datatypes.PropertyObject; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.testng.AssertJUnit.*; import com.google.gson.Gson; @@ -69,6 +65,14 @@ public class PropertyRestUtils extends BaseRestUtils { return sendPut(url, body, user.getUserId(), acceptHeaderData); } + public static RestResponse updateGroupProperty(Component component, String groupId, String body, User user) + throws Exception { + Config config = Config.instance(); + + String url = String.format(Urls.RESOURCE_GROUP_PROPERTY, config.getCatalogBeHost(), config.getCatalogBePort(), component.getUniqueId(), groupId); + return sendPut(url, body, user.getUserId(), acceptHeaderData); + } + public static RestResponse getProperty(String resourceId, String propertyId, User user) throws Exception { Config config = Config.instance(); String url = String.format(Urls.GET_PROPERTY, config.getCatalogBeHost(), config.getCatalogBePort(), resourceId, @@ -337,4 +341,24 @@ public class PropertyRestUtils extends BaseRestUtils { } return declareProportiesResponse; } + + public static RestResponse updateInput(Component componentObject, PropertyObject componentInput, User sdncModifierDetails) + throws Exception { + Config config = Config.instance(); + String url = String.format(Urls.UPDATE_INPUT, config.getCatalogBeHost(), config.getCatalogBePort(), componentObject.getUniqueId()); + String userId = sdncModifierDetails.getUserId(); + Map headersMap = prepareHeadersMap(userId); + Gson gson = new Gson(); + String userBodyJson = gson.toJson(componentInput); + String calculateMD5 = GeneralUtility.calculateMD5Base64EncodedByString(userBodyJson); + headersMap.put(HttpHeaderEnum.Content_MD5.getValue(), calculateMD5); + HttpRequest http = new HttpRequest(); + // System.out.println(url); + // System.out.println(userBodyJson); + RestResponse declareProportiesResponse = http.httpSendPost(url, userBodyJson, headersMap); + if (declareProportiesResponse.getErrorCode() == STATUS_CODE_GET_SUCCESS) { + + } + return declareProportiesResponse; + } } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java index 2f33273319..5f8eeca911 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java @@ -113,15 +113,12 @@ public class ResourceRestUtils extends BaseRestUtils { Gson gson = new Gson(); String resourceImportBodyJson = gson.toJson(importReqDetails); HttpRequest http = new HttpRequest(); - // System.out.println(url); - // System.out.println(resourceImportBodyJson); Map headersMap = prepareHeadersMap(userId); if (additionalHeaders != null) { headersMap.putAll(additionalHeaders); } else { - headersMap.put(HttpHeaderEnum.Content_MD5.getValue(), - ArtifactRestUtils.calculateMD5(resourceImportBodyJson)); + headersMap.put(HttpHeaderEnum.Content_MD5.getValue(), ArtifactRestUtils.calculateMD5(resourceImportBodyJson)); } RestResponse createResourceResponse = http.httpSendPost(url, resourceImportBodyJson, headersMap); @@ -272,7 +269,7 @@ public class ResourceRestUtils extends BaseRestUtils { Map headersMap = prepareHeadersMap(sdncModifierDetails.getUserId()); headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader); - headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci"); + headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId); return sendGet(url, sdncModifierDetails.getUserId(), headersMap); @@ -285,7 +282,7 @@ public class ResourceRestUtils extends BaseRestUtils { Map headersMap = prepareHeadersMap(sdncModifierDetails.getUserId()); headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader); - headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci"); + headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId); return sendGet(url, sdncModifierDetails.getUserId(), headersMap); @@ -298,7 +295,7 @@ public class ResourceRestUtils extends BaseRestUtils { Map headersMap = prepareHeadersMap(sdncModifierDetails.getUserId()); headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader); - headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci"); + headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId); return sendGet(url, sdncModifierDetails.getUserId(), headersMap); @@ -359,9 +356,9 @@ public class ResourceRestUtils extends BaseRestUtils { HttpRequest http = new HttpRequest(); String url = String.format(Urls.GET_PROPERTY_SCOPES_LIST, config.getCatalogBeHost(), config.getCatalogBePort()); - Map headersMap = new HashMap(); - headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json"); - headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json"); + Map headersMap = new HashMap<>(); + headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData); + headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData); headersMap.put(HttpHeaderEnum.USER_ID.getValue(), "cs0008"); return http.httpSendGet(url, headersMap); @@ -374,10 +371,10 @@ public class ResourceRestUtils extends BaseRestUtils { HttpRequest http = new HttpRequest(); String url = String.format(Urls.GET_ALL_ARTIFACTS, config.getCatalogBeHost(), config.getCatalogBePort()); - Map headersMap = new HashMap(); + Map headersMap = new HashMap<>(); - headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json"); - headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json"); + headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), acceptJsonHeader); + headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptJsonHeader); headersMap.put(HttpHeaderEnum.USER_ID.getValue(), "cs0008"); return http.httpSendGet(url, headersMap); @@ -390,9 +387,9 @@ public class ResourceRestUtils extends BaseRestUtils { HttpRequest http = new HttpRequest(); String url = String.format(Urls.GET_CONFIGURATION, config.getCatalogBeHost(), config.getCatalogBePort()); - Map headersMap = new HashMap(); - headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json"); - headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json"); + Map headersMap = new HashMap<>(); + headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), acceptJsonHeader); + headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptJsonHeader); headersMap.put(HttpHeaderEnum.USER_ID.getValue(), "cs0008"); return http.httpSendGet(url, headersMap); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtilsExternalAPI.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtilsExternalAPI.java index d9b8ec3d4b..76d2ededfc 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtilsExternalAPI.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtilsExternalAPI.java @@ -50,7 +50,7 @@ public class ResourceRestUtilsExternalAPI extends BaseRestUtils { String calculateMD5 = GeneralUtility.calculateMD5Base64EncodedByString(userBodyJson); headersMap.put(HttpHeaderEnum.Content_MD5.getValue(), calculateMD5); headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader); - headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci"); + headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId); headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId()); HttpRequest http = new HttpRequest(); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java index 6f83ec9d52..d78a6c9026 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java @@ -20,22 +20,16 @@ package org.openecomp.sdc.ci.tests.utils.rest; -import java.io.IOException; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import org.apache.commons.codec.binary.Base64; import org.apache.log4j.Logger; -import org.codehaus.jackson.Version; -import org.codehaus.jackson.map.DeserializationConfig; -import org.codehaus.jackson.map.JsonDeserializer; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.map.module.SimpleModule; import org.json.JSONArray; import org.json.JSONException; import org.json.simple.JSONObject; @@ -44,12 +38,13 @@ import org.openecomp.sdc.be.model.ArtifactDefinition; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.ComponentInstanceProperty; +import org.openecomp.sdc.be.model.GroupDefinition; import org.openecomp.sdc.be.model.Product; import org.openecomp.sdc.be.model.PropertyConstraint; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.category.CategoryDefinition; -import org.openecomp.sdc.be.model.operations.impl.PropertyOperation.PropertyConstraintJacksonDeserialiser; +import org.openecomp.sdc.be.model.operations.impl.PropertyOperation.PropertyConstraintJacksonDeserializer; import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails; import org.openecomp.sdc.ci.tests.datatypes.ResourceAssetStructure; import org.openecomp.sdc.ci.tests.datatypes.ResourceRespJavaObject; @@ -57,11 +52,16 @@ import org.openecomp.sdc.ci.tests.datatypes.ServiceDistributionStatus; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.Utils; -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; +import java.io.IOException; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.List; +import java.util.Map; public class ResponseParser { @@ -104,16 +104,25 @@ public class ResponseParser { public static String getValueFromJsonResponse(String response, String fieldName) { try { - JSONObject jsonResp = (JSONObject) JSONValue.parse(response); - Object fieldValue = jsonResp.get(fieldName); - return fieldValue.toString(); +// JSONObject jsonResp = (JSONObject) JSONValue.parse(response); + String[] split = fieldName.split(":"); + String fieldValue = response; + for(int i=0; i map = new HashMap(); + Map map = new HashMap<>(); ResourceRespJavaObject jsonToJavaObject = new ResourceRespJavaObject(); for (int counter = 0; counter < arrayOfObjects.size(); counter++) { @@ -169,19 +178,19 @@ public class ResponseParser { } - public static Resource convertResourceResponseToJavaObject(String response) { - - ObjectMapper mapper = new ObjectMapper(); - final SimpleModule module = new SimpleModule("customerSerializationModule", - new Version(1, 0, 0, "static version")); - JsonDeserializer deserializer = new PropertyConstraintJacksonDeserialiser(); - addDeserializer(module, PropertyConstraint.class, deserializer); + private static ObjectMapper newObjectMapper() { + SimpleModule module = new SimpleModule("customDeserializationModule"); + module.addDeserializer(PropertyConstraint.class, new PropertyConstraintJacksonDeserializer()); + return new ObjectMapper() + .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .registerModule(module); + } - mapper.registerModule(module); + public static Resource convertResourceResponseToJavaObject(String response) { + ObjectMapper mapper = newObjectMapper(); Resource resource = null; try { -// TODO Andrey L. uncomment line below in case to ignore on unknown properties, not recommended - mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); resource = mapper.readValue(response, Resource.class); logger.debug(resource.toString()); @@ -199,15 +208,9 @@ public class ResponseParser { public static ComponentInstanceProperty convertPropertyResponseToJavaObject(String response) { - ObjectMapper mapper = new ObjectMapper(); - final SimpleModule module = new SimpleModule("customerSerializationModule", new Version(1, 0, 0, "static version")); - JsonDeserializer desrializer = new PropertyConstraintJacksonDeserialiser(); - addDeserializer(module, PropertyConstraint.class, desrializer); - - mapper.registerModule(module); + ObjectMapper mapper = newObjectMapper(); ComponentInstanceProperty propertyDefinition = null; try { - mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); propertyDefinition = mapper.readValue(response, ComponentInstanceProperty.class); logger.debug(propertyDefinition.toString()); } catch (IOException e) { @@ -216,6 +219,19 @@ public class ResponseParser { return propertyDefinition; } + public static GroupDefinition convertPropertyResponseToObject(String response) { + + ObjectMapper mapper = newObjectMapper(); + GroupDefinition groupDefinition = null; + try { + groupDefinition = mapper.readValue(response, GroupDefinition.class); + logger.debug(groupDefinition.toString()); + } catch (IOException e) { + e.printStackTrace(); + } + return groupDefinition; + } + public static String toJson(Object object) { Gson gson = new Gson(); return gson.toJson(object); @@ -225,7 +241,7 @@ public class ResponseParser { ObjectMapper mapper = new ObjectMapper(); ArtifactDefinition artifactDefinition = null; try { - mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); artifactDefinition = mapper.readValue(response, ArtifactDefinition.class); logger.debug(artifactDefinition.toString()); } catch (IOException e) { @@ -257,18 +273,10 @@ public class ResponseParser { public static T parseToObjectUsingMapper(String json, Class clazz) { // Generic convert - ObjectMapper mapper = new ObjectMapper(); + ObjectMapper mapper = newObjectMapper(); T object = null; - final SimpleModule module = new SimpleModule("customerSerializationModule", - new Version(1, 0, 0, "static version")); - JsonDeserializer desrializer = new PropertyConstraintJacksonDeserialiser(); - addDeserializer(module, PropertyConstraint.class, desrializer); - mapper.registerModule(module); - mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); try { object = mapper.readValue(json, clazz); - // System.out.println("Class: "+clazz.getSimpleName()+", json: - // "+json); } catch (IOException e) { e.printStackTrace(); } @@ -286,25 +294,11 @@ public class ResponseParser { return artifactReqDetails; } - public static void addDeserializer(SimpleModule module, Class clazz, - final JsonDeserializer deserializer) { - module.addDeserializer(clazz, deserializer); - } - public static Service convertServiceResponseToJavaObject(String response) { - ObjectMapper mapper = new ObjectMapper(); - final SimpleModule module = new SimpleModule("customerSerializationModule", - new Version(1, 0, 0, "static version")); - JsonDeserializer deserializer = new PropertyConstraintJacksonDeserialiser(); - addDeserializer(module, PropertyConstraint.class, deserializer); - - mapper.registerModule(module); + ObjectMapper mapper = newObjectMapper(); Service service = null; try { -// TODO Andrey L. uncomment line below in case to ignore on unknown properties, not recommended, added by Matvey - mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); - service = mapper.readValue(response, Service.class); logger.debug(service.toString()); } catch (IOException e) { @@ -316,18 +310,9 @@ public class ResponseParser { public static Product convertProductResponseToJavaObject(String response) { - ObjectMapper mapper = new ObjectMapper(); - - final SimpleModule module = new SimpleModule("customerSerializationModule", - new Version(1, 0, 0, "static version")); - JsonDeserializer desrializer = new PropertyConstraintJacksonDeserialiser(); - addDeserializer(module, PropertyConstraint.class, desrializer); - - mapper.registerModule(module); - + ObjectMapper mapper = newObjectMapper(); Product product = null; try { - mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); product = mapper.readValue(response, Product.class); logger.debug(product.toString()); } catch (IOException e) { @@ -339,16 +324,9 @@ public class ResponseParser { public static ComponentInstance convertComponentInstanceResponseToJavaObject(String response) { - ObjectMapper mapper = new ObjectMapper(); - final SimpleModule module = new SimpleModule("customerSerializationModule", - new Version(1, 0, 0, "static version")); - JsonDeserializer desrializer = new PropertyConstraintJacksonDeserialiser(); - addDeserializer(module, PropertyConstraint.class, desrializer); - - mapper.registerModule(module); + ObjectMapper mapper = newObjectMapper(); ComponentInstance componentInstance = null; try { - mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); componentInstance = mapper.readValue(response, ComponentInstance.class); logger.debug(componentInstance.toString()); } catch (IOException e) { @@ -360,7 +338,7 @@ public class ResponseParser { } public static List getValuesFromJsonArray(RestResponse message) throws Exception { - List artifactTypesArrayFromApi = new ArrayList(); + List artifactTypesArrayFromApi = new ArrayList<>(); org.json.JSONObject responseObject = new org.json.JSONObject(message.getResponse()); JSONArray jArr = responseObject.getJSONArray("artifactTypes"); @@ -392,7 +370,7 @@ public class ResponseParser { } public static List> getAuditFromMessage(Map auditingMessage) { - List> auditList = new ArrayList>(); + List> auditList = new ArrayList<>(); auditList.add(auditingMessage); return auditList; } @@ -425,8 +403,8 @@ public class ResponseParser { } public static List getDerivedListFromJson(RestResponse res) throws JSONException { - JSONArray listFromJson = getListFromJson(res, "derivedList"); - List lst = new ArrayList(); + JSONArray listFromJson = getListFromJson(res, "derivedFrom"); + List lst = new ArrayList<>(); for (int i = 0; i < listFromJson.length(); i++) { lst.add(listFromJson.getString(i)); } @@ -440,7 +418,7 @@ public class ResponseParser { } public static List> getListOfMapsFromJson(RestResponse res, String field) throws Exception { - List> list = new ArrayList>(); + List> list = new ArrayList<>(); JSONArray listFromJson = getListFromJson(res, field); for (int i = 0; i < listFromJson.length(); i++) { Map convertStringToMap = convertStringToMap(listFromJson.getString(i)); @@ -472,7 +450,7 @@ public class ResponseParser { // Map> map = new HashMap>(); - Map> map = new HashMap>(); + Map> map = new HashMap<>(); JsonElement jElement = new JsonParser().parse(response); JsonObject jObject = jElement.getAsJsonObject(); @@ -531,7 +509,7 @@ public class ResponseParser { public static Map convertServiceDistributionStatusToObject(String response) throws ParseException { - Map serviceDistributionStatusMap = new HashMap(); + Map serviceDistributionStatusMap = new HashMap<>(); ServiceDistributionStatus serviceDistributionStatusObject = null; JsonElement jElement = new JsonParser().parse(response); @@ -551,7 +529,7 @@ public class ResponseParser { public static Map getPropertiesNameType(RestResponse restResponse) throws JSONException { - Map propertiesMap = new HashMap(); + Map propertiesMap = new HashMap<>(); JSONArray propertiesList = getListFromJson(restResponse, "properties"); for (int i = 0; i < propertiesList.length() ; i ++){ JSONObject prop = (JSONObject) JSONValue.parse(propertiesList.get(i).toString()); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ServiceRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ServiceRestUtils.java index 9ba4a906c6..1d8aef6f04 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ServiceRestUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ServiceRestUtils.java @@ -45,9 +45,6 @@ import com.google.gson.Gson; public class ServiceRestUtils extends BaseRestUtils { private static Logger logger = LoggerFactory.getLogger(ServiceRestUtils.class.getName()); - private final static String cacheControl = "no-cache"; - private final static String contentTypeHeaderData = "application/json"; - private final static String acceptHeaderDate = "application/json"; // ****** CREATE ******* private static Gson gson = new Gson(); @@ -68,8 +65,7 @@ public class ServiceRestUtils extends BaseRestUtils { public static RestResponse markServiceToDelete(String resourceId, String userId) throws IOException { Config config = Utils.getConfig(); - String url = String.format(Urls.DELETE_SERVICE, config.getCatalogBeHost(), config.getCatalogBePort(), - resourceId); + String url = String.format(Urls.DELETE_SERVICE, config.getCatalogBeHost(), config.getCatalogBePort(), resourceId); RestResponse sendDelete = sendDelete(url, userId); return sendDelete; @@ -79,8 +75,7 @@ public class ServiceRestUtils extends BaseRestUtils { public static RestResponse deleteServiceById(String serviceId, String userId) throws IOException { Config config = Utils.getConfig(); - String url = String.format(Urls.DELETE_SERVICE, config.getCatalogBeHost(), config.getCatalogBePort(), - serviceId); + String url = String.format(Urls.DELETE_SERVICE, config.getCatalogBeHost(), config.getCatalogBePort(), serviceId); RestResponse sendDelete = sendDelete(url, userId); deleteMarkedServices(userId); return sendDelete; @@ -177,12 +172,12 @@ public class ServiceRestUtils extends BaseRestUtils { } public static Map prepareHeadersMap(User sdncModifierDetails, boolean isCached) { - Map headersMap = new HashMap(); + Map headersMap = new HashMap<>(); if (isCached) - headersMap.put(HttpHeaderEnum.CACHE_CONTROL.getValue(), cacheControl); + headersMap.put(HttpHeaderEnum.CACHE_CONTROL.getValue(), BaseRestUtils.cacheControlHeader); - headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); - headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate); + headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData); + headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData); headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId()); return headersMap; } @@ -202,7 +197,7 @@ public class ServiceRestUtils extends BaseRestUtils { String url = String.format(Urls.REJECT_DISTRIBUTION, config.getCatalogBeHost(), config.getCatalogBePort(), serviceId); String userBodyJson = gson.toJson(comment); - return sendPost(url, userBodyJson, userId, acceptHeaderData); + return sendPost(url, userBodyJson, userId, BaseRestUtils.acceptHeaderData); } @@ -268,9 +263,9 @@ public class ServiceRestUtils extends BaseRestUtils { String url = String.format(Urls.GET_FOLLWED_LIST, config.getCatalogBeHost(), config.getCatalogBePort()); - Map headersMap = new HashMap(); - headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json"); - headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json"); + Map headersMap = new HashMap<>(); + headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData); + headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData); headersMap.put(HttpHeaderEnum.USER_ID.getValue(), user.getUserId()); RestResponse getResourceNotAbstarctResponse = httpRequest.httpSendGet(url, headersMap); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/UserRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/UserRestUtils.java index 881e9469dd..5031391fe4 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/UserRestUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/UserRestUtils.java @@ -171,7 +171,7 @@ public class UserRestUtils extends BaseRestUtils { Config config = Utils.getConfig(); - Map headersMap = new HashMap(); + Map headersMap = new HashMap<>(); headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate); headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId()); @@ -189,7 +189,7 @@ public class UserRestUtils extends BaseRestUtils { Config config = Utils.getConfig(); - Map headersMap = new HashMap(); + Map headersMap = new HashMap<>(); headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate); headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId()); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ArtifactValidationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ArtifactValidationUtils.java index a07300671f..61d340094d 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ArtifactValidationUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ArtifactValidationUtils.java @@ -20,17 +20,9 @@ package org.openecomp.sdc.ci.tests.utils.validation; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.File; -import java.io.IOException; -import java.util.List; -import java.util.Map; - -import org.codehaus.jackson.JsonParseException; -import org.codehaus.jackson.JsonProcessingException; -import org.codehaus.jackson.map.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; import org.openecomp.sdc.be.model.ArtifactDefinition; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentInstance; @@ -44,8 +36,14 @@ import org.openecomp.sdc.ci.tests.utils.Utils; import org.openecomp.sdc.ci.tests.utils.general.FileUtils; import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.assertTrue; public class ArtifactValidationUtils { @@ -109,16 +107,14 @@ public class ArtifactValidationUtils { counter); } - public static ESArtifactData parseArtifactRespFromES(RestResponse resResponse) - throws JsonParseException, JsonProcessingException, Exception { + public static ESArtifactData parseArtifactRespFromES(RestResponse resResponse) throws Exception { String bodyToParse = resResponse.getResponse(); JsonElement jElement = new JsonParser().parse(bodyToParse); JsonElement jsourceElement = jElement.getAsJsonObject().get("_source"); ObjectMapper mapper = new ObjectMapper(); - ESArtifactData esArtifactObject = mapper.readValue(jsourceElement.toString(), ESArtifactData.class); - return esArtifactObject; + return mapper.readValue(jsourceElement.toString(), ESArtifactData.class); } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/AuditValidationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/AuditValidationUtils.java index 4cf712f2fc..5f5afb2126 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/AuditValidationUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/AuditValidationUtils.java @@ -48,7 +48,6 @@ import org.openecomp.sdc.be.model.category.SubCategoryDefinition; import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.ci.tests.api.Urls; import org.openecomp.sdc.ci.tests.config.Config; -import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails; import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.enums.AuditEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.AuditJsonKeysEnum; @@ -66,7 +65,6 @@ import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedUserCRUDAudit; import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.run.StartTest; -import org.openecomp.sdc.ci.tests.utils.ArtifactUtils; import org.openecomp.sdc.ci.tests.utils.Utils; import org.openecomp.sdc.ci.tests.utils.cassandra.CassandraUtils; import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; @@ -129,41 +127,18 @@ public class AuditValidationUtils { public static void validateAuditDownloadExternalAPI(ExpectedResourceAuditJavaObject resourceAuditJavaObject, String action, String body, boolean checkAllFields) throws Exception { - Map actualAuditRecords = new HashMap(); - // Andrey's comment - // actualAuditRecords = parseAuditResourceByAction(action, body); - actualAuditRecords = parseAuditResourceByAction(action, null); - - // List> actualAuditRecords = new - // ArrayList>(); - // actualAuditRecords = parseAuditResourceByActionToList(action, body); + Map actualAuditRecords = parseAuditResourceByAction(action, null); validateField(actualAuditRecords, AuditJsonKeysEnum.ACTION.getAuditJsonKeyName(), action); - validateField(actualAuditRecords, AuditJsonKeysEnum.RESOURCE_NAME.getAuditJsonKeyName(), - resourceAuditJavaObject.getResourceName()); - validateField(actualAuditRecords, AuditJsonKeysEnum.RESOURCE_TYPE.getAuditJsonKeyName(), - resourceAuditJavaObject.getResourceType()); - - validateField(actualAuditRecords, AuditJsonKeysEnum.STATUS.getAuditJsonKeyName(), - resourceAuditJavaObject.getStatus()); - validateField(actualAuditRecords, AuditJsonKeysEnum.DESCRIPTION.getAuditJsonKeyName(), - resourceAuditJavaObject.getDesc()); - - // validateField(actualAuditRecords, - // AuditJsonKeysEnum.CONSUMER_ID.getAuditJsonKeyName(), - // resourceAuditJavaObject.getCONSUMER_ID()); - // validateField(actualAuditRecords, - // AuditJsonKeysEnum.RESOURCE_URL.getAuditJsonKeyName(), - // resourceAuditJavaObject.getRESOURCE_URL()); + validateField(actualAuditRecords, AuditJsonKeysEnum.RESOURCE_NAME.getAuditJsonKeyName(), resourceAuditJavaObject.getResourceName()); + validateField(actualAuditRecords, AuditJsonKeysEnum.RESOURCE_TYPE.getAuditJsonKeyName(), resourceAuditJavaObject.getResourceType()); + validateField(actualAuditRecords, AuditJsonKeysEnum.STATUS.getAuditJsonKeyName(), resourceAuditJavaObject.getStatus()); + validateField(actualAuditRecords, AuditJsonKeysEnum.DESCRIPTION.getAuditJsonKeyName(), resourceAuditJavaObject.getDesc()); } - public static void validateAudit(ExpectedResourceAuditJavaObject resourceAuditJavaObject, String action, - String body, boolean checkAllFields) throws Exception { - Map actualAuditRecords = new HashMap(); - // Andrey's comment - // actualAuditRecords = parseAuditResourceByAction(action, body); - actualAuditRecords = parseAuditResourceByAction(action, null); + public static void validateAudit(ExpectedResourceAuditJavaObject resourceAuditJavaObject, String action, String body, boolean checkAllFields) throws Exception { + Map actualAuditRecords = parseAuditResourceByAction(action, null); if ((resourceAuditJavaObject.getModifierName() != null) && (resourceAuditJavaObject.getModifierUid() != null)) { resourceAuditJavaObject.setModifierUid(getModifierString(resourceAuditJavaObject.getModifierName(), @@ -171,77 +146,45 @@ public class AuditValidationUtils { } validateField(actualAuditRecords, AuditJsonKeysEnum.ACTION.getAuditJsonKeyName(), action); - validateField(actualAuditRecords, AuditJsonKeysEnum.RESOURCE_NAME.getAuditJsonKeyName(), - resourceAuditJavaObject.getResourceName()); - validateField(actualAuditRecords, AuditJsonKeysEnum.RESOURCE_TYPE.getAuditJsonKeyName(), - resourceAuditJavaObject.getResourceType()); - validateField(actualAuditRecords, AuditJsonKeysEnum.PREV_VERSION.getAuditJsonKeyName(), - resourceAuditJavaObject.getPrevVersion()); - validateField(actualAuditRecords, AuditJsonKeysEnum.CURR_VERSION.getAuditJsonKeyName(), - resourceAuditJavaObject.getCurrVersion()); - - validateField(actualAuditRecords, AuditJsonKeysEnum.MODIFIER.getAuditJsonKeyName(), - resourceAuditJavaObject.getModifierUid()); - validateField(actualAuditRecords, AuditJsonKeysEnum.PREV_STATE.getAuditJsonKeyName(), - resourceAuditJavaObject.getPrevState()); - validateField(actualAuditRecords, AuditJsonKeysEnum.CURR_STATE.getAuditJsonKeyName(), - resourceAuditJavaObject.getCurrState()); - validateField(actualAuditRecords, AuditJsonKeysEnum.STATUS.getAuditJsonKeyName(), - resourceAuditJavaObject.getStatus()); - // validateField(map2, AuditJsonKeysEnum.STATUS.getAuditJsonKeyName(), - // Double.parseDouble(resourceAuditJavaObject.getStatus())); - validateField(actualAuditRecords, AuditJsonKeysEnum.DESCRIPTION.getAuditJsonKeyName(), - resourceAuditJavaObject.getDesc()); - validateField(actualAuditRecords, AuditJsonKeysEnum.COMMENT.getAuditJsonKeyName(), - resourceAuditJavaObject.getComment()); - // validateField(map2, - // AuditJsonKeysEnum.ARTIFACT_DATA.getAuditJsonKeyName(), - // resourceAuditJavaObject.getArtifactData()); - validateField(actualAuditRecords, AuditJsonKeysEnum.TOSCA_NODE_TYPE.getAuditJsonKeyName(), - resourceAuditJavaObject.getToscaNodeType()); - validateField(actualAuditRecords, AuditJsonKeysEnum.CURR_ARTIFACT_UUID.getAuditJsonKeyName(), - resourceAuditJavaObject.getCurrArtifactUuid()); - validateField(actualAuditRecords, AuditJsonKeysEnum.PREV_ARTIFACT_UUID.getAuditJsonKeyName(), - resourceAuditJavaObject.getPrevArtifactUuid()); - - validateAtifactDataField(actualAuditRecords, AuditJsonKeysEnum.ARTIFACT_DATA.getAuditJsonKeyName(), - resourceAuditJavaObject.getArtifactData(), checkAllFields); + validateField(actualAuditRecords, AuditJsonKeysEnum.RESOURCE_NAME.getAuditJsonKeyName(), resourceAuditJavaObject.getResourceName()); + validateField(actualAuditRecords, AuditJsonKeysEnum.RESOURCE_TYPE.getAuditJsonKeyName(), resourceAuditJavaObject.getResourceType()); + validateField(actualAuditRecords, AuditJsonKeysEnum.PREV_VERSION.getAuditJsonKeyName(), resourceAuditJavaObject.getPrevVersion()); + validateField(actualAuditRecords, AuditJsonKeysEnum.CURR_VERSION.getAuditJsonKeyName(), resourceAuditJavaObject.getCurrVersion()); + + validateField(actualAuditRecords, AuditJsonKeysEnum.MODIFIER.getAuditJsonKeyName(), resourceAuditJavaObject.getModifierUid()); + validateField(actualAuditRecords, AuditJsonKeysEnum.PREV_STATE.getAuditJsonKeyName(), resourceAuditJavaObject.getPrevState()); + validateField(actualAuditRecords, AuditJsonKeysEnum.CURR_STATE.getAuditJsonKeyName(), resourceAuditJavaObject.getCurrState()); + validateField(actualAuditRecords, AuditJsonKeysEnum.STATUS.getAuditJsonKeyName(), resourceAuditJavaObject.getStatus()); + validateField(actualAuditRecords, AuditJsonKeysEnum.DESCRIPTION.getAuditJsonKeyName(), resourceAuditJavaObject.getDesc()); + validateField(actualAuditRecords, AuditJsonKeysEnum.COMMENT.getAuditJsonKeyName(), resourceAuditJavaObject.getComment()); + validateField(actualAuditRecords, AuditJsonKeysEnum.TOSCA_NODE_TYPE.getAuditJsonKeyName(), resourceAuditJavaObject.getToscaNodeType()); + validateField(actualAuditRecords, AuditJsonKeysEnum.CURR_ARTIFACT_UUID.getAuditJsonKeyName(), resourceAuditJavaObject.getCurrArtifactUuid()); + validateField(actualAuditRecords, AuditJsonKeysEnum.PREV_ARTIFACT_UUID.getAuditJsonKeyName(), resourceAuditJavaObject.getPrevArtifactUuid()); + + validateAtifactDataField(actualAuditRecords, AuditJsonKeysEnum.ARTIFACT_DATA.getAuditJsonKeyName(), resourceAuditJavaObject.getArtifactData(), checkAllFields); } - public static void validateExternalAudit(ExpectedExternalAudit externalAuditObject, String action, - Map body) throws Exception { + public static void validateExternalAudit(ExpectedExternalAudit externalAuditObject, String action, Map body) throws Exception { - Map actualAuditRecord = new HashMap(); - actualAuditRecord = parseAuditResourceByAction(action, body); + Map actualAuditRecord = parseAuditResourceByAction(action, body); validateField(actualAuditRecord, AuditJsonKeysEnum.ACTION.getAuditJsonKeyName(), action); - validateField(actualAuditRecord, AuditJsonKeysEnum.CONSUMER_ID.getAuditJsonKeyName(), - externalAuditObject.getCONSUMER_ID()); + validateField(actualAuditRecord, AuditJsonKeysEnum.CONSUMER_ID.getAuditJsonKeyName(), externalAuditObject.getCONSUMER_ID()); // TODO - validateField(actualAuditRecord, AuditJsonKeysEnum.RESOURCE_URL.getAuditJsonKeyName(), - externalAuditObject.getRESOURCE_URL()); + validateField(actualAuditRecord, AuditJsonKeysEnum.RESOURCE_URL.getAuditJsonKeyName(), externalAuditObject.getRESOURCE_URL()); //TODO - validateField(actualAuditRecord, AuditJsonKeysEnum.RESOURCE_NAME.getAuditJsonKeyName(), - externalAuditObject.getRESOURCE_NAME()); - validateField(actualAuditRecord, AuditJsonKeysEnum.SERVICE_INSTANCE_ID.getAuditJsonKeyName(), - externalAuditObject.getSERVICE_INSTANCE_ID()); + validateField(actualAuditRecord, AuditJsonKeysEnum.RESOURCE_NAME.getAuditJsonKeyName(), externalAuditObject.getRESOURCE_NAME()); + validateField(actualAuditRecord, AuditJsonKeysEnum.SERVICE_INSTANCE_ID.getAuditJsonKeyName(), externalAuditObject.getSERVICE_INSTANCE_ID()); //TODO - validateField(actualAuditRecord, AuditJsonKeysEnum.RESOURCE_TYPE.getAuditJsonKeyName(), - externalAuditObject.getRESOURCE_TYPE()); - validateField(actualAuditRecord, AuditJsonKeysEnum.STATUS.getAuditJsonKeyName(), - externalAuditObject.getSTATUS()); - validateField(actualAuditRecord, AuditJsonKeysEnum.DESCRIPTION.getAuditJsonKeyName(), - externalAuditObject.getDESC()); + validateField(actualAuditRecord, AuditJsonKeysEnum.RESOURCE_TYPE.getAuditJsonKeyName(), externalAuditObject.getRESOURCE_TYPE()); + validateField(actualAuditRecord, AuditJsonKeysEnum.STATUS.getAuditJsonKeyName(), externalAuditObject.getSTATUS()); + validateField(actualAuditRecord, AuditJsonKeysEnum.DESCRIPTION.getAuditJsonKeyName(), externalAuditObject.getDESC()); //TODO -// validateField(actualAuditRecord, AuditJsonKeysEnum.MODIFIER.getAuditJsonKeyName(), -// externalAuditObject.getMODIFIER()); - validateField(actualAuditRecord, AuditJsonKeysEnum.PREV_ARTIFACT_UUID.getAuditJsonKeyName(), - externalAuditObject.getPREV_ARTIFACT_UUID()); - validateField(actualAuditRecord, AuditJsonKeysEnum.CURR_ARTIFACT_UUID.getAuditJsonKeyName(), - externalAuditObject.getCURR_ARTIFACT_UUID()); +// validateField(actualAuditRecord, AuditJsonKeysEnum.MODIFIER.getAuditJsonKeyName(), externalAuditObject.getMODIFIER()); + validateField(actualAuditRecord, AuditJsonKeysEnum.PREV_ARTIFACT_UUID.getAuditJsonKeyName(), externalAuditObject.getPREV_ARTIFACT_UUID()); + validateField(actualAuditRecord, AuditJsonKeysEnum.CURR_ARTIFACT_UUID.getAuditJsonKeyName(), externalAuditObject.getCURR_ARTIFACT_UUID()); //TODO - validateField(actualAuditRecord, AuditJsonKeysEnum.ARTIFACT_DATA.getAuditJsonKeyName(), - externalAuditObject.getARTIFACT_DATA()); + validateField(actualAuditRecord, AuditJsonKeysEnum.ARTIFACT_DATA.getAuditJsonKeyName(), externalAuditObject.getARTIFACT_DATA()); } @@ -288,26 +231,19 @@ public class AuditValidationUtils { } // //Benny - public static void validateEcompConsumerAudit(ExpectedEcomConsumerAudit ecompConsumerAuditJavaObject, String action) - throws Exception { + public static void validateEcompConsumerAudit(ExpectedEcomConsumerAudit ecompConsumerAuditJavaObject, String action) throws Exception { String fixedAction = BaseRestUtils.encodeUrlForDownload(action); - Map map2 = new HashMap(); - map2 = parseAuditResourceByAction(fixedAction, null); - - validateField(map2, EcompConsumerAuditJsonKeysEnum.MODIFIER.getAuditJsonKeyName(), - ecompConsumerAuditJavaObject.getModifier()); - validateField(map2, EcompConsumerAuditJsonKeysEnum.ECOMP_USER.getAuditJsonKeyName(), - ecompConsumerAuditJavaObject.getEcomUser()); - validateField(map2, EcompConsumerAuditJsonKeysEnum.STATUS.getAuditJsonKeyName(), - ecompConsumerAuditJavaObject.getStatus()); - validateField(map2, EcompConsumerAuditJsonKeysEnum.DESC.getAuditJsonKeyName(), - ecompConsumerAuditJavaObject.getDesc()); + Map map2 = parseAuditResourceByAction(fixedAction, null); + + validateField(map2, EcompConsumerAuditJsonKeysEnum.MODIFIER.getAuditJsonKeyName(), ecompConsumerAuditJavaObject.getModifier()); + validateField(map2, EcompConsumerAuditJsonKeysEnum.ECOMP_USER.getAuditJsonKeyName(), ecompConsumerAuditJavaObject.getEcomUser()); + validateField(map2, EcompConsumerAuditJsonKeysEnum.STATUS.getAuditJsonKeyName(), ecompConsumerAuditJavaObject.getStatus()); + validateField(map2, EcompConsumerAuditJsonKeysEnum.DESC.getAuditJsonKeyName(), ecompConsumerAuditJavaObject.getDesc()); validateField(map2, EcompConsumerAuditJsonKeysEnum.ACTION.getAuditJsonKeyName(), action); } - public static void ecompConsumerAuditSuccess(String action, ConsumerDataDefinition consumerDataDefinition, - User user, int status) throws Exception { + public static void ecompConsumerAuditSuccess(String action, ConsumerDataDefinition consumerDataDefinition, User user, int status) throws Exception { ExpectedEcomConsumerAudit expectedEcomConsumerAuditJavaObject = new ExpectedEcomConsumerAudit(); expectedEcomConsumerAuditJavaObject.setAction(action); expectedEcomConsumerAuditJavaObject.setEcomUser( @@ -384,34 +320,24 @@ public class AuditValidationUtils { public static void validateAuditGetListOfUsersByRoles(ExpectedGetUserListAudit GetListOfUsersAuditJavaObject, String action) throws Exception { - Map map2 = new HashMap(); - map2 = parseAuditResourceByAction(action, null); + Map map2 = parseAuditResourceByAction(action, null); validateField(map2, AuditJsonKeysEnum.ACTION.getAuditJsonKeyName(), action); validateField(map2, AuditJsonKeysEnum.STATUS.getAuditJsonKeyName(), GetListOfUsersAuditJavaObject.getStatus()); - validateField(map2, AuditJsonKeysEnum.MODIFIER.getAuditJsonKeyName(), - GetListOfUsersAuditJavaObject.getModifier()); - validateField(map2, AuditJsonKeysEnum.DESCRIPTION.getAuditJsonKeyName(), - GetListOfUsersAuditJavaObject.getDesc()); - validateField(map2, AuditJsonKeysEnum.DETAILS.getAuditJsonKeyName(), - GetListOfUsersAuditJavaObject.getDetails()); + validateField(map2, AuditJsonKeysEnum.MODIFIER.getAuditJsonKeyName(), GetListOfUsersAuditJavaObject.getModifier()); + validateField(map2, AuditJsonKeysEnum.DESCRIPTION.getAuditJsonKeyName(), GetListOfUsersAuditJavaObject.getDesc()); + validateField(map2, AuditJsonKeysEnum.DETAILS.getAuditJsonKeyName(), GetListOfUsersAuditJavaObject.getDetails()); } - public static void validateAuditImport(ExpectedResourceAuditJavaObject resourceAuditJavaObject, String action) - throws Exception { + public static void validateAuditImport(ExpectedResourceAuditJavaObject resourceAuditJavaObject, String action) throws Exception { - Map map2 = new HashMap(); - map2 = parseAuditResourceByAction(action, null); + Map map2 = parseAuditResourceByAction(action, null); - resourceAuditJavaObject.setModifierUid( - getModifierString(resourceAuditJavaObject.getModifierName(), resourceAuditJavaObject.getModifierUid())); + resourceAuditJavaObject.setModifierUid(getModifierString(resourceAuditJavaObject.getModifierName(), resourceAuditJavaObject.getModifierUid())); validateField(map2, AuditJsonKeysEnum.ACTION.getAuditJsonKeyName(), action); - validateField(map2, AuditJsonKeysEnum.RESOURCE_TYPE.getAuditJsonKeyName(), - resourceAuditJavaObject.getResourceType()); - validateField(map2, AuditJsonKeysEnum.PREV_VERSION.getAuditJsonKeyName(), - resourceAuditJavaObject.getPrevVersion()); - validateField(map2, AuditJsonKeysEnum.CURR_VERSION.getAuditJsonKeyName(), - resourceAuditJavaObject.getCurrVersion()); + validateField(map2, AuditJsonKeysEnum.RESOURCE_TYPE.getAuditJsonKeyName(), resourceAuditJavaObject.getResourceType()); + validateField(map2, AuditJsonKeysEnum.PREV_VERSION.getAuditJsonKeyName(), resourceAuditJavaObject.getPrevVersion()); + validateField(map2, AuditJsonKeysEnum.CURR_VERSION.getAuditJsonKeyName(), resourceAuditJavaObject.getCurrVersion()); validateField(map2, AuditJsonKeysEnum.MODIFIER.getAuditJsonKeyName(), resourceAuditJavaObject.getModifierUid()); validateField(map2, AuditJsonKeysEnum.PREV_STATE.getAuditJsonKeyName(), resourceAuditJavaObject.getPrevState()); validateField(map2, AuditJsonKeysEnum.CURR_STATE.getAuditJsonKeyName(), resourceAuditJavaObject.getCurrState()); @@ -420,28 +346,20 @@ public class AuditValidationUtils { } - public static void validateAuditDistribution(ExpectedResourceAuditJavaObject resourceAuditJavaObject, String action) - throws Exception { + public static void validateAuditDistribution(ExpectedResourceAuditJavaObject resourceAuditJavaObject, String action) throws Exception { - Map map2 = new HashMap(); - map2 = parseAuditResourceByAction(action, null); + Map map2 = parseAuditResourceByAction(action, null); - resourceAuditJavaObject.setModifierUid( - getModifierString(resourceAuditJavaObject.getModifierName(), resourceAuditJavaObject.getModifierUid())); + resourceAuditJavaObject.setModifierUid(getModifierString(resourceAuditJavaObject.getModifierName(), resourceAuditJavaObject.getModifierUid())); validateField(map2, AuditJsonKeysEnum.ACTION.getAuditJsonKeyName(), action); - validateField(map2, AuditJsonKeysEnum.RESOURCE_NAME.getAuditJsonKeyName(), - resourceAuditJavaObject.getResourceName()); - validateField(map2, AuditJsonKeysEnum.RESOURCE_TYPE.getAuditJsonKeyName(), - resourceAuditJavaObject.getResourceType()); - validateField(map2, AuditJsonKeysEnum.CURR_VERSION.getAuditJsonKeyName(), - resourceAuditJavaObject.getCurrVersion()); + validateField(map2, AuditJsonKeysEnum.RESOURCE_NAME.getAuditJsonKeyName(), resourceAuditJavaObject.getResourceName()); + validateField(map2, AuditJsonKeysEnum.RESOURCE_TYPE.getAuditJsonKeyName(), resourceAuditJavaObject.getResourceType()); + validateField(map2, AuditJsonKeysEnum.CURR_VERSION.getAuditJsonKeyName(), resourceAuditJavaObject.getCurrVersion()); validateField(map2, AuditJsonKeysEnum.MODIFIER.getAuditJsonKeyName(), resourceAuditJavaObject.getModifierUid()); validateField(map2, AuditJsonKeysEnum.CURR_STATE.getAuditJsonKeyName(), resourceAuditJavaObject.getCurrState()); - validateField(map2, AuditJsonKeysEnum.DPREV_STATUS.getAuditJsonKeyName(), - resourceAuditJavaObject.getDprevStatus()); - validateField(map2, AuditJsonKeysEnum.DCURR_STATUS.getAuditJsonKeyName(), - resourceAuditJavaObject.getDcurrStatus()); + validateField(map2, AuditJsonKeysEnum.DPREV_STATUS.getAuditJsonKeyName(), resourceAuditJavaObject.getDprevStatus()); + validateField(map2, AuditJsonKeysEnum.DCURR_STATUS.getAuditJsonKeyName(), resourceAuditJavaObject.getDcurrStatus()); validateField(map2, AuditJsonKeysEnum.STATUS.getAuditJsonKeyName(), resourceAuditJavaObject.getStatus()); validateField(map2, AuditJsonKeysEnum.DESCRIPTION.getAuditJsonKeyName(), resourceAuditJavaObject.getDesc()); validateField(map2, AuditJsonKeysEnum.COMMENT.getAuditJsonKeyName(), resourceAuditJavaObject.getComment()); @@ -450,46 +368,34 @@ public class AuditValidationUtils { } // Benny - public static void validateAudit_Distribution(ExpectedResourceAuditJavaObject resourceAuditJavaObject, - String action) throws Exception { + public static void validateAudit_Distribution(ExpectedResourceAuditJavaObject resourceAuditJavaObject, String action) throws Exception { List> actionToList = getAuditListByAction(resourceAuditJavaObject.getAction(), 1); Map map2 = actionToList.get(0); validateField(map2, AuditJsonKeysEnum.ACTION.getAuditJsonKeyName(), action); - validateField(map2, AuditJsonKeysEnum.RESOURCE_NAME.getAuditJsonKeyName(), - resourceAuditJavaObject.getResourceName()); - validateField(map2, AuditJsonKeysEnum.RESOURCE_TYPE.getAuditJsonKeyName(), - resourceAuditJavaObject.getResourceType()); - validateField(map2, AuditJsonKeysEnum.CURR_VERSION.getAuditJsonKeyName(), - resourceAuditJavaObject.getCurrVersion()); + validateField(map2, AuditJsonKeysEnum.RESOURCE_NAME.getAuditJsonKeyName(), resourceAuditJavaObject.getResourceName()); + validateField(map2, AuditJsonKeysEnum.RESOURCE_TYPE.getAuditJsonKeyName(), resourceAuditJavaObject.getResourceType()); + validateField(map2, AuditJsonKeysEnum.CURR_VERSION.getAuditJsonKeyName(), resourceAuditJavaObject.getCurrVersion()); validateField(map2, AuditJsonKeysEnum.MODIFIER.getAuditJsonKeyName(), resourceAuditJavaObject.getMODIFIER()); validateField(map2, AuditJsonKeysEnum.CURR_STATE.getAuditJsonKeyName(), resourceAuditJavaObject.getCurrState()); - validateField(map2, AuditJsonKeysEnum.DPREV_STATUS.getAuditJsonKeyName(), - resourceAuditJavaObject.getDprevStatus()); - validateField(map2, AuditJsonKeysEnum.DCURR_STATUS.getAuditJsonKeyName(), - resourceAuditJavaObject.getDcurrStatus()); + validateField(map2, AuditJsonKeysEnum.DPREV_STATUS.getAuditJsonKeyName(), resourceAuditJavaObject.getDprevStatus()); + validateField(map2, AuditJsonKeysEnum.DCURR_STATUS.getAuditJsonKeyName(), resourceAuditJavaObject.getDcurrStatus()); validateField(map2, AuditJsonKeysEnum.STATUS.getAuditJsonKeyName(), resourceAuditJavaObject.getStatus()); validateField(map2, AuditJsonKeysEnum.DESCRIPTION.getAuditJsonKeyName(), resourceAuditJavaObject.getDesc()); validateField(map2, AuditJsonKeysEnum.COMMENT.getAuditJsonKeyName(), resourceAuditJavaObject.getComment()); } - public void validateAuditNotification(ExpectedResourceAuditJavaObject resourceAuditJavaObject, String action) - throws Exception { + public void validateAuditNotification(ExpectedResourceAuditJavaObject resourceAuditJavaObject, String action) throws Exception { - Map map2 = new HashMap(); - map2 = parseAuditResourceByAction(action, null); + Map map2 = parseAuditResourceByAction(action, null); - resourceAuditJavaObject.setModifierUid( - getModifierString(resourceAuditJavaObject.getModifierName(), resourceAuditJavaObject.getModifierUid())); + resourceAuditJavaObject.setModifierUid(getModifierString(resourceAuditJavaObject.getModifierName(), resourceAuditJavaObject.getModifierUid())); validateField(map2, AuditJsonKeysEnum.ACTION.getAuditJsonKeyName(), action); - validateField(map2, AuditJsonKeysEnum.RESOURCE_NAME.getAuditJsonKeyName(), - resourceAuditJavaObject.getResourceName()); - validateField(map2, AuditJsonKeysEnum.RESOURCE_TYPE.getAuditJsonKeyName(), - resourceAuditJavaObject.getResourceType()); - validateField(map2, AuditJsonKeysEnum.CURR_VERSION.getAuditJsonKeyName(), - resourceAuditJavaObject.getCurrVersion()); + validateField(map2, AuditJsonKeysEnum.RESOURCE_NAME.getAuditJsonKeyName(), resourceAuditJavaObject.getResourceName()); + validateField(map2, AuditJsonKeysEnum.RESOURCE_TYPE.getAuditJsonKeyName(), resourceAuditJavaObject.getResourceType()); + validateField(map2, AuditJsonKeysEnum.CURR_VERSION.getAuditJsonKeyName(), resourceAuditJavaObject.getCurrVersion()); validateField(map2, AuditJsonKeysEnum.CURR_STATE.getAuditJsonKeyName(), resourceAuditJavaObject.getCurrState()); validateField(map2, AuditJsonKeysEnum.STATUS.getAuditJsonKeyName(), resourceAuditJavaObject.getStatus()); validateField(map2, AuditJsonKeysEnum.DESCRIPTION.getAuditJsonKeyName(), resourceAuditJavaObject.getDesc()); @@ -498,39 +404,31 @@ public class AuditValidationUtils { } - public static void validateAudit(ExpectedDistDownloadAudit expectedDistDownloadAudit, String action) - throws Exception { + public static void validateAudit(ExpectedDistDownloadAudit expectedDistDownloadAudit, String action) throws Exception { - Map map2 = new HashMap(); - map2 = parseAuditResourceByAction(action, null); + Map map2 = parseAuditResourceByAction(action, null); validateField(map2, AuditJsonKeysEnum.ACTION.getAuditJsonKeyName(), action); validateField(map2, AuditJsonKeysEnum.STATUS.getAuditJsonKeyName(), expectedDistDownloadAudit.getStatus()); validateField(map2, AuditJsonKeysEnum.DESCRIPTION.getAuditJsonKeyName(), expectedDistDownloadAudit.getDesc()); - validateField(map2, AuditJsonKeysEnum.CONSUMER_ID.getAuditJsonKeyName(), - expectedDistDownloadAudit.getConsumerId()); - validateField(map2, AuditJsonKeysEnum.RESOURCE_URL.getAuditJsonKeyName(), - expectedDistDownloadAudit.getResourceUrl()); + validateField(map2, AuditJsonKeysEnum.CONSUMER_ID.getAuditJsonKeyName(), expectedDistDownloadAudit.getConsumerId()); + validateField(map2, AuditJsonKeysEnum.RESOURCE_URL.getAuditJsonKeyName(), expectedDistDownloadAudit.getResourceUrl()); } public static void validateAuditExternalSearchAPI(ExpectedExternalAudit expectedDistDownloadAudit, String action, Map body) throws Exception { - Map map2 = new HashMap(); - map2 = parseAuditResourceByAction(action, body); + Map map2 = parseAuditResourceByAction(action, body); validateField(map2, AuditJsonKeysEnum.ACTION.getAuditJsonKeyName(), action); validateField(map2, AuditJsonKeysEnum.STATUS.getAuditJsonKeyName(), expectedDistDownloadAudit.getSTATUS()); validateField(map2, AuditJsonKeysEnum.DESCRIPTION.getAuditJsonKeyName(), expectedDistDownloadAudit.getDESC()); - validateField(map2, AuditJsonKeysEnum.CONSUMER_ID.getAuditJsonKeyName(), - expectedDistDownloadAudit.getCONSUMER_ID()); - validateField(map2, AuditJsonKeysEnum.RESOURCE_URL.getAuditJsonKeyName(), - expectedDistDownloadAudit.getRESOURCE_URL()); + validateField(map2, AuditJsonKeysEnum.CONSUMER_ID.getAuditJsonKeyName(), expectedDistDownloadAudit.getCONSUMER_ID()); + validateField(map2, AuditJsonKeysEnum.RESOURCE_URL.getAuditJsonKeyName(), expectedDistDownloadAudit.getRESOURCE_URL()); } public static void validateAuditExternalCreateResource(ExpectedResourceAuditJavaObject expectedExternalAudit, String action, Map body) throws Exception { - Map map2 = new HashMap(); - map2 = parseAuditResourceByAction(action, body); + Map map2 = parseAuditResourceByAction(action, body); validateField(map2, AuditJsonKeysEnum.ACTION.getAuditJsonKeyName(), action); validateField(map2, AuditJsonKeysEnum.RESOURCE_NAME.getAuditJsonKeyName(), expectedExternalAudit.getResourceName()); @@ -549,8 +447,7 @@ public class AuditValidationUtils { } public static void validateAuditExternalChangeAssetLifeCycle(ExpectedResourceAuditJavaObject expectedExternalAudit, String action, Map body) throws Exception { - Map map2 = new HashMap(); - map2 = parseAuditResourceByAction(action, body); + Map map2 = parseAuditResourceByAction(action, body); validateField(map2, AuditJsonKeysEnum.ACTION.getAuditJsonKeyName(), action); validateField(map2, AuditJsonKeysEnum.DESCRIPTION.getAuditJsonKeyName(), expectedExternalAudit.getDesc()); @@ -566,28 +463,20 @@ public class AuditValidationUtils { validateField(map2, AuditJsonKeysEnum.CURR_VERSION.getAuditJsonKeyName(), expectedExternalAudit.getCurrVersion()); validateField(map2, AuditJsonKeysEnum.PREV_STATE.getAuditJsonKeyName(), expectedExternalAudit.getPrevState()); validateField(map2, AuditJsonKeysEnum.CURR_STATE.getAuditJsonKeyName(), expectedExternalAudit.getCurrState()); - - - // TODO: Remove comment -// validateField(map2, AuditJsonKeysEnum.INVARIANT_UUID.getAuditJsonKeyName(), expectedExternalAudit.getINVARIANT_UUID()); + } public void validateAuditDeploy(ExpectedResourceAuditJavaObject resourceAuditJavaObject, String action) throws Exception { - Map map2 = new HashMap(); - map2 = parseAuditResourceByAction(action, null); + Map map2 = parseAuditResourceByAction(action, null); - resourceAuditJavaObject.setModifierUid( - getModifierString(resourceAuditJavaObject.getModifierName(), resourceAuditJavaObject.getModifierUid())); + resourceAuditJavaObject.setModifierUid(getModifierString(resourceAuditJavaObject.getModifierName(), resourceAuditJavaObject.getModifierUid())); validateField(map2, AuditJsonKeysEnum.ACTION.getAuditJsonKeyName(), action); - validateField(map2, AuditJsonKeysEnum.RESOURCE_NAME.getAuditJsonKeyName(), - resourceAuditJavaObject.getResourceName()); - validateField(map2, AuditJsonKeysEnum.RESOURCE_TYPE.getAuditJsonKeyName(), - resourceAuditJavaObject.getResourceType()); - validateField(map2, AuditJsonKeysEnum.CURR_VERSION.getAuditJsonKeyName(), - resourceAuditJavaObject.getCurrVersion()); + validateField(map2, AuditJsonKeysEnum.RESOURCE_NAME.getAuditJsonKeyName(), resourceAuditJavaObject.getResourceName()); + validateField(map2, AuditJsonKeysEnum.RESOURCE_TYPE.getAuditJsonKeyName(), resourceAuditJavaObject.getResourceType()); + validateField(map2, AuditJsonKeysEnum.CURR_VERSION.getAuditJsonKeyName(), resourceAuditJavaObject.getCurrVersion()); validateField(map2, AuditJsonKeysEnum.MODIFIER.getAuditJsonKeyName(), resourceAuditJavaObject.getModifierUid()); validateField(map2, AuditJsonKeysEnum.STATUS.getAuditJsonKeyName(), resourceAuditJavaObject.getStatus()); validateField(map2, AuditJsonKeysEnum.DESCRIPTION.getAuditJsonKeyName(), resourceAuditJavaObject.getDesc()); @@ -598,25 +487,19 @@ public class AuditValidationUtils { public static void validateAuditProduct(ExpectedProductAudit productExpectedAudit, String action, AuditJsonKeysEnum... additionalFields) throws Exception { - Map map2 = new HashMap(); - map2 = parseAuditResourceByAction(action, null); + Map map2 = parseAuditResourceByAction(action, null); validateField(map2, AuditJsonKeysEnum.ACTION.getAuditJsonKeyName(), action); - validateField(map2, AuditJsonKeysEnum.RESOURCE_NAME.getAuditJsonKeyName(), - productExpectedAudit.getRESOURCE_NAME()); - validateField(map2, AuditJsonKeysEnum.RESOURCE_TYPE.getAuditJsonKeyName(), - productExpectedAudit.getRESOURCE_TYPE()); - validateField(map2, AuditJsonKeysEnum.PREV_VERSION.getAuditJsonKeyName(), - productExpectedAudit.getPREV_VERSION()); - validateField(map2, AuditJsonKeysEnum.CURR_VERSION.getAuditJsonKeyName(), - productExpectedAudit.getCURR_VERSION()); + validateField(map2, AuditJsonKeysEnum.RESOURCE_NAME.getAuditJsonKeyName(), productExpectedAudit.getRESOURCE_NAME()); + validateField(map2, AuditJsonKeysEnum.RESOURCE_TYPE.getAuditJsonKeyName(), productExpectedAudit.getRESOURCE_TYPE()); + validateField(map2, AuditJsonKeysEnum.PREV_VERSION.getAuditJsonKeyName(), productExpectedAudit.getPREV_VERSION()); + validateField(map2, AuditJsonKeysEnum.CURR_VERSION.getAuditJsonKeyName(), productExpectedAudit.getCURR_VERSION()); validateField(map2, AuditJsonKeysEnum.PREV_STATE.getAuditJsonKeyName(), productExpectedAudit.getPREV_STATE()); validateField(map2, AuditJsonKeysEnum.CURR_STATE.getAuditJsonKeyName(), productExpectedAudit.getCURR_STATE()); validateField(map2, AuditJsonKeysEnum.MODIFIER.getAuditJsonKeyName(), productExpectedAudit.getMODIFIER()); validateField(map2, AuditJsonKeysEnum.STATUS.getAuditJsonKeyName(), productExpectedAudit.getSTATUS()); validateField(map2, AuditJsonKeysEnum.DESCRIPTION.getAuditJsonKeyName(), productExpectedAudit.getDESC()); - validateField(map2, AuditJsonKeysEnum.SERVICE_INSTANCE_ID.getAuditJsonKeyName(), - productExpectedAudit.getSERVICE_INSTANCE_ID()); + validateField(map2, AuditJsonKeysEnum.SERVICE_INSTANCE_ID.getAuditJsonKeyName(), productExpectedAudit.getSERVICE_INSTANCE_ID()); if (additionalFields != null) { List fieldsList = Arrays.asList(additionalFields); if (fieldsList.contains(AuditJsonKeysEnum.COMMENT)) { @@ -837,76 +720,6 @@ public class AuditValidationUtils { return resultsMap; } - // public static Map retrieveAuditMessagesByPattern(String pattern) throws - // IOException { - // - //// Config config = Utils.getConfig(); - //// HttpRequest getAuditingMessage = new HttpRequest(); - //// String url = String.format(Urls.GET_SEARCH_DATA_FROM_ES, - // config.getEsHost(), config.getEsPort(), pattern); - //// RestResponse restResponse = getAuditingMessage.httpSendGet(url, null); - // - //// get cassandra table name by action - // String esType = - // AuditingActionEnum.getActionByName(pattern).getAuditingEsType(); - //// AuditingActionEnum actionByName = - // AuditingActionEnum.getActionByName(pattern); - // - //// Map myFields= new - // HashMap(); - //// myFields.put(AuditingFieldsKeysEnum.AUDIT_ACTION , pattern); - // - // List> myFields = new - // ArrayList>(); - // Pair myPair = new - // Pair(AuditingFieldsKeysEnum.AUDIT_ACTION - // , pattern); - // myFields.add(0, myPair); - // - // - // List fetchFromTable = CassandraUtils.fetchFromTable("sdcaudit", - // esType, myFields); - // Row row = fetchFromTable.get(0); - // - // - // ColumnDefinitions columnDefinitions = row.getColumnDefinitions(); - //// String string = row.getString(columnDefinitions.getName(1)); - // - //// String metaData = row.getColumnDefinitions().toString(); - //// metaData =metaData.replaceAll("\\((.*?)\\)|\\[|\\]|Columns", ""); - //// List metaDataList = new - // ArrayList(Arrays.asList(metaData.split(", "))); - // - // - // - // Map resultsMap = new HashMap(); - // - // - // for (int i=0 ; i < columnDefinitions.size() ; i++){ - // resultsMap.put(columnDefinitions.getName(i) , - // row.getObject(columnDefinitions.getName(i)) == null ? "null" : - // row.getObject(columnDefinitions.getName(i)).toString()); - // } - //// for (String string : metaDataList) { - //// resultsMap.put(string , row.getString(string)); - //// } - //// - // - //// String dataString = fetchFromTable.toString(); - //// dataString = dataString.replaceAll("\\[|\\]|Row", ""); - //// List dataArray = new - // ArrayList(Arrays.asList(dataString.split(", "))); - //// - //// - //// Map resultsMap = new HashMap(); - //// for (int i=0 ; i> actionToList = getAuditListByAction(expectedAddUserAuditJavaObject.getAction(), 1); Map map = actionToList.get(0); validateField(map, UserAuditJsonKeysEnum.ACTION.getAuditJsonKeyName(), action); - validateField(map, UserAuditJsonKeysEnum.MODIFIER.getAuditJsonKeyName(), - expectedAddUserAuditJavaObject.getModifier()); - validateField(map, UserAuditJsonKeysEnum.USER_AFTER.getAuditJsonKeyName(), - expectedAddUserAuditJavaObject.getUserAfter()); - validateField(map, UserAuditJsonKeysEnum.USER_BEFORE.getAuditJsonKeyName(), - expectedAddUserAuditJavaObject.getUserBefore()); - validateField(map, UserAuditJsonKeysEnum.STATUS.getAuditJsonKeyName(), - expectedAddUserAuditJavaObject.getStatus()); + validateField(map, UserAuditJsonKeysEnum.MODIFIER.getAuditJsonKeyName(), expectedAddUserAuditJavaObject.getModifier()); + validateField(map, UserAuditJsonKeysEnum.USER_AFTER.getAuditJsonKeyName(), expectedAddUserAuditJavaObject.getUserAfter()); + validateField(map, UserAuditJsonKeysEnum.USER_BEFORE.getAuditJsonKeyName(), expectedAddUserAuditJavaObject.getUserBefore()); + validateField(map, UserAuditJsonKeysEnum.STATUS.getAuditJsonKeyName(), expectedAddUserAuditJavaObject.getStatus()); validateField(map, UserAuditJsonKeysEnum.DESC.getAuditJsonKeyName(), expectedAddUserAuditJavaObject.getDesc()); } @@ -1029,8 +835,7 @@ public class AuditValidationUtils { expectedCatrgoryAuditJavaObject.setAction(action); expectedCatrgoryAuditJavaObject.setModifier(user.getFullName() + "(" + user.getUserId() + ")"); expectedCatrgoryAuditJavaObject.setCategoryName(categoryDataDefinition.getName()); - String subCategoryName = (subCategoryDefinition != null ? subCategoryDefinition.getName() - : Constants.EMPTY_STRING); + String subCategoryName = (subCategoryDefinition != null ? subCategoryDefinition.getName() : Constants.EMPTY_STRING); expectedCatrgoryAuditJavaObject.setSubCategoryName(subCategoryName); String groupingName = (groupingDefinition != null ? groupingDefinition.getName() : Constants.EMPTY_STRING); expectedCatrgoryAuditJavaObject.setGroupingName(groupingName); @@ -1049,14 +854,10 @@ public class AuditValidationUtils { expectedCatrgoryAuditJavaObject.setModifier(getModifierString(expectedCatrgoryAuditJavaObject.getModifierName(), expectedCatrgoryAuditJavaObject.getModifierUid())); validateField(map, CategoryAuditJsonKeysEnum.ACTION.getAuditJsonKeyName(), action); - validateField(map, CategoryAuditJsonKeysEnum.MODIFIER.getAuditJsonKeyName(), - expectedCatrgoryAuditJavaObject.getModifier()); - validateField(map, CategoryAuditJsonKeysEnum.DETAILS.getAuditJsonKeyName(), - expectedCatrgoryAuditJavaObject.getDetails()); - validateField(map, CategoryAuditJsonKeysEnum.STATUS.getAuditJsonKeyName(), - expectedCatrgoryAuditJavaObject.getStatus()); - validateField(map, CategoryAuditJsonKeysEnum.DESCRIPTION.getAuditJsonKeyName(), - expectedCatrgoryAuditJavaObject.getDesc()); + validateField(map, CategoryAuditJsonKeysEnum.MODIFIER.getAuditJsonKeyName(), expectedCatrgoryAuditJavaObject.getModifier()); + validateField(map, CategoryAuditJsonKeysEnum.DETAILS.getAuditJsonKeyName(), expectedCatrgoryAuditJavaObject.getDetails()); + validateField(map, CategoryAuditJsonKeysEnum.STATUS.getAuditJsonKeyName(), expectedCatrgoryAuditJavaObject.getStatus()); + validateField(map, CategoryAuditJsonKeysEnum.DESCRIPTION.getAuditJsonKeyName(), expectedCatrgoryAuditJavaObject.getDesc()); } @@ -1066,20 +867,13 @@ public class AuditValidationUtils { List> actionToList = getAuditListByAction(expectedCatrgoryAuditJavaObject.getAction(), 1); Map map = actionToList.get(0); validateField(map, CategoryAuditJsonKeysEnum.ACTION.getAuditJsonKeyName(), action); - validateField(map, CategoryAuditJsonKeysEnum.MODIFIER.getAuditJsonKeyName(), - expectedCatrgoryAuditJavaObject.getModifier()); - validateField(map, CategoryAuditJsonKeysEnum.CATEGORY_NAME.getAuditJsonKeyName(), - expectedCatrgoryAuditJavaObject.getCategoryName()); - validateField(map, CategoryAuditJsonKeysEnum.SUB_CATEGORY_NAME.getAuditJsonKeyName(), - expectedCatrgoryAuditJavaObject.getSubCategoryName()); - validateField(map, CategoryAuditJsonKeysEnum.GROUPING_NAME.getAuditJsonKeyName(), - expectedCatrgoryAuditJavaObject.getGroupingName()); - validateField(map, CategoryAuditJsonKeysEnum.RESOURCE_TYPE.getAuditJsonKeyName(), - expectedCatrgoryAuditJavaObject.getResourceType()); - validateField(map, CategoryAuditJsonKeysEnum.STATUS.getAuditJsonKeyName(), - expectedCatrgoryAuditJavaObject.getStatus()); - validateField(map, CategoryAuditJsonKeysEnum.DESCRIPTION.getAuditJsonKeyName(), - expectedCatrgoryAuditJavaObject.getDesc()); + validateField(map, CategoryAuditJsonKeysEnum.MODIFIER.getAuditJsonKeyName(), expectedCatrgoryAuditJavaObject.getModifier()); + validateField(map, CategoryAuditJsonKeysEnum.CATEGORY_NAME.getAuditJsonKeyName(), expectedCatrgoryAuditJavaObject.getCategoryName()); + validateField(map, CategoryAuditJsonKeysEnum.SUB_CATEGORY_NAME.getAuditJsonKeyName(), expectedCatrgoryAuditJavaObject.getSubCategoryName()); + validateField(map, CategoryAuditJsonKeysEnum.GROUPING_NAME.getAuditJsonKeyName(), expectedCatrgoryAuditJavaObject.getGroupingName()); + validateField(map, CategoryAuditJsonKeysEnum.RESOURCE_TYPE.getAuditJsonKeyName(), expectedCatrgoryAuditJavaObject.getResourceType()); + validateField(map, CategoryAuditJsonKeysEnum.STATUS.getAuditJsonKeyName(), expectedCatrgoryAuditJavaObject.getStatus()); + validateField(map, CategoryAuditJsonKeysEnum.DESCRIPTION.getAuditJsonKeyName(), expectedCatrgoryAuditJavaObject.getDesc()); } public static void GetCategoryHierarchyAuditSuccess(String action, String componentType, User user, int status) @@ -1122,60 +916,6 @@ public class AuditValidationUtils { return sb.toString(); } - public static ExpectedResourceAuditJavaObject expectedMissingInformationAuditObject(String Action, - String resourceUid, ComponentType resourceType) throws FileNotFoundException { - ExpectedResourceAuditJavaObject expectedAudit = new ExpectedResourceAuditJavaObject(); - expectedAudit.setAction(Action); - expectedAudit.setResourceName(resourceUid); - expectedAudit.setResourceType(resourceType.getValue()); - expectedAudit.setPrevVersion(""); - expectedAudit.setCurrVersion(""); - expectedAudit.setModifierName(""); - expectedAudit.setModifierUid(""); - expectedAudit.setPrevState(""); - expectedAudit.setCurrState(""); - expectedAudit.setPrevArtifactUuid(""); - expectedAudit.setCurrArtifactUuid(""); - expectedAudit.setArtifactData(""); - expectedAudit.setStatus("403"); - expectedAudit.setDesc(buildAuditDescription( - new ErrorValidationUtils().parseErrorConfigYaml(ActionStatus.MISSING_INFORMATION.name()), - new ArrayList())); - return expectedAudit; - } - - public static ExpectedResourceAuditJavaObject expectedComponentNotFoundAuditObject(String Action, - String resourceUid, ComponentType resourceType, String artifactUid, User user, - ArrayList notFoundComponent) throws FileNotFoundException { - String desc = null; - - ExpectedResourceAuditJavaObject expectedAudit = new ExpectedResourceAuditJavaObject(); - expectedAudit.setAction(Action); - expectedAudit.setResourceName(resourceUid); - expectedAudit.setResourceType(resourceType.getValue()); - expectedAudit.setPrevVersion(""); - expectedAudit.setCurrVersion(""); - expectedAudit.setModifierName(user.getFirstName() + " " + user.getLastName()); - expectedAudit.setModifierUid(user.getUserId()); - expectedAudit.setPrevState(""); - expectedAudit.setCurrState(""); - expectedAudit.setPrevArtifactUuid(""); - expectedAudit.setCurrArtifactUuid(artifactUid); - expectedAudit.setArtifactData(""); - expectedAudit.setStatus("404"); - - if (resourceType.getValue() == ComponentType.SERVICE.getValue()) { - desc = buildAuditDescription( - new ErrorValidationUtils().parseErrorConfigYaml(ActionStatus.SERVICE_NOT_FOUND.name()), - notFoundComponent); - } else if (resourceType.getValue() == ComponentType.RESOURCE.getValue()) - desc = buildAuditDescription( - new ErrorValidationUtils().parseErrorConfigYaml(ActionStatus.RESOURCE_NOT_FOUND.name()), - notFoundComponent); - - expectedAudit.setDesc(desc); - return expectedAudit; - } public static ExpectedResourceAuditJavaObject expectedArtifactNotFoundAuditObject(String Action, String resourceUid, ComponentType resourceType, String artifactUid, User user, String currState, String currVersion) @@ -1205,144 +945,27 @@ public class AuditValidationUtils { return expectedAudit; } - public static ExpectedResourceAuditJavaObject expectedArtifactNotFoundAuditObject(String Action, - String resourceName, ComponentType resourceType, String artifactUid, LifecycleStateEnum lifecycle, - User user, String currVersion) throws FileNotFoundException { - String desc = null; - - ExpectedResourceAuditJavaObject expectedAudit = new ExpectedResourceAuditJavaObject(); - expectedAudit.setAction(Action); - expectedAudit.setResourceName(resourceName); - expectedAudit.setResourceType(resourceType.getValue()); - expectedAudit.setPrevVersion(""); - expectedAudit.setCurrVersion(currVersion); - expectedAudit.setModifierName(user.getFirstName() + " " + user.getLastName()); - expectedAudit.setModifierUid(user.getUserId()); - expectedAudit.setPrevState(""); - expectedAudit.setCurrState(lifecycle.name()); - expectedAudit.setPrevArtifactUuid(""); - expectedAudit.setCurrArtifactUuid(artifactUid); - expectedAudit.setArtifactData(""); - expectedAudit.setStatus("404"); - - desc = buildAuditDescription( - new ErrorValidationUtils().parseErrorConfigYaml(ActionStatus.ARTIFACT_NOT_FOUND.name()), - new ArrayList()); - - expectedAudit.setDesc(desc); - return expectedAudit; - } - - public static ExpectedResourceAuditJavaObject expectedRestrictedOperationAuditObject(String Action, - String resourceNameOrUid, ComponentType resourceType, String artifactUid, User user, String currVersion, - String currState) throws FileNotFoundException { - String desc = null; - - ExpectedResourceAuditJavaObject expectedAudit = new ExpectedResourceAuditJavaObject(); - expectedAudit.setAction(Action); - expectedAudit.setResourceName(resourceNameOrUid); - expectedAudit.setResourceType(resourceType.getValue()); - expectedAudit.setPrevVersion(""); - expectedAudit.setCurrVersion(currVersion); - expectedAudit.setModifierName(user.getFirstName() + " " + user.getLastName()); - expectedAudit.setModifierUid(user.getUserId()); - expectedAudit.setPrevState(""); - expectedAudit.setCurrState(currState); - expectedAudit.setPrevArtifactUuid(""); - expectedAudit.setCurrArtifactUuid(artifactUid); - expectedAudit.setArtifactData(""); - expectedAudit.setStatus("409"); - - desc = buildAuditDescription( - new ErrorValidationUtils().parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name()), - new ArrayList()); - - expectedAudit.setDesc(desc); - return expectedAudit; - } - - public static ExpectedResourceAuditJavaObject expectedInvalidContentAuditObject(String Action, String resourceName, - ComponentType resourceType, String artifactUid, User user, String currVersion, String currState, - ArrayList invalidContentList) throws FileNotFoundException { - return expectedInvalidContentAuditObject(ActionStatus.INVALID_CONTENT, Action, resourceName, resourceType, - artifactUid, user, currVersion, currState, invalidContentList); - } - - public static ExpectedResourceAuditJavaObject expectedInvalidContentAuditObject(ActionStatus actionStatus, - String Action, String resourceName, ComponentType resourceType, String artifactUid, User user, - String currVersion, String currState, ArrayList invalidContentList) throws FileNotFoundException { - String desc = null; - - ExpectedResourceAuditJavaObject expectedAudit = new ExpectedResourceAuditJavaObject(); - expectedAudit.setAction(Action); - expectedAudit.setResourceName(resourceName); - expectedAudit.setResourceType(resourceType.getValue()); - expectedAudit.setPrevVersion(""); - expectedAudit.setCurrVersion(currVersion); - expectedAudit.setModifierName(user.getFirstName() + " " + user.getLastName()); - expectedAudit.setModifierUid(user.getUserId()); - expectedAudit.setPrevState(""); - expectedAudit.setCurrState(currState); - expectedAudit.setPrevArtifactUuid(""); - expectedAudit.setCurrArtifactUuid(artifactUid); - expectedAudit.setArtifactData(""); - expectedAudit.setStatus("400"); - - desc = buildAuditDescription(new ErrorValidationUtils().parseErrorConfigYaml(actionStatus.name()), - invalidContentList); - - expectedAudit.setDesc(desc); - return expectedAudit; - } - - public static ExpectedResourceAuditJavaObject expectedSuccessAuditObject(String Action, String resourceName, - ComponentType resourceType, ArtifactReqDetails artifactReq, User user, String currVersion, String currState, - String prevArtifactUuid) throws FileNotFoundException { - ExpectedResourceAuditJavaObject expectedAudit = new ExpectedResourceAuditJavaObject(); - expectedAudit.setAction(Action); - expectedAudit.setResourceName(resourceName); - expectedAudit.setResourceType(resourceType.getValue()); - expectedAudit.setPrevVersion(""); - expectedAudit.setCurrVersion(currVersion); - expectedAudit.setModifierName(user.getFirstName() + " " + user.getLastName()); - expectedAudit.setModifierUid(user.getUserId()); - expectedAudit.setPrevState(""); - expectedAudit.setCurrState(currState); - expectedAudit.setPrevArtifactUuid(prevArtifactUuid); - expectedAudit.setCurrArtifactUuid(artifactReq.getUniqueId()); - expectedAudit - .setArtifactData(buildArtifactDataAudit(ArtifactUtils.convertArtifactReqToDefinition(artifactReq))); - expectedAudit.setStatus("200"); - expectedAudit.setDesc("OK"); - return expectedAudit; - } - public static JSONObject filterAuditByUuid(String action, String uuid) throws Exception { - Map actionMap = new HashMap(); + Map actionMap = new HashMap<>(); actionMap.put("ACTION", action); JSONObject actionJsonObject = new JSONObject(actionMap); - Map uuidMap = new HashMap(); + Map uuidMap = new HashMap<>(); uuidMap.put("SERVICE_INSTANCE_ID", uuid); JSONObject uuidJsonObject = new JSONObject(uuidMap); - List filters = new ArrayList(Arrays.asList(actionJsonObject, uuidJsonObject)); + List filters = new ArrayList<>(Arrays.asList(actionJsonObject, uuidJsonObject)); JSONObject body = buildElasticQueryBody(filters); return body; } - public static void validateAudit(ExpectedResourceAuditJavaObject resourceAuditJavaObject, String action) - throws Exception { + public static void validateAudit(ExpectedResourceAuditJavaObject resourceAuditJavaObject, String action) throws Exception { List> actionToList = getAuditListByAction(resourceAuditJavaObject.getAction(), 1); Map map2 = actionToList.get(0); validateField(map2, AuditJsonKeysEnum.ACTION.getAuditJsonKeyName(), action); - validateField(map2, AuditJsonKeysEnum.RESOURCE_NAME.getAuditJsonKeyName(), - resourceAuditJavaObject.getResourceName()); - validateField(map2, AuditJsonKeysEnum.RESOURCE_TYPE.getAuditJsonKeyName(), - resourceAuditJavaObject.getResourceType()); - validateField(map2, AuditJsonKeysEnum.PREV_VERSION.getAuditJsonKeyName(), - resourceAuditJavaObject.getPrevVersion()); - validateField(map2, AuditJsonKeysEnum.CURR_VERSION.getAuditJsonKeyName(), - resourceAuditJavaObject.getCurrVersion()); + validateField(map2, AuditJsonKeysEnum.RESOURCE_NAME.getAuditJsonKeyName(), resourceAuditJavaObject.getResourceName()); + validateField(map2, AuditJsonKeysEnum.RESOURCE_TYPE.getAuditJsonKeyName(), resourceAuditJavaObject.getResourceType()); + validateField(map2, AuditJsonKeysEnum.PREV_VERSION.getAuditJsonKeyName(), resourceAuditJavaObject.getPrevVersion()); + validateField(map2, AuditJsonKeysEnum.CURR_VERSION.getAuditJsonKeyName(), resourceAuditJavaObject.getCurrVersion()); validateField(map2, AuditJsonKeysEnum.MODIFIER.getAuditJsonKeyName(), resourceAuditJavaObject.getMODIFIER()); validateField(map2, AuditJsonKeysEnum.PREV_STATE.getAuditJsonKeyName(), resourceAuditJavaObject.getPrevState()); validateField(map2, AuditJsonKeysEnum.CURR_STATE.getAuditJsonKeyName(), resourceAuditJavaObject.getCurrState()); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/AssetLifeCycle.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/AssetLifeCycle.java index 2d50ebffcc..91effad4c4 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/AssetLifeCycle.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/AssetLifeCycle.java @@ -20,12 +20,9 @@ package org.openecomp.sdc.externalApis; -import static java.util.Arrays.asList; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - +import com.aventstack.extentreports.Status; +import com.google.gson.Gson; +import fj.data.Either; import org.json.simple.parser.JSONParser; import org.junit.Rule; import org.junit.rules.TestName; @@ -33,41 +30,16 @@ import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.enums.AssetTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; -import org.openecomp.sdc.be.model.ArtifactDefinition; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.Resource; -import org.openecomp.sdc.be.model.Service; -import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; +import org.openecomp.sdc.be.model.*; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.config.Config; -import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ResourceAssetStructure; -import org.openecomp.sdc.ci.tests.datatypes.ResourceDetailedAssetStructure; -import org.openecomp.sdc.ci.tests.datatypes.ResourceExternalReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.SearchCriteriaEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; -import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaObject; +import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; -import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.AssetRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtilsExternalAPI; -import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; -import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils; +import org.openecomp.sdc.ci.tests.utils.rest.*; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; @@ -75,11 +47,6 @@ import org.testng.SkipException; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import com.aventstack.extentreports.Status; -import com.google.gson.Gson; - -import fj.data.Either; - public class AssetLifeCycle extends ComponentBaseTest { private static Logger log = LoggerFactory.getLogger(CRUDExternalAPI.class.getName()); @@ -153,12 +120,12 @@ public class AssetLifeCycle extends ComponentBaseTest { Component resourceDetails = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, defaultResource.getName(), defaultResource.getVersion()); Assert.assertEquals(resourceDetails.getLifecycleState().toString(), LifeCycleStatesEnum.CHECKIN.getComponentState().toString(), "Life cycle state not changed."); - // auditing verification + /*// auditing verification AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API; Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, parsedCreatedResponse.getName()); ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, defaultUser, LifeCycleStatesEnum.CHECKIN, AssetTypeEnum.RESOURCES); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ restResponse = LifecycleRestUtils.checkOutResource(parsedCreatedResponse.getUuid(), defaultUser); Assert.assertEquals(restResponse.getErrorCode(), (Integer)STATUS_CODE_CREATED, "Fail to check out."); @@ -166,7 +133,7 @@ public class AssetLifeCycle extends ComponentBaseTest { resourceDetails = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, defaultResource.getName(), String.format("%.1f", Double.parseDouble(defaultResource.getVersion()) + 0.1)); Assert.assertEquals(resourceDetails.getLifecycleState().toString(), LifeCycleStatesEnum.CHECKOUT.getComponentState().toString(), "Life cycle state not changed."); - // auditing verification + /*// auditing verification body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, parsedCreatedResponse.getName()); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_STATE, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.toString()); @@ -174,7 +141,7 @@ public class AssetLifeCycle extends ComponentBaseTest { expectedResourceAuditJavaObject.setCurrVersion("0.2"); expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.toString()); expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.toString()); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ } @@ -193,12 +160,12 @@ public class AssetLifeCycle extends ComponentBaseTest { resourceDetails = AtomicOperationUtils.getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceDetails.getName(), resourceDetails.getVersion()); Assert.assertEquals(resourceDetails.getLifecycleState().toString(), LifeCycleStatesEnum.CHECKIN.getComponentState().toString(), "Life cycle state not changed."); - // auditing verification + /*// auditing verification AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API; Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName()); ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, defaultUser, LifeCycleStatesEnum.CHECKIN, AssetTypeEnum.SERVICES); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ restResponse = LifecycleRestUtils.checkOutService(resourceDetails.getUUID(), defaultUser); Assert.assertEquals(restResponse.getErrorCode(), (Integer)STATUS_CODE_CREATED, "Fail to check out."); @@ -206,7 +173,7 @@ public class AssetLifeCycle extends ComponentBaseTest { resourceDetails = AtomicOperationUtils.getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceDetails.getName(), String.format("%.1f", Double.parseDouble(resourceDetails.getVersion()) + 0.1)); Assert.assertEquals(resourceDetails.getLifecycleState().toString(), LifeCycleStatesEnum.CHECKOUT.getComponentState().toString(), "Life cycle state not changed."); - // auditing verification + /*// auditing verification body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName()); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_STATE, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.toString()); @@ -214,7 +181,7 @@ public class AssetLifeCycle extends ComponentBaseTest { expectedResourceAuditJavaObject.setCurrVersion("0.2"); expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.toString()); expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.toString()); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -274,7 +241,7 @@ public class AssetLifeCycle extends ComponentBaseTest { } Assert.assertEquals(restResponse.getErrorCode(), (Integer)STATUS_CODE_NOT_FOUND, "Asset found."); - // auditing verification + /* // auditing verification AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API; Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, String.format("/sdc/v1/catalog/%s/%s/lifecycleState/%s", assetTypeEnum.getValue().toLowerCase(), assetUUID, lifeCycleStatesEnum.getState())); @@ -283,7 +250,7 @@ public class AssetLifeCycle extends ComponentBaseTest { List variables = asList(assetUUID); expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -304,14 +271,12 @@ public class AssetLifeCycle extends ComponentBaseTest { // US849997 - Story [BE]: External API for asset lifecycle - checkout @Test(dataProvider="invalidUserCheckinForCheckedOutService") public void invalidUserCheckinForCheckedOutService(User defaultUser) throws Exception { - Component resourceDetails = null; - Either createdComponent = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true); - resourceDetails = createdComponent.left().value(); - + Component resourceDetails = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value(); + RestResponse restResponse = LifecycleRestUtils.checkInService(resourceDetails.getUUID(), defaultUser); Assert.assertEquals(restResponse.getErrorCode(), (Integer)RESTRICTED_OPERATION, "Expected for restricted operation."); - // auditing verification + /*// auditing verification AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API; Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName()); @@ -321,7 +286,7 @@ public class AssetLifeCycle extends ComponentBaseTest { ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name()); List variables = asList(""); expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ } @DataProvider(name="invalidUserCheckinForCheckedInService") @@ -348,7 +313,7 @@ public class AssetLifeCycle extends ComponentBaseTest { RestResponse restResponse = LifecycleRestUtils.checkInService(resourceDetails.getUUID(), defaultUser); Assert.assertEquals(restResponse.getErrorCode(), (Integer)RESTRICTED_OPERATION, "Expected for restricted operation."); - // auditing verification + /*// auditing verification AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API; Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName()); @@ -359,7 +324,7 @@ public class AssetLifeCycle extends ComponentBaseTest { ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name()); List variables = asList(""); expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ } @DataProvider(name="invalidUserCheckoutForCheckedOutService") @@ -378,14 +343,12 @@ public class AssetLifeCycle extends ComponentBaseTest { // US849997 - Story [BE]: External API for asset lifecycle - checkout @Test(dataProvider="invalidUserCheckoutForCheckedOutService") public void invalidUserCheckoutForCheckedOutService(User defaultUser) throws Exception { - Component resourceDetails = null; - Either createdComponent = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true); - resourceDetails = createdComponent.left().value(); - + + Component resourceDetails = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value(); RestResponse restResponse = LifecycleRestUtils.checkOutService(resourceDetails.getUUID(), defaultUser); Assert.assertEquals(restResponse.getErrorCode(), (Integer)RESTRICTED_OPERATION, "Expected for restricted operation."); - // auditing verification + /* // auditing verification AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API; Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName()); @@ -395,7 +358,7 @@ public class AssetLifeCycle extends ComponentBaseTest { ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name()); List variables = asList(""); expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ } @DataProvider(name="invalidUserCheckoutForCheckedInService") @@ -414,15 +377,13 @@ public class AssetLifeCycle extends ComponentBaseTest { // US849997 - Story [BE]: External API for asset lifecycle - checkout @Test(dataProvider="invalidUserCheckoutForCheckedInService") public void invalidUserCheckoutForCheckedInService(User defaultUser) throws Exception { - Component resourceDetails = null; - Either createdComponent = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true); - resourceDetails = createdComponent.left().value(); + Component resourceDetails = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value(); resourceDetails = AtomicOperationUtils.changeComponentState(resourceDetails, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); RestResponse restResponse = LifecycleRestUtils.checkOutService(resourceDetails.getUUID(), defaultUser); Assert.assertEquals(restResponse.getErrorCode(), (Integer)RESTRICTED_OPERATION, "Expected for restricted operation."); - // auditing verification + /* // auditing verification AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API; Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName()); @@ -433,7 +394,7 @@ public class AssetLifeCycle extends ComponentBaseTest { ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name()); List variables = asList(""); expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ } @DataProvider(name="invalidUserCheckinForCheckedOutResource") @@ -452,14 +413,12 @@ public class AssetLifeCycle extends ComponentBaseTest { // US849997 - Story [BE]: External API for asset lifecycle - checkout @Test(dataProvider="invalidUserCheckinForCheckedOutResource") public void invalidUserCheckinForCheckedOutResource(User defaultUser) throws Exception { - Component resourceDetails = null; - Either createdComponent = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, UserRoleEnum.DESIGNER, true); - resourceDetails = createdComponent.left().value(); - + + Component resourceDetails = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, UserRoleEnum.DESIGNER, true).left().value(); RestResponse restResponse = LifecycleRestUtils.checkInResource(resourceDetails.getUUID(), defaultUser); Assert.assertEquals(restResponse.getErrorCode(), (Integer)RESTRICTED_OPERATION, "Expected for restricted operation."); - // auditing verification + /*// auditing verification AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API; Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName()); @@ -469,7 +428,7 @@ public class AssetLifeCycle extends ComponentBaseTest { ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name()); List variables = asList(""); expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ } @DataProvider(name="invalidUserCheckinForCheckedInResource") @@ -496,7 +455,7 @@ public class AssetLifeCycle extends ComponentBaseTest { RestResponse restResponse = LifecycleRestUtils.checkInResource(resourceDetails.getUUID(), defaultUser); Assert.assertEquals(restResponse.getErrorCode(), (Integer)RESTRICTED_OPERATION, "Expected for restricted operation."); - // auditing verification + /*// auditing verification AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API; Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName()); @@ -507,7 +466,7 @@ public class AssetLifeCycle extends ComponentBaseTest { ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name()); List variables = asList(""); expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ } @DataProvider(name="invalidUserCheckoutForCheckedOutResource") @@ -526,14 +485,12 @@ public class AssetLifeCycle extends ComponentBaseTest { // US849997 - Story [BE]: External API for asset lifecycle - checkout @Test(dataProvider="invalidUserCheckoutForCheckedOutResource") public void invalidUserCheckoutForCheckedOutResource(User defaultUser) throws Exception { - Component resourceDetails = null; - Either createdComponent = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, UserRoleEnum.DESIGNER, true); - resourceDetails = createdComponent.left().value(); - + + Component resourceDetails = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, UserRoleEnum.DESIGNER, true).left().value(); RestResponse restResponse = LifecycleRestUtils.checkOutResource(resourceDetails.getUUID(), defaultUser); Assert.assertEquals(restResponse.getErrorCode(), (Integer)RESTRICTED_OPERATION, "Expected for restricted operation."); - // auditing verification + /*// auditing verification AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API; Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName()); @@ -543,7 +500,7 @@ public class AssetLifeCycle extends ComponentBaseTest { ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name()); List variables = asList(""); expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ } @DataProvider(name="invalidUserCheckoutForCheckedInResource") @@ -562,15 +519,14 @@ public class AssetLifeCycle extends ComponentBaseTest { // US849997 - Story [BE]: External API for asset lifecycle - checkout @Test(dataProvider="invalidUserCheckoutForCheckedInResource") public void invalidUserCheckoutForCheckedInResource(User defaultUser) throws Exception { - Component resourceDetails = null; - Either createdComponent = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, UserRoleEnum.DESIGNER, true); - resourceDetails = createdComponent.left().value(); + + Component resourceDetails = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, UserRoleEnum.DESIGNER, true).left().value(); resourceDetails = AtomicOperationUtils.changeComponentState(resourceDetails, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); RestResponse restResponse = LifecycleRestUtils.checkOutResource(resourceDetails.getUUID(), defaultUser); Assert.assertEquals(restResponse.getErrorCode(), (Integer)RESTRICTED_OPERATION, "Expected for restricted operation."); - // auditing verification + /*// auditing verification AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API; Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName()); @@ -581,7 +537,7 @@ public class AssetLifeCycle extends ComponentBaseTest { ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name()); List variables = asList(""); expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -653,7 +609,7 @@ public class AssetLifeCycle extends ComponentBaseTest { Assert.assertEquals(restResponse.getErrorCode(), (Integer)errorCode, "Expected that response code will be equal."); - // auditing verification + /*// auditing verification AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API; Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName()); @@ -680,7 +636,7 @@ public class AssetLifeCycle extends ComponentBaseTest { } expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ } @@ -756,7 +712,7 @@ public class AssetLifeCycle extends ComponentBaseTest { Assert.assertEquals(restResponse.getErrorCode(), (Integer)errorCode, "Expected that response code will be equal."); - // auditing verification + /*// auditing verification AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API; Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName()); @@ -783,7 +739,7 @@ public class AssetLifeCycle extends ComponentBaseTest { } expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ } @@ -803,7 +759,7 @@ public class AssetLifeCycle extends ComponentBaseTest { // Certification request restResponse = LifecycleRestUtils.certificationRequestResource(resourceDetails.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - // Auditing verification + /*// Auditing verification AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API; Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName()); @@ -811,19 +767,19 @@ public class AssetLifeCycle extends ComponentBaseTest { ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, defaultUser, LifeCycleStatesEnum.CERTIFICATIONREQUEST, AssetTypeEnum.RESOURCES); expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.toString()); expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.READY_FOR_CERTIFICATION.toString()); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ // Start testing restResponse = LifecycleRestUtils.startTestingResource(resourceDetails.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.TESTER)); - // Auditing verification + /* // Auditing verification body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName()); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, String.format("/sdc/v1/catalog/%s/%s/lifecycleState/%s", AssetTypeEnum.RESOURCES.getValue().toLowerCase(), resourceDetails.getUUID(), LifeCycleStatesEnum.STARTCERTIFICATION.getState())); expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION, AssetTypeEnum.RESOURCES); expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.READY_FOR_CERTIFICATION.toString()); expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS.toString()); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ } // US824692 - Story [BE]: External API for asset lifecycle - submit for test / start testing @@ -836,7 +792,7 @@ public class AssetLifeCycle extends ComponentBaseTest { // Certification request restResponse = LifecycleRestUtils.certificationRequestService(resourceDetails.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - // Auditing verification + /*// Auditing verification AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API; Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName()); @@ -844,19 +800,19 @@ public class AssetLifeCycle extends ComponentBaseTest { ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, defaultUser, LifeCycleStatesEnum.CERTIFICATIONREQUEST, AssetTypeEnum.SERVICES); expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.toString()); expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.READY_FOR_CERTIFICATION.toString()); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ // Start testing restResponse = LifecycleRestUtils.startTestingService(resourceDetails.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.TESTER)); - // Auditing verification + /* // Auditing verification body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName()); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, String.format("/sdc/v1/catalog/%s/%s/lifecycleState/%s", AssetTypeEnum.SERVICES.getValue().toLowerCase(), resourceDetails.getUUID(), LifeCycleStatesEnum.STARTCERTIFICATION.getState())); expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION, AssetTypeEnum.SERVICES); expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.READY_FOR_CERTIFICATION.toString()); expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS.toString()); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ } // US824692 - Story [BE]: External API for asset lifecycle - submit for test / start testing @@ -869,7 +825,7 @@ public class AssetLifeCycle extends ComponentBaseTest { // Certification request restResponse = LifecycleRestUtils.certificationRequestResource(resourceDetails.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - // Auditing verification + /*// Auditing verification AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API; Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName()); @@ -883,7 +839,7 @@ public class AssetLifeCycle extends ComponentBaseTest { List variables = asList(LifeCycleStatesEnum.CERTIFICATIONREQUEST.getState()); expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ } // US824692 - Story [BE]: External API for asset lifecycle - submit for test / start testing @@ -896,7 +852,7 @@ public class AssetLifeCycle extends ComponentBaseTest { // Certification request restResponse = LifecycleRestUtils.startTestingResource(resourceDetails.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.TESTER)); - // Auditing verification + /*// Auditing verification AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API; Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName()); @@ -910,7 +866,7 @@ public class AssetLifeCycle extends ComponentBaseTest { List variables = asList(LifeCycleStatesEnum.STARTCERTIFICATION.getState()); expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ } @@ -938,7 +894,7 @@ public class AssetLifeCycle extends ComponentBaseTest { // Certify restResponse = LifecycleRestUtils.certifyResource(resourceDetails.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.TESTER)); - // Auditing verification + /*// Auditing verification AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API; Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName()); @@ -947,7 +903,7 @@ public class AssetLifeCycle extends ComponentBaseTest { expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS.toString()); expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.CERTIFIED.toString()); expectedResourceAuditJavaObject.setCurrVersion("1.0"); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ } @@ -967,7 +923,7 @@ public class AssetLifeCycle extends ComponentBaseTest { // Certify restResponse = LifecycleRestUtils.certifyService(resourceDetails.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.TESTER)); - // Auditing verification + /*// Auditing verification AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API; Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName()); @@ -976,7 +932,7 @@ public class AssetLifeCycle extends ComponentBaseTest { expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS.toString()); expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.CERTIFIED.toString()); expectedResourceAuditJavaObject.setCurrVersion("1.0"); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ } @@ -1017,7 +973,9 @@ public class AssetLifeCycle extends ComponentBaseTest { ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("ci", "OTHER", true, false); RestResponse uploadArtifactRestResponse = ArtifactRestUtils.externalAPIUploadArtifactOfTheAsset(initComponentVersion, defaultUser, artifactReqDetails); BaseRestUtils.checkSuccess(uploadArtifactRestResponse); - ArtifactDefinition responseArtifact = ArtifactRestUtils.getArtifactDataFromJson(uploadArtifactRestResponse.getResponse()); + + ArtifactDefinition responseArtifact = ResponseParser.convertArtifactDefinitionResponseToJavaObject(uploadArtifactRestResponse.getResponse()); +// ArtifactDefinition responseArtifact = ArtifactRestUtils.getArtifactDataFromJson(uploadArtifactRestResponse.getResponse()); initComponentVersion = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, parsedCreatedResponse.getName(), parsedCreatedResponse.getVersion()); // 5. Update artifact via external API. @@ -1033,13 +991,13 @@ public class AssetLifeCycle extends ComponentBaseTest { Assert.assertEquals(parsedCreatedResponse.getUuid(), initComponentVersion.getUUID(), "Expect that UUID will not change."); Assert.assertEquals(parsedCreatedResponse.getInvariantUUID(), initComponentVersion.getInvariantUUID(), "Expected that invariantUUID will not change."); - // Auditing verification + /* // Auditing verification AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API; Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, initComponentVersion.getName()); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, String.format("/sdc/v1/catalog/%s/%s/lifecycleState/%s", AssetTypeEnum.RESOURCES.getValue().toLowerCase(), initComponentVersion.getUUID(), LifeCycleStatesEnum.CHECKIN.getState())); ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(initComponentVersion, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CHECKIN, AssetTypeEnum.RESOURCES); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ // 7. Then checkout the VFCMT via external API. RestResponse checkOutRestResponse = LifecycleRestUtils.checkOutResource(initComponentVersion.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); @@ -1049,7 +1007,7 @@ public class AssetLifeCycle extends ComponentBaseTest { Assert.assertEquals(parsedCreatedResponse.getUuid(), initComponentVersion.getUUID(), "Expect that UUID will not change."); Assert.assertEquals(parsedCreatedResponse.getInvariantUUID(), initComponentVersion.getInvariantUUID(), "Expected that invariantUUID will not change."); - // Auditing verification + /*// Auditing verification body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, initComponentVersion.getName()); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, String.format("/sdc/v1/catalog/%s/%s/lifecycleState/%s", AssetTypeEnum.RESOURCES.getValue().toLowerCase(), initComponentVersion.getUUID(), LifeCycleStatesEnum.CHECKOUT.getState())); @@ -1057,7 +1015,7 @@ public class AssetLifeCycle extends ComponentBaseTest { expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.toString()); expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.toString()); expectedResourceAuditJavaObject.setCurrVersion("0.2"); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ // 8. The minor version must be incremented, the invariantUUID, and UUID must stay the same, the uniqueId should be changed, the artifacts from first version exists on the new version. Component newComponentVersion = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, parsedCreatedResponse.getName(), String.format("%.1f", Double.parseDouble(parsedCreatedResponse.getVersion()))); @@ -1078,7 +1036,7 @@ public class AssetLifeCycle extends ComponentBaseTest { Assert.assertEquals(parsedCreatedResponse.getUuid(), initComponentVersion.getUUID(), "Expect that UUID will not change."); Assert.assertEquals(parsedCreatedResponse.getInvariantUUID(), initComponentVersion.getInvariantUUID(), "Expected that invariantUUID will not change."); - // Auditing verification + /*// Auditing verification body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, initComponentVersion.getName()); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, String.format("/sdc/v1/catalog/%s/%s/lifecycleState/%s", AssetTypeEnum.RESOURCES.getValue().toLowerCase(), initComponentVersion.getUUID(), LifeCycleStatesEnum.CHECKIN.getState())); @@ -1087,8 +1045,8 @@ public class AssetLifeCycle extends ComponentBaseTest { expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.toString()); expectedResourceAuditJavaObject.setCurrVersion("0.2"); expectedResourceAuditJavaObject.setPrevVersion("0.2"); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); - + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ + // 11. Certify via external API. RestResponse certifyRestResponse = LifecycleRestUtils.certifyResource(initComponentVersion.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); BaseRestUtils.checkCreateResponse(certifyRestResponse); @@ -1097,7 +1055,7 @@ public class AssetLifeCycle extends ComponentBaseTest { Assert.assertEquals(parsedCreatedResponse.getUuid(), initComponentVersion.getUUID(), "Expect that UUID will not change."); Assert.assertEquals(parsedCreatedResponse.getInvariantUUID(), initComponentVersion.getInvariantUUID(), "Expected that invariantUUID will not change."); - // Auditing verification + /*// Auditing verification body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, initComponentVersion.getName()); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, String.format("/sdc/v1/catalog/%s/%s/lifecycleState/%s", AssetTypeEnum.RESOURCES.getValue().toLowerCase(), initComponentVersion.getUUID(), LifeCycleStatesEnum.CERTIFY.getState())); @@ -1106,7 +1064,7 @@ public class AssetLifeCycle extends ComponentBaseTest { expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.CERTIFIED.toString()); expectedResourceAuditJavaObject.setCurrVersion("1.0"); expectedResourceAuditJavaObject.setPrevVersion("0.2"); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ // 12. Check out via external API. checkOutRestResponse = LifecycleRestUtils.checkOutResource(initComponentVersion.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); @@ -1116,7 +1074,7 @@ public class AssetLifeCycle extends ComponentBaseTest { Assert.assertNotEquals(parsedCreatedResponse.getUuid(), initComponentVersion.getUUID(), "Expect that UUID will change."); Assert.assertEquals(parsedCreatedResponse.getInvariantUUID(), initComponentVersion.getInvariantUUID(), "Expected that invariantUUID will not change."); - // Auditing verification + /*// Auditing verification body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, initComponentVersion.getName()); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, String.format("/sdc/v1/catalog/%s/%s/lifecycleState/%s", AssetTypeEnum.RESOURCES.getValue().toLowerCase(), initComponentVersion.getUUID(), LifeCycleStatesEnum.CHECKOUT.getState())); @@ -1125,7 +1083,7 @@ public class AssetLifeCycle extends ComponentBaseTest { expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.toString()); expectedResourceAuditJavaObject.setCurrVersion("1.1"); expectedResourceAuditJavaObject.setPrevVersion("1.0"); - AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/ } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/CRUDExternalAPI.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/CRUDExternalAPI.java index 26d1c18907..318316e5ad 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/CRUDExternalAPI.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/CRUDExternalAPI.java @@ -20,75 +20,27 @@ package org.openecomp.sdc.externalApis; -import static java.util.Arrays.asList; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - +import com.aventstack.extentreports.Status; +import fj.data.Either; import org.apache.commons.lang3.StringUtils; -import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpResponseException; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.BasicResponseHandler; -import org.apache.http.util.EntityUtils; -import org.codehaus.jackson.map.DeserializationConfig; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.map.SerializationConfig.Feature; -import org.codehaus.jackson.map.annotate.JsonSerialize; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; import org.junit.Rule; import org.junit.rules.TestName; -import org.openecomp.sdc.be.config.BeEcompErrorManager; import org.openecomp.sdc.be.dao.api.ActionStatus; -import org.openecomp.sdc.be.datatypes.enums.AssetTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; -import org.openecomp.sdc.be.model.ArtifactDefinition; -import org.openecomp.sdc.be.model.ArtifactUiDownloadData; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.ComponentInstance; -import org.openecomp.sdc.be.model.Resource; -import org.openecomp.sdc.be.model.Service; -import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; +import org.openecomp.sdc.be.model.*; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.config.Config; import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails; import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.DistributionNotificationStatusEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; -import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedExternalAudit; -import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; -import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils; -import org.openecomp.sdc.ci.tests.utils.validation.DistributionValidationUtils; +import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; -import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; -import org.openecomp.sdc.common.api.Constants; -import org.openecomp.sdc.common.config.EcompErrorName; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; -import org.openecomp.sdc.common.util.GeneralUtility; import org.openecomp.sdc.common.util.ValidationUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -97,12 +49,11 @@ import org.testng.SkipException; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import com.aventstack.extentreports.Status; -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; +import java.io.IOException; +import java.util.List; +import java.util.Map; -import fj.data.Either; +import static java.util.Arrays.asList; public class CRUDExternalAPI extends ComponentBaseTest { @@ -111,11 +62,6 @@ public class CRUDExternalAPI extends ComponentBaseTest { protected static final String UPLOAD_ARTIFACT_NAME = "TLV_prv.ppk"; protected Config config = Config.instance(); - protected String contentTypeHeaderData = "application/json"; - protected String acceptHeaderDate = "application/json"; - - protected Gson gson = new Gson(); - protected JSONParser jsonParser = new JSONParser(); protected String serviceVersion; protected ResourceReqDetails resourceDetails; @@ -132,7 +78,6 @@ public class CRUDExternalAPI extends ComponentBaseTest { @DataProvider(name="uploadArtifactOnVfcVlCpViaExternalAPI" , parallel=true) public static Object[][] dataProviderUploadArtifactOnVfcVlCpViaExternalAPI() { return new Object[][] { - {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VFC}, {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VFC}, {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VFC}, {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VFC}, @@ -317,7 +262,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { } - @DataProvider(name="uploadArtifactOnServiceViaExternalAPIIncludingDistribution", parallel=true) +/* @DataProvider(name="uploadArtifactOnServiceViaExternalAPIIncludingDistribution", parallel=true) public static Object[][] dataProviderUploadArtifactOnServiceViaExternalAPIIncludingDistribution() { return new Object[][] { {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType()}, @@ -339,7 +284,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { List distributionStatusList = Arrays.asList(DistributionNotificationStatusEnum.DOWNLOAD_OK.toString(), DistributionNotificationStatusEnum.DEPLOY_OK.toString(), DistributionNotificationStatusEnum.NOTIFIED.toString()); DistributionValidationUtils.validateDistributedArtifactsByAudit((Service)component, distributionStatusList); } - } + }*/ // Happy flow - get chosen life cycle state, artifact type and asset type @@ -366,7 +311,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { numberOfArtifact = component.getDeploymentArtifacts().size(); } - ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse()); + ArtifactDefinition responseArtifact = ResponseParser.convertArtifactDefinitionResponseToJavaObject(restResponse.getResponse()); // Get list of deployment artifact + download them via external API Map deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum); Assert.assertEquals(numberOfArtifact, deploymentArtifacts.keySet().size(), "Expected that number of deployment artifacts will be increase by one."); @@ -401,7 +346,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { Assert.assertEquals(responseCode, expectedResponseCode, "Response code is not correct."); - // Check auditing for upload operation + /*// Check auditing for upload operation ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse()); AuditingActionEnum action = AuditingActionEnum.ARTIFACT_UPLOAD_BY_API; @@ -413,7 +358,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, component); expectedExternalAudit.setRESOURCE_NAME(componentInstance.getNormalizedName()); expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + component.getUUID() + "/resourceInstances/" + componentInstance.getNormalizedName() + "/artifacts"); - AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPLOAD_BY_API.getName(), body); + AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPLOAD_BY_API.getName(), body);*/ return restResponse; } @@ -455,7 +400,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { Assert.assertEquals(responseCode, expectedResponseCode, "Response code is not correct."); - // Check auditing for upload operation + /*// Check auditing for upload operation ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse()); AuditingActionEnum action = AuditingActionEnum.ARTIFACT_UPLOAD_BY_API; @@ -465,7 +410,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((component.getComponentType().getValue() + "s").toUpperCase()); ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, component); - AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPLOAD_BY_API.getName(), body); + AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPLOAD_BY_API.getName(), body);*/ return restResponse; } @@ -538,7 +483,6 @@ public class CRUDExternalAPI extends ComponentBaseTest { String response = restResponse.getResponse(); String payloadData = artifactReqDetails.getPayload(); String decodedPaypload = org.openecomp.sdc.ci.tests.utils.Decoder.decode(payloadData); - Assert.assertEquals(response, decodedPaypload, "Response artifact payload not correct."); } @@ -645,8 +589,8 @@ public class CRUDExternalAPI extends ComponentBaseTest { {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VFC}, {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC}, {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC}, - - + + {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VL}, {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VL}, {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VL}, @@ -655,7 +599,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VL}, {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL}, {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL}, - + {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.CP}, {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.CP}, {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.CP}, @@ -664,8 +608,8 @@ public class CRUDExternalAPI extends ComponentBaseTest { {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.CP}, {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP}, {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP}, - - + + {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VFC}, {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VFC}, {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VFC}, @@ -674,7 +618,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VFC}, {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC}, {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC}, - + {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VL}, {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VL}, {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VL}, @@ -683,7 +627,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VL}, {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL}, {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL}, - + {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.CP}, {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.CP}, {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.CP}, @@ -692,7 +636,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.CP}, {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP}, {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP}, - + {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VFC}, {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VFC}, {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VFC}, @@ -701,7 +645,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VFC}, {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC}, {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC}, - + {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VL}, {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VL}, {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VL}, @@ -710,7 +654,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VL}, {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL}, {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL}, - + {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.CP}, {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.CP}, {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.CP}, @@ -1018,7 +962,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { } - ArtifactDefinition artifactDefinition = getArtifactDataFromJson(restResponse.getResponse()); + ArtifactDefinition artifactDefinition = ResponseParser.convertArtifactDefinitionResponseToJavaObject(restResponse.getResponse()); ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_EXIST.name()); List variables = asList(artifactDefinition.getArtifactDisplayName()); @@ -1043,7 +987,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { Integer responseCode = restResponse.getErrorCode(); Assert.assertEquals(responseCode, errorInfo.getCode(), "Response code is not correct."); - // Check auditing for upload operation + /*// Check auditing for upload operation ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse()); AuditingActionEnum action = AuditingActionEnum.ARTIFACT_UPLOAD_BY_API; @@ -1076,7 +1020,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { } } - AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPLOAD_BY_API.getName(), body); + AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPLOAD_BY_API.getName(), body);*/ return restResponse; @@ -1103,7 +1047,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { // = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.EXCEEDS_LIMIT.name()); // List variables = asList("artifact name", "255"); - ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse()); + /*ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse()); AuditingActionEnum action = AuditingActionEnum.ARTIFACT_UPLOAD_BY_API; @@ -1125,7 +1069,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { } else { body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName()); } - AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPLOAD_BY_API.getName(), body); + AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPLOAD_BY_API.getName(), body);*/ return restResponse; @@ -1520,7 +1464,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { } } - @DataProvider(name="updateArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI", parallel=true) + @DataProvider(name="updateArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI", parallel=true) public static Object[][] dataProviderUpdateArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI() { return new Object[][] { {ResourceTypeEnum.VFC}, @@ -1528,14 +1472,10 @@ public class CRUDExternalAPI extends ComponentBaseTest { {ResourceTypeEnum.CP} }; } - + // Verify that it cannot update VFC/VL/CP artifact on VFCi/VLi/CPi - Failure flow @Test(dataProvider="updateArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI") public void updateArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI(ResourceTypeEnum resourceTypeEnum) throws Exception { - - if(true){ - throw new SkipException("Open bug 321612"); - } getExtendTest().log(Status.INFO, String.format("resourceTypeEnum: %s", resourceTypeEnum)); Component resourceInstanceDetails = getComponentInTargetLifeCycleState(ComponentTypeEnum.RESOURCE.getValue(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, resourceTypeEnum); @@ -1546,7 +1486,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { AtomicOperationUtils.addComponentInstanceToComponentContainer(resourceInstanceDetails, component, UserRoleEnum.DESIGNER, true).left().value(); component = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, component.getName(), component.getVersion()); - ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name()); + ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.OK.name()); Map deploymentArtifacts; deploymentArtifacts = getDeploymentArtifactsOfAsset(component, ComponentTypeEnum.RESOURCE_INSTANCE); String artifactUUID = null; @@ -1704,7 +1644,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { } } - @DataProvider(name="updateArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset", parallel=true) + @DataProvider(name="updateArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset", parallel=true) public static Object[][] dataProviderUpdateArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset() { return new Object[][] { {ComponentTypeEnum.RESOURCE, UserRoleEnum.DESIGNER2, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()}, @@ -1757,7 +1697,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { @Test(dataProvider="updateArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset") public void updateArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset(ComponentTypeEnum componentTypeEnum, UserRoleEnum userRoleEnum, LifeCycleStatesEnum lifeCycleStatesEnum, String artifactType) throws Exception { if(true){ - throw new SkipException("Open bug 321612"); + throw new SkipException("Open bug 321612"); } getExtendTest().log(Status.INFO, String.format("componentTypeEnum: %s, userRoleEnum: %s, lifeCycleStatesEnum: %s, artifactType: %s", componentTypeEnum, userRoleEnum, lifeCycleStatesEnum, artifactType)); Component component = uploadArtifactOnAssetViaExternalAPI(componentTypeEnum, LifeCycleStatesEnum.CHECKIN, artifactType, null); @@ -1843,7 +1783,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { Component component = uploadArtifactOnAssetViaExternalAPI(componentTypeEnum, LifeCycleStatesEnum.CHECKIN, artifactType, null); ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name()); List variables = asList(component.getName(), component.getComponentType().toString().toLowerCase(), ElementFactory.getDefaultUser(UserRoleEnum.TESTER).getFirstName(), - ElementFactory.getDefaultUser(UserRoleEnum.TESTER).getLastName(), ElementFactory.getDefaultUser(UserRoleEnum.TESTER).getUserId()); + ElementFactory.getDefaultUser(UserRoleEnum.TESTER).getLastName(), ElementFactory.getDefaultUser(UserRoleEnum.TESTER).getUserId()); updateArtifactOnAssetViaExternalAPI(component, componentTypeEnum, LifeCycleStatesEnum.STARTCERTIFICATION, artifactType, errorInfo, variables, UserRoleEnum.DESIGNER); } @@ -2166,15 +2106,18 @@ public class CRUDExternalAPI extends ComponentBaseTest { String artifactName = artifactReqDetails.getArtifactLabel(); String artifactUUID = deploymentArtifacts.get(artifactName).getArtifactUUID(); String artifactVersionBeforeUpdate = deploymentArtifacts.get(artifactName).getArtifactVersion(); - int numberOfArtifact = deploymentArtifacts.size(); - + int numberOfArtifact = deploymentArtifacts.size(); + + ArtifactReqDetails updateArtifactReqDetails = ElementFactory.getArtifactByType(ArtifactTypeEnum.SNMP_POLL.name(), ArtifactTypeEnum.SNMP_POLL.name(), true, true); + updateArtifactReqDetails.setPayload("dGVzdA=="); + // create component/s & upload artifact via external api if(ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) { updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(userRoleEnum), - component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, variables, chosenLifeCycleState, true); + component.getComponentInstances().get(0), updateArtifactReqDetails, artifactUUID, errorInfo, variables, chosenLifeCycleState, true); } else { updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(userRoleEnum), - null, artifactReqDetails, artifactUUID, errorInfo, variables, chosenLifeCycleState, true); + null, updateArtifactReqDetails, artifactUUID, errorInfo, variables, chosenLifeCycleState, true); } if(component.getComponentType().equals(ComponentTypeEnum.SERVICE)) { @@ -2190,9 +2133,15 @@ public class CRUDExternalAPI extends ComponentBaseTest { deploymentArtifacts = component.getDeploymentArtifacts(); } Assert.assertEquals(numberOfArtifact, deploymentArtifacts.keySet().size(), "Expected that number of deployment artifact will be same as before."); - Assert.assertEquals(String.valueOf((Integer.parseInt(artifactVersionBeforeUpdate))), deploymentArtifacts.get(artifactName).getArtifactVersion(), "Expected that aftifact will not change."); - Assert.assertEquals(artifactUUID, deploymentArtifacts.get(artifactName).getArtifactUUID(), "Expected that aftifactUUID will not change."); Assert.assertEquals(componentVersionBeforeUpdate, component.getVersion(), "Expected that check-out component will not change version number."); + if (errorInfo.getCode().equals(200)) { + Assert.assertNotEquals(String.valueOf((Integer.parseInt(artifactVersionBeforeUpdate))), deploymentArtifacts.get(artifactName).getArtifactVersion(), "Artifact version should be changed."); + Assert.assertNotEquals(artifactUUID, deploymentArtifacts.get(artifactName).getArtifactUUID(), "Artifact UUID should be changed."); + }else{ + Assert.assertEquals(String.valueOf((Integer.parseInt(artifactVersionBeforeUpdate))), deploymentArtifacts.get(artifactName).getArtifactVersion(), "Artifact version should not be changed."); + Assert.assertEquals(artifactUUID, deploymentArtifacts.get(artifactName).getArtifactUUID(), "Artifact UUID should not be changed."); + } + return component; } @@ -2212,7 +2161,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { Assert.assertEquals(responseCode, errorInfo.getCode(), "Response code is not correct."); component = AtomicOperationUtils.getComponentObject(component, UserRoleEnum.DESIGNER); - //TODO + /* //TODO // Check auditing for upload operation ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse()); @@ -2255,7 +2204,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { } } - AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPDATE_BY_API.getName(), body); + AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPDATE_BY_API.getName(), body);*/ return restResponse; } @@ -2349,7 +2298,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { restResponse = updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, artifactUUID, 200); } - ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse()); + ArtifactDefinition responseArtifact = ResponseParser.convertArtifactDefinitionResponseToJavaObject(restResponse.getResponse()); component = getNewerVersionOfComponent(component, chosenLifeCycleState); // Get list of deployment artifact + download them via external API @@ -2379,7 +2328,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { Assert.assertEquals(responseCode, expectedResponseCode, "Response code is not correct."); - // Check auditing for upload operation + /* // Check auditing for upload operation ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse()); AuditingActionEnum action = AuditingActionEnum.ARTIFACT_UPDATE_BY_API; @@ -2392,7 +2341,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { // expectedExternalAudit.setRESOURCE_URL(expectedExternalAudit.getRESOURCE_URL()+ "/" + artifactUUID); expectedExternalAudit.setRESOURCE_NAME(componentInstance.getNormalizedName()); expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + component.getUUID() + "/resourceInstances/" + componentInstance.getNormalizedName() + "/artifacts/" + artifactUUID); - AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPDATE_BY_API.getName(), body); + AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPDATE_BY_API.getName(), body);*/ return restResponse; } @@ -2407,7 +2356,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { Assert.assertEquals(responseCode, expectedResponseCode, "Response code is not correct."); - // Check auditing for upload operation + /* // Check auditing for upload operation ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse()); AuditingActionEnum action = AuditingActionEnum.ARTIFACT_UPDATE_BY_API; @@ -2418,7 +2367,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((component.getComponentType().getValue() + "s").toUpperCase()); ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, component); expectedExternalAudit.setRESOURCE_URL(expectedExternalAudit.getRESOURCE_URL()+ "/" + artifactUUID); - AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPDATE_BY_API.getName(), body); + AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPDATE_BY_API.getName(), body);*/ return restResponse; } @@ -2973,10 +2922,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { // Verify that it cannot delete VFC/VL/CP artifact on VFCi/VLi/CPi - Failure flow @Test(dataProvider="deleteArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI") public void deleteArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI(ResourceTypeEnum resourceTypeEnum) throws Exception { - if(true){ - throw new SkipException("Open bug 321550"); - } - + getExtendTest().log(Status.INFO, String.format("resourceTypeEnum: %s", resourceTypeEnum)); Component resourceInstanceDetails = getComponentInTargetLifeCycleState(ComponentTypeEnum.RESOURCE.getValue(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, resourceTypeEnum); @@ -2987,7 +2933,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { AtomicOperationUtils.addComponentInstanceToComponentContainer(resourceInstanceDetails, component, UserRoleEnum.DESIGNER, true).left().value(); component = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, component.getName(), component.getVersion()); - ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name()); + ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.OK.name()); Map deploymentArtifacts; deploymentArtifacts = getDeploymentArtifactsOfAsset(component, ComponentTypeEnum.RESOURCE_INSTANCE); String artifactUUID = null; @@ -3017,7 +2963,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { Integer responseCode = restResponse.getErrorCode(); Assert.assertEquals(responseCode, errorInfo.getCode(), "Response code is not correct."); - // Check auditing for upload operation + /*// Check auditing for upload operation ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse()); AuditingActionEnum action = AuditingActionEnum.ARTIFACT_DELETE_BY_API; @@ -3062,7 +3008,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { // getExtendTest().log(LogStatus.INFO, "Audit Action: " + AuditingActionEnum.ARTIFACT_DELETE_BY_API.getName()); // body.forEach((k,v)->getExtendTest().log(LogStatus.INFO,"key : " + k + " value : " + v)); - AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_DELETE_BY_API.getName(), body); + AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_DELETE_BY_API.getName(), body);*/ return restResponse; @@ -3139,7 +3085,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { Assert.assertEquals(responseCode, expectedResponseCode, "Response code is not correct."); - // Check auditing for upload operation + /*// Check auditing for upload operation ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse()); AuditingActionEnum action = AuditingActionEnum.ARTIFACT_DELETE_BY_API; @@ -3152,7 +3098,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { // expectedExternalAudit.setRESOURCE_URL(expectedExternalAudit.getRESOURCE_URL()+ "/" + artifactUUID); expectedExternalAudit.setRESOURCE_NAME(componentInstance.getNormalizedName()); expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + component.getUUID() + "/resourceInstances/" + componentInstance.getNormalizedName() + "/artifacts/" + artifactUUID); - AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_DELETE_BY_API.getName(), body); + AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_DELETE_BY_API.getName(), body);*/ component = AtomicOperationUtils.getComponentObject(component, UserRoleEnum.DESIGNER); return restResponse; } @@ -3167,7 +3113,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { Assert.assertEquals(responseCode, expectedResponseCode, "Response code is not correct."); - // Check auditing for upload operation + /*// Check auditing for upload operation ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse()); AuditingActionEnum action = AuditingActionEnum.ARTIFACT_DELETE_BY_API; @@ -3178,7 +3124,7 @@ public class CRUDExternalAPI extends ComponentBaseTest { AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((component.getComponentType().getValue() + "s").toUpperCase()); ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, component); expectedExternalAudit.setRESOURCE_URL(expectedExternalAudit.getRESOURCE_URL()+ "/" + artifactUUID); - AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_DELETE_BY_API.getName(), body); + AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_DELETE_BY_API.getName(), body);*/ component = AtomicOperationUtils.getComponentObject(component, UserRoleEnum.DESIGNER); return restResponse; } @@ -3259,159 +3205,5 @@ public class CRUDExternalAPI extends ComponentBaseTest { return resourceDetails; } - - - - - protected String createUploadArtifactBodyJson() { - Map jsonBody = new HashMap(); - jsonBody.put("artifactName", UPLOAD_ARTIFACT_NAME); - jsonBody.put("artifactDisplayName", "configure"); - jsonBody.put("artifactType", "SHELL"); - jsonBody.put("mandatory", "false"); - jsonBody.put("description", "ff"); - jsonBody.put("payloadData", UPLOAD_ARTIFACT_PAYLOAD); - jsonBody.put("artifactLabel", "configure"); - return gson.toJson(jsonBody); - } - - protected ArtifactDefinition getArtifactDataFromJson(String content) { - JsonObject jsonElement = new JsonObject(); - ArtifactDefinition resourceInfo = null; - - try { - Gson gson = new Gson(); - jsonElement = gson.fromJson(content, jsonElement.getClass()); - JsonElement artifactGroupValue = jsonElement.get(Constants.ARTIFACT_GROUP_TYPE_FIELD); - if (artifactGroupValue != null && !artifactGroupValue.isJsonNull()) { - String groupValueUpper = artifactGroupValue.getAsString().toUpperCase(); - if (!ArtifactGroupTypeEnum.getAllTypes().contains(groupValueUpper)) { - StringBuilder sb = new StringBuilder(); - for (String value : ArtifactGroupTypeEnum.getAllTypes()) { - sb.append(value).append(", "); - } - log.debug("artifactGroupType is {}. valid values are: {}", groupValueUpper, sb.toString()); - return null; - } else { - jsonElement.remove(Constants.ARTIFACT_GROUP_TYPE_FIELD); - jsonElement.addProperty(Constants.ARTIFACT_GROUP_TYPE_FIELD, groupValueUpper); - } - } - String payload = null; - JsonElement artifactPayload = jsonElement.get(Constants.ARTIFACT_PAYLOAD_DATA); - if (artifactPayload != null && !artifactPayload.isJsonNull()) { - payload = artifactPayload.getAsString(); - } - jsonElement.remove(Constants.ARTIFACT_PAYLOAD_DATA); - String json = gson.toJson(jsonElement); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(Feature.FAIL_ON_EMPTY_BEANS, false); - mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); - - resourceInfo = mapper.readValue(json, ArtifactDefinition.class); - resourceInfo.setPayloadData(payload); - - } catch (Exception e) { - BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeArtifactInformationInvalidError, "Artifact Upload / Update"); - BeEcompErrorManager.getInstance().logBeArtifactInformationInvalidError("Artifact Upload / Update"); - log.debug("Failed to convert the content {} to object.", content.substring(0, Math.min(50, content.length())), e); - } - return resourceInfo; - } - - protected HttpGet createGetRequest(String url) { - HttpGet httpGet = new HttpGet(url); - httpGet.addHeader(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); - httpGet.addHeader(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate); - httpGet.addHeader(HttpHeaderEnum.USER_ID.getValue(), sdncUserDetails.getUserId()); - return httpGet; - } - - protected String getArtifactUid(HttpResponse response) throws HttpResponseException, IOException, ParseException { - String responseString = new BasicResponseHandler().handleResponse(response); - JSONObject responseMap = (JSONObject) jsonParser.parse(responseString); - String artifactId = (String) responseMap.get("uniqueId"); - return artifactId; - } - - protected String getArtifactEsId(HttpResponse response) throws HttpResponseException, IOException, ParseException { - String responseString = new BasicResponseHandler().handleResponse(response); - JSONObject responseMap = (JSONObject) jsonParser.parse(responseString); - String esId = (String) responseMap.get("EsId"); - return esId; - } - - protected ArtifactDefinition addArtifactDataFromResponse(HttpResponse response, ArtifactDefinition artifact) throws HttpResponseException, IOException, ParseException { - //String responseString = new BasicResponseHandler().handleResponse(response); - HttpEntity entity = response.getEntity(); - String responseString = EntityUtils.toString(entity); - JSONObject responseMap = (JSONObject) jsonParser.parse(responseString); - artifact.setEsId((String)responseMap.get("esId")); - artifact.setUniqueId((String) responseMap.get("uniqueId")); - artifact.setArtifactGroupType(ArtifactGroupTypeEnum.findType((String) responseMap.get("artifactGroupType"))); - artifact.setTimeout(((Long) responseMap.get("timeout")).intValue()); - return artifact; - } - - protected String getLifecycleArtifactUid(CloseableHttpResponse response) throws HttpResponseException, IOException, ParseException { - String responseString = new BasicResponseHandler().handleResponse(response); - JSONObject responseMap = (JSONObject) jsonParser.parse(responseString); - responseMap = (JSONObject) responseMap.get("implementation"); - String artifactId = (String) responseMap.get("uniqueId"); - return artifactId; - } - - protected HttpDelete createDeleteArtifactRequest(String url) { - HttpDelete httpDelete = new HttpDelete(url); - httpDelete.addHeader(HttpHeaderEnum.USER_ID.getValue(), sdncUserDetails.getUserId()); - httpDelete.addHeader(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate); - return httpDelete; - } - - protected HttpPost createPostAddArtifactRequeast(String jsonBody, String url, boolean addMd5Header) throws UnsupportedEncodingException { - HttpPost httppost = new HttpPost(url); - httppost.addHeader(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); - httppost.addHeader(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate); - httppost.addHeader(HttpHeaderEnum.USER_ID.getValue(), sdncUserDetails.getUserId()); - if (addMd5Header) { - httppost.addHeader(HttpHeaderEnum.Content_MD5.getValue(), GeneralUtility.calculateMD5Base64EncodedByString(jsonBody)); - } - StringEntity input = new StringEntity(jsonBody); - input.setContentType("application/json"); - httppost.setEntity(input); - log.debug("Executing request {}" , httppost.getRequestLine()); - return httppost; - } - - protected String createLoadArtifactBody() { - Map json = new HashMap(); - json.put("artifactName", "install_apache2.sh"); - json.put("artifactType", "SHELL"); - json.put("description", "ddd"); - json.put("payloadData", "UEsDBAoAAAAIAAeLb0bDQz"); - json.put("artifactLabel", "name123"); - - String jsonStr = gson.toJson(json); - return jsonStr; - } - - protected void checkDeleteResponse(RestResponse response) { - BaseRestUtils.checkStatusCode(response, "delete request failed", false, 204, 404); - } - - protected ArtifactUiDownloadData getArtifactUiDownloadData(String artifactUiDownloadDataStr) throws Exception { - - ObjectMapper mapper = new ObjectMapper(); - try { - ArtifactUiDownloadData artifactUiDownloadData = mapper.readValue(artifactUiDownloadDataStr, ArtifactUiDownloadData.class); - return artifactUiDownloadData; - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/DeploymentValiditaion.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/DeploymentValiditaion.java index 07cb7d9e02..9e82a818a1 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/DeploymentValiditaion.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/DeploymentValiditaion.java @@ -20,28 +20,10 @@ package org.openecomp.sdc.externalApis; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - +import com.aventstack.extentreports.Status; import org.apache.commons.io.FileUtils; import org.junit.Rule; import org.junit.rules.TestName; -import org.openecomp.sdc.be.datatypes.enums.AssetTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.Resource; @@ -50,12 +32,10 @@ import org.openecomp.sdc.be.model.category.CategoryDefinition; import org.openecomp.sdc.be.model.category.SubCategoryDefinition; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.datatypes.PropertyReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; -import org.openecomp.sdc.ci.tests.utils.rest.AssetRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.CatalogRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.CategoryRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; @@ -64,35 +44,35 @@ import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import org.yaml.snakeyaml.Yaml; -import com.aventstack.extentreports.Status; - - - - - - - +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.*; +import java.util.stream.Collectors; +import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.assertTrue; public class DeploymentValiditaion extends ComponentBaseTest{ - - - @Rule public static TestName name = new TestName(); - +// These tests should run in executable jar only on deployed environment public DeploymentValiditaion() { super(name, DeploymentValiditaion.class.getName()); } - + protected final static String categoryFilterKey = "category"; protected final static String subCategoryFilterKey = "subCategory"; protected String attVersionStr ; - - + protected String pathPrefix; + + public static List listf(String directoryName) { File directory = new File(directoryName); - List resultList = new ArrayList(); + List resultList = new ArrayList<>(); // get all the files from a directory File[] fList = directory.listFiles(); @@ -106,40 +86,35 @@ public class DeploymentValiditaion extends ComponentBaseTest{ } //System.out.println(fList); return resultList; - } + } @BeforeTest public void beforeTest() throws Exception{ RestResponse attVersion = CatalogRestUtils.getOsVersion(); attVersionStr = ResponseParser.getVersionFromResponse(attVersion); + pathPrefix = File.separator+"opt"+File.separator+"app"+File.separator+"asdc_kits"+File.separator+"catalog-be-"+attVersionStr+File.separator+"import"+File.separator+"tosca"+File.separator; } - - - @Test + + /*@Test public void pasrseNormativies() throws Exception{ - - - String path = "//apps//asdc_kits//catalog-be-" + attVersionStr + "//import//tosca//normative-types"; - String path2 = "//apps//asdc_kits//catalog-be-" + attVersionStr + "//import//tosca//heat-types"; - -// String path = "C:\\Git_work\\Git_UGN\\d2-sdnc\\catalog-be\\src\\main\\resources\\import\\tosca\\normative-types"; -// String path2 = "C:\\Git_work\\Git_UGN\\d2-sdnc\\catalog-be\\src\\main\\resources\\import\\tosca\\heat-types"; - - - List yamlList1 = getYamlFilesList(path); + + + String path = pathPrefix+"normative-types"; + String path2 = pathPrefix+"heat-types"; + + List yamlList1 = getYamlFilesList(path); List nodeNamesFromYamlList1 = getNodeNamesFromYamlList(yamlList1); - List yamlList2 = getYamlFilesList(path2); + List yamlList2 = getYamlFilesList(path2); List nodeNamesFromYamlList2 = getNodeNamesFromYamlList(yamlList2); - - - List expectedList = new ArrayList(); + + + List expectedList = new ArrayList<>(); expectedList.addAll(nodeNamesFromYamlList1); expectedList.addAll(nodeNamesFromYamlList2); System.out.println("list of normatives from files:::::::::::"); expectedList.forEach(System.out::println); getExtendTest().log(Status.INFO, "list of normatives from files:"); getExtendTest().log(Status.INFO,expectedList.toString()); - - + String[] filter = { categoryFilterKey + "=" + ResourceCategoryEnum.GENERIC_ABSTRACT.getCategory(), subCategoryFilterKey + "=" + ResourceCategoryEnum.GENERIC_ABSTRACT.getSubCategory() }; RestResponse assetResponse = AssetRestUtils.getComponentListByAssetType(true, AssetTypeEnum.RESOURCES); Map resourceAssetList = AssetRestUtils.getResourceAssetMap(assetResponse); @@ -149,7 +124,7 @@ public class DeploymentValiditaion extends ComponentBaseTest{ resourceToscaNamesList.forEach(System.out::println); getExtendTest().log(Status.INFO, "list of normatives from APIs:"); getExtendTest().log(Status.INFO, resourceToscaNamesList.toString()); - + boolean good = true; List missingNormatives = new ArrayList<>(); @@ -157,23 +132,21 @@ public class DeploymentValiditaion extends ComponentBaseTest{ if (!resourceToscaNamesList.contains(expectedList.get(i))) { good = false; missingNormatives.add(expectedList.get(i)); - - } } - + System.out.println("<<<<<<<<>>>>>"); missingNormatives.forEach(System.out::println); getExtendTest().log(Status.INFO, "MISSING NORMATIVES:"); getExtendTest().log(Status.INFO, missingNormatives.toString()); - + assertTrue("missing normatives ", good); - - } + + }*/ public List getNodeNamesFromYamlList(List yamlList) throws IOException { - List nodeNameList = new ArrayList(); + List nodeNameList = new ArrayList<>(); for (File file : yamlList) { String content = new String(Files.readAllBytes(Paths.get(file.getPath())), StandardCharsets.UTF_8); @@ -190,7 +163,7 @@ public class DeploymentValiditaion extends ComponentBaseTest{ public List getYamlFilesList(String path) throws IOException { - List yamlList = new ArrayList(); + List yamlList = new ArrayList<>(); File dir = new File(path); String[] extensions = new String[] { "yml" }; System.out.println("Getting all .yml files in " + dir.getCanonicalPath() @@ -202,22 +175,13 @@ public class DeploymentValiditaion extends ComponentBaseTest{ } return yamlList; } - - - - - @Test (enabled=false) public void testYaml() throws IOException{ - + System.out.println(""); - - File file = new File("\\\\Comp-1\\FileIO\\Stop.txt"); - - - //read file + File file = new File("\\\\Comp-1\\FileIO\\Stop.txt"); Map readZip = null; Path path = Paths.get("C:\\Users\\ys9693\\Documents\\csar\\attributesWithProporties\\attributesWithProporties.csar"); @@ -229,117 +193,89 @@ public class DeploymentValiditaion extends ComponentBaseTest{ byte[] artifactsBs = readZip.get("Definitions/VF_RI2_G6.yaml"); String str = new String(artifactsBs, StandardCharsets.UTF_8); - - - Yaml yaml = new Yaml(); Map load = (Map) yaml.load(str); Map topology_template = (Map) load.get("topology_template"); Map node_templates = (Map) topology_template.get("node_templates"); - + Set keySet = node_templates.keySet(); } - - - + + + @Test public void pasrseDataTypes() throws Exception{ - -// String path = "C:\\Git_work\\Git_UGN\\d2-sdnc\\catalog-be\\src\\main\\resources\\import\\tosca\\data-types\\dataTypes.yml"; - String path = "//apps//asdc_kits//catalog-be-" + attVersionStr + "//import//tosca//data-types//dataTypes.yml"; - + + String path = pathPrefix+"data-types"+File.separator+"dataTypes.yml"; String content = new String(Files.readAllBytes(Paths.get(path)), StandardCharsets.UTF_8); - - + Yaml yaml = new Yaml(); Map load = (Map) yaml.load(content); - List listOfDataTypes = new ArrayList(); + List listOfDataTypes = new ArrayList<>(); listOfDataTypes.addAll(load.keySet()); System.out.println("<<<<<<<< List of Data Types >>>>>>>>>"); listOfDataTypes.forEach(System.out::println); getExtendTest().log(Status.INFO, "List of Data Types:"); getExtendTest().log(Status.INFO, listOfDataTypes.toString()); - + Resource resource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value(); PropertyReqDetails defaultProperty = ElementFactory.getDefaultListProperty(); - -// SchemaDefinition schemaDefinition = new SchemaDefinition(); - - - - + defaultProperty.setPropertyDefaultValue(null); -// defaultProperty.setSchema(schemaDefinition); - - -// listOfDataTypes.remove("tosca.datatypes.Root"); for (String dataType : listOfDataTypes) { -// if (dataType.equals("map") || dataType.equals("list")){ defaultProperty.setPropertyType(dataType); defaultProperty.setName(dataType); System.out.println("Adding proporty with data type: ----> " + dataType); getExtendTest().log(Status.INFO, "Adding proporty with data type: ----> " + dataType); AtomicOperationUtils.addCustomPropertyToResource(defaultProperty, resource, UserRoleEnum.DESIGNER, true); -// } } - listOfDataTypes.forEach(System.out::println); - - } - - - - + } @Test public void pasrseCategories() throws Exception{ - -// String path = "C:\\Git_work\\Git_UGN\\d2-sdnc\\catalog-be\\src\\main\\resources\\import\\tosca\\categories\\categoryTypes.yml"; - String path = "//apps//asdc_kits//catalog-be-" + attVersionStr + "//import//tosca//categories//categoryTypes.yml"; - + + String path = pathPrefix+"categories"+File.separator+"categoryTypes.yml"; String content = new String(Files.readAllBytes(Paths.get(path)), StandardCharsets.UTF_8); - - List serviceCategories = new ArrayList(); - List resourceCategories = new ArrayList(); - + + List serviceCategories = new ArrayList<>(); + List resourceCategories = new ArrayList<>(); + Yaml yaml = new Yaml(); Map load = (Map) yaml.load(content); Map services = (Map) load.get("services"); Map resources = (Map) load.get("resources"); - - Map> resourcesListFromFile = new HashMap>() ; - + + Map> resourcesListFromFile = new HashMap<>() ; + //retrieve subcategories for ( String resourceCategoryName : resources.keySet()) { Map subcategory = (Map) resources.get(resourceCategoryName).get("subcategories"); - + resourceCategories = new ArrayList(); - for (String subcategoryName : subcategory.keySet()) { + for (String subcategoryName : subcategory.keySet()) { String name = (String) subcategory.get(subcategoryName).get("name"); -// resourceCategories.add(name.replaceAll("\\s","")); resourceCategories.add(name); - } - resourcesListFromFile.put(resources.get(resourceCategoryName).get("name").toString(), resourceCategories); - } - + resourcesListFromFile.put(resources.get(resourceCategoryName).get("name").toString(), resourceCategories); + } + System.out.println(resourcesListFromFile.toString()); getExtendTest().log(Status.INFO, "Expected categories:"); getExtendTest().log(Status.INFO, resourcesListFromFile.toString()); - - //retrieve service categories + + //retrieve service categories // for ( String serviceCategoryName : services.keySet()) { // String name = (String) services.get(serviceCategoryName).get("name"); // serviceCategories.add(name); // } // serviceCategories.forEach(System.out::println); - - + //retrieve resource list from URL - + Map> categoriesMap = getCategories(); List resourceSubCategories = categoriesMap.get(ComponentTypeEnum.RESOURCE_PARAM_NAME); List subcategories; @@ -347,80 +283,69 @@ public class DeploymentValiditaion extends ComponentBaseTest{ subcategories = categoryDefinition.getSubcategories(); } // subcategories.stream().collect(toMap(i -> i, i -> items.get(i))); - + // resourceSubCategories.stream().collect( // Collectors.groupingBy(CategoryDefinition::getName, Collectors.groupingBy(SubCategoryDefinition::getName))); - + // resourceSubCategories.stream().filter(p->p.getSubcategories()).map(m->m.getName()).collect(Collectors.toList()).collect(Collectors.toMap(CategoryDefinition::getName,m)); - - + + Map> resourceMapFromUrl = resourceSubCategories.stream().collect(Collectors.toMap( e -> e.getName() , e -> e.getSubcategories().stream().map(e1 -> e1.getName()).collect(Collectors.toList()))); - + getExtendTest().log(Status.INFO, "Actual categories:"); getExtendTest().log(Status.INFO, resourceMapFromUrl.toString()); - - - assertTrue("missing categories ", resourceMapFromUrl.keySet().containsAll(resourcesListFromFile.keySet())); - - - - + + assertTrue("missing categories ", resourceMapFromUrl.keySet().containsAll(resourcesListFromFile.keySet())); } - - + + public Map> getCategories() throws Exception { - + User defaultAdminUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); - + Map> map = new HashMap>(); - - + + RestResponse allResourceCategories = CategoryRestUtils.getAllCategories(defaultAdminUser, ComponentTypeEnum.RESOURCE_PARAM_NAME); RestResponse allServiceCategories = CategoryRestUtils.getAllCategories(defaultAdminUser, ComponentTypeEnum.SERVICE_PARAM_NAME); List parsedResourceCategories = ResponseParser.parseCategories(allResourceCategories); List parsedServiceCategories = ResponseParser.parseCategories(allServiceCategories); - + map.put(ComponentTypeEnum.RESOURCE_PARAM_NAME, parsedResourceCategories); map.put(ComponentTypeEnum.SERVICE_PARAM_NAME, parsedServiceCategories); - + return map; } - - @Test (enabled=false) + +/* @Test (enabled=false) public void pasrseCategoriesClass2() throws IOException{ - + String path = "C:\\Git_work\\Git_UGN\\d2-sdnc\\catalog-be\\src\\main\\resources\\import\\tosca\\categories\\categoryTypes.yml"; FileReader reader = new FileReader(path); Yaml yaml=new Yaml(); - - + + Map map = (Map) yaml.load(reader); - + Collection values = (Collection) map.values(); for (Map map2 : values) { Collection values2 = map2.values(); for (Object object : values2) { - - + + } } - - { - - } + List collect = values.stream().map(e -> e.get("name")).collect(Collectors.toList()); - + // resourcesArrayList.stream().filter(s -> s.getName().toLowerCase().startsWith("ci") && !s.getName().toLowerCase().equals("cindervolume")).map(e -> e.getUniqueId()).collect(Collectors.toList()).forEach((i) - - - - - } + + }*/ } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetAssetServlet.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetAssetServlet.java index fdef535f95..9db9e8a4d8 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetAssetServlet.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetAssetServlet.java @@ -20,21 +20,14 @@ package org.openecomp.sdc.externalApis; -import static org.testng.AssertJUnit.assertEquals; - -import java.io.InputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - +import com.google.gson.Gson; import org.apache.commons.codec.binary.Base64; import org.apache.commons.io.IOUtils; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; -import org.codehaus.jackson.map.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition; @@ -45,35 +38,26 @@ import org.openecomp.sdc.be.model.ArtifactUiDownloadData; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.api.Urls; -import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ResourceAssetStructure; -import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ServiceAssetStructure; -import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.*; import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; -import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedExternalAudit; import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.Utils; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; -import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.AssetRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; -import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils; -import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils; +import org.openecomp.sdc.ci.tests.utils.rest.*; import org.openecomp.sdc.common.api.Constants; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; import org.testng.annotations.Test; -import com.google.gson.Gson; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +import static org.testng.AssertJUnit.assertEquals; public class GetAssetServlet extends ComponentBaseTest { @@ -102,78 +86,52 @@ public class GetAssetServlet extends ComponentBaseTest { // CassandraUtils.truncateAllKeyspaces(); List expectedAssetNamesList = new ArrayList<>(); + ResourceReqDetails resourceDetails = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, sdncUserDetails); + Resource resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, UserRoleEnum.DESIGNER, true).left().value(); + expectedAssetNamesList.add(resourceDetails.getName()); - ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource(); - resourceDetails.setName("ciResource1"); - resourceDetails.setResourceType(ResourceTypeEnum.VF.name()); - RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createResource); - Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class); - expectedAssetNamesList.add(resource.getName()); - - resourceDetails.setName("ciResource2"); - resourceDetails.setResourceType(ResourceTypeEnum.VF.name()); - createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createResource); - resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class); + resourceDetails = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, sdncUserDetails); + resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, UserRoleEnum.DESIGNER, true).left().value(); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - expectedAssetNamesList.add(resource.getName()); - expectedAssetNamesList.add(resource.getName()); - - resourceDetails.setName("ciResource3"); - resourceDetails.setResourceType(ResourceTypeEnum.VF.name()); - createResource = ResourceRestUtils.createResource(resourceDetails, - ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createResource); - resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class); + expectedAssetNamesList.add(resourceDetails.getName()); + + resourceDetails = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, sdncUserDetails); + resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, UserRoleEnum.DESIGNER, true).left().value(); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - expectedAssetNamesList.add(resource.getName()); + expectedAssetNamesList.add(resourceDetails.getName()); - resourceDetails.setName("ciResource4"); - resourceDetails.setResourceType(ResourceTypeEnum.VF.name()); - createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createResource); - resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class); + resourceDetails = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, sdncUserDetails); + resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, UserRoleEnum.DESIGNER, true).left().value(); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); - expectedAssetNamesList.add(resource.getName()); + expectedAssetNamesList.add(resourceDetails.getName()); - resourceDetails.setName("ciResource5"); - resourceDetails.setResourceType(ResourceTypeEnum.VF.name()); - createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createResource); - resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class); + resourceDetails = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, sdncUserDetails); + resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, UserRoleEnum.DESIGNER, true).left().value(); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - expectedAssetNamesList.add(resource.getName()); + expectedAssetNamesList.add(resourceDetails.getName()); - resourceDetails.setName("ciResource6"); - resourceDetails.setResourceType(ResourceTypeEnum.VF.name()); - createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createResource); - resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class); + resourceDetails = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, sdncUserDetails); + resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, UserRoleEnum.DESIGNER, true).left().value(); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.STARTCERTIFICATION, true).getLeft(); - expectedAssetNamesList.add(resource.getName()); + expectedAssetNamesList.add(resourceDetails.getName()); - resourceDetails.setName("ciResource7"); - resourceDetails.setResourceType(ResourceTypeEnum.VF.name()); - createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createResource); - resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class); + resourceDetails = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, sdncUserDetails); + resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, UserRoleEnum.DESIGNER, true).left().value(); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFICATIONREQUEST, true).getLeft(); - expectedAssetNamesList.add(resource.getName()); - expectedAssetNamesList.add(resource.getName()); + expectedAssetNamesList.add(resourceDetails.getName()); System.out.println("7 VF resources were created"); @@ -186,11 +144,11 @@ public class GetAssetServlet extends ComponentBaseTest { AssetRestUtils.checkComponentTypeInObjectList(resourceAssetList, ComponentTypeEnum.RESOURCE); - // Validate audit message + /* // Validate audit message ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetListAudit(AssetTypeEnum.RESOURCES, AuditingActionEnum.GET_ASSET_LIST); Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_ASSET_LIST.getName(), body); + AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_ASSET_LIST.getName(), body);*/ } @@ -202,76 +160,59 @@ public class GetAssetServlet extends ComponentBaseTest { ArtifactReqDetails artifactDetails = ElementFactory.getArtifactByType(ArtifactTypeEnum.OTHER, ArtifactTypeEnum.OTHER, true); ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(); - serviceDetails.setName("ciService1"); - RestResponse createService = ServiceRestUtils.createService(serviceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createService); - Service service = ResponseParser.parseToObjectUsingMapper(createService.getResponse(), Service.class); - expectedAssetNamesList.add(service.getName()); - - serviceDetails.setName("ciService2"); - createService = ServiceRestUtils.createService(serviceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createService); - service = ResponseParser.parseToObjectUsingMapper(createService.getResponse(), Service.class); + Service service = AtomicOperationUtils.createCustomService(serviceDetails, UserRoleEnum.DESIGNER, true).left().value(); + expectedAssetNamesList.add(serviceDetails.getName()); + + serviceDetails = ElementFactory.getDefaultService(); + service = AtomicOperationUtils.createCustomService(serviceDetails, UserRoleEnum.DESIGNER, true).left().value(); RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(artifactDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), service.getUniqueId()); BaseRestUtils.checkSuccess(addInformationalArtifactToService); service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - expectedAssetNamesList.add(service.getName()); - expectedAssetNamesList.add(service.getName()); + expectedAssetNamesList.add(serviceDetails.getName()); - serviceDetails.setName("ciService3"); - createService = ServiceRestUtils.createService(serviceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createService); - service = ResponseParser.parseToObjectUsingMapper(createService.getResponse(), Service.class); + serviceDetails = ElementFactory.getDefaultService(); + service = AtomicOperationUtils.createCustomService(serviceDetails, UserRoleEnum.DESIGNER, true).left().value(); addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(artifactDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), service.getUniqueId()); BaseRestUtils.checkSuccess(addInformationalArtifactToService); service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - expectedAssetNamesList.add(service.getName()); + expectedAssetNamesList.add(serviceDetails.getName()); - serviceDetails.setName("ciService4"); - createService = ServiceRestUtils.createService(serviceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createService); - service = ResponseParser.parseToObjectUsingMapper(createService.getResponse(), Service.class); + serviceDetails = ElementFactory.getDefaultService(); + service = AtomicOperationUtils.createCustomService(serviceDetails, UserRoleEnum.DESIGNER, true).left().value(); service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); - expectedAssetNamesList.add(service.getName()); + expectedAssetNamesList.add(serviceDetails.getName()); - serviceDetails.setName("ciService5"); - createService = ServiceRestUtils.createService(serviceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createService); - service = ResponseParser.parseToObjectUsingMapper(createService.getResponse(), Service.class); + serviceDetails = ElementFactory.getDefaultService(); + service = AtomicOperationUtils.createCustomService(serviceDetails, UserRoleEnum.DESIGNER, true).left().value(); service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - expectedAssetNamesList.add(service.getName()); + expectedAssetNamesList.add(serviceDetails.getName()); - serviceDetails.setName("ciService6"); - createService = ServiceRestUtils.createService(serviceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createService); - service = ResponseParser.parseToObjectUsingMapper(createService.getResponse(), Service.class); + serviceDetails = ElementFactory.getDefaultService(); + service = AtomicOperationUtils.createCustomService(serviceDetails, UserRoleEnum.DESIGNER, true).left().value(); addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(artifactDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), service.getUniqueId()); BaseRestUtils.checkSuccess(addInformationalArtifactToService); service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.STARTCERTIFICATION, true).getLeft(); - expectedAssetNamesList.add(service.getName()); + expectedAssetNamesList.add(serviceDetails.getName()); - serviceDetails.setName("ciService7"); - createService = ServiceRestUtils.createService(serviceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createService); - service = ResponseParser.parseToObjectUsingMapper(createService.getResponse(), Service.class); + serviceDetails = ElementFactory.getDefaultService(); + service = AtomicOperationUtils.createCustomService(serviceDetails, UserRoleEnum.DESIGNER, true).left().value(); addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(artifactDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), service.getUniqueId()); BaseRestUtils.checkSuccess(addInformationalArtifactToService); service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFICATIONREQUEST, true).getLeft(); - expectedAssetNamesList.add(service.getName()); - expectedAssetNamesList.add(service.getName()); + expectedAssetNamesList.add(serviceDetails.getName()); System.out.println("7 Services were created"); @@ -282,24 +223,20 @@ public class GetAssetServlet extends ComponentBaseTest { List getActualAssetNamesList = AssetRestUtils.getServiceNamesList(serviceAssetList); Utils.compareArrayLists(getActualAssetNamesList, expectedAssetNamesList, "Element"); - // Validate audit message + /*// Validate audit message ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetListAudit(AssetTypeEnum.SERVICES, AuditingActionEnum.GET_ASSET_LIST); Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_ASSET_LIST.getName(), body); + AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_ASSET_LIST.getName(), body);*/ } - @Test + @Test(enabled = false) public void getToscaModelSuccess() throws Exception { CloseableHttpClient httpclient = HttpClients.createDefault(); - ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource(); -// resourceDetails.setName("ciResource11"); - resourceDetails.setResourceType(ResourceTypeEnum.VF.name()); - RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncUserDetails); - BaseRestUtils.checkCreateResponse(createResource); - Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class); + ResourceReqDetails resourceDetails = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, sdncUserDetails); + Resource resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, UserRoleEnum.DESIGNER, true).left().value(); HttpResponse assetResponse = AssetRestUtils.getComponentToscaModel(AssetTypeEnum.RESOURCES, resource.getUUID()); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); String artId = resource.getToscaArtifacts().get("assettoscacsar").getEsId(); @@ -320,6 +257,7 @@ public class GetAssetServlet extends ComponentBaseTest { .append(artifactUiDownloadData.getArtifactName()).append("\"").toString()); } + private HttpGet createGetRequest(String url) { HttpGet httpGet = new HttpGet(url); httpGet.addHeader(HttpHeaderEnum.USER_ID.getValue(), sdncUserDetails.getUserId()); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetCSARofVF.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetCSARofVF.java index 7ab35b758e..fbbd394731 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetCSARofVF.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetCSARofVF.java @@ -20,41 +20,33 @@ package org.openecomp.sdc.externalApis; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.zip.ZipEntry; -import java.util.zip.ZipException; -import java.util.zip.ZipFile; - import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.datatypes.enums.AssetTypeEnum; -import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; -import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; -import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedExternalAudit; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; -import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.utils.rest.AssetRestUtils; -import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.zip.ZipEntry; +import java.util.zip.ZipException; +import java.util.zip.ZipFile; + +import static org.testng.AssertJUnit.assertTrue; + public class GetCSARofVF extends ComponentBaseTest { // protected User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); @@ -86,16 +78,14 @@ public class GetCSARofVF extends ComponentBaseTest { Resource resource = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value(); // HttpResponse componentToscaModel = AssetRestUtils.getComponentToscaModel(AssetTypeEnum.RESOURCES, resource.getUUID()); - File toscaModelCsarFile = AssetRestUtils.getToscaModelCsarFile(AssetTypeEnum.RESOURCES, resource.getUUID(), ""); + File toscaModelCsarFile = AssetRestUtils.getToscaModelCsarFile(AssetTypeEnum.RESOURCES, resource.getUUID()); // validate tosca structure validateCsarContent(resource, toscaModelCsarFile); - // Validate audit message - validateAudit(resource); - - - + /* // Validate audit message + validateAudit(resource);*/ + } @@ -108,16 +98,14 @@ public class GetCSARofVF extends ComponentBaseTest { AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true); // HttpResponse componentToscaModel = AssetRestUtils.getComponentToscaModel(AssetTypeEnum.RESOURCES, resource.getUUID()); - File toscaModelCsarFile = AssetRestUtils.getToscaModelCsarFile(AssetTypeEnum.RESOURCES, resource.getUUID(), ""); + File toscaModelCsarFile = AssetRestUtils.getToscaModelCsarFile(AssetTypeEnum.RESOURCES, resource.getUUID()); // validate tosca structure validateCsarContent(resource, toscaModelCsarFile); - // Validate audit message - validateAudit(resource); - - - + /*// Validate audit message + validateAudit(resource);*/ + } @Test @@ -128,15 +116,14 @@ public class GetCSARofVF extends ComponentBaseTest { AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true); // HttpResponse componentToscaModel = AssetRestUtils.getComponentToscaModel(AssetTypeEnum.RESOURCES, resource.getUUID()); - File toscaModelCsarFile = AssetRestUtils.getToscaModelCsarFile(AssetTypeEnum.RESOURCES, resource.getUUID(), ""); + File toscaModelCsarFile = AssetRestUtils.getToscaModelCsarFile(AssetTypeEnum.RESOURCES, resource.getUUID()); // validate tosca structure validateCsarContent(resource, toscaModelCsarFile); - // Validate audit message - validateAudit(resource); - - + /*// Validate audit message + validateAudit(resource);*/ + } @@ -146,15 +133,13 @@ public class GetCSARofVF extends ComponentBaseTest { Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value(); // HttpResponse componentToscaModel = AssetRestUtils.getComponentToscaModel(AssetTypeEnum.RESOURCES, resource.getUUID()); - File toscaModelCsarFile = AssetRestUtils.getToscaModelCsarFile(AssetTypeEnum.SERVICES, service.getUUID(), ""); + File toscaModelCsarFile = AssetRestUtils.getToscaModelCsarFile(AssetTypeEnum.SERVICES, service.getUUID()); // validate tosca structure validateCsarContent(service, toscaModelCsarFile); - validateAudit(service); - - - + /*validateAudit(service);*/ + } @Test @@ -165,14 +150,13 @@ public class GetCSARofVF extends ComponentBaseTest { AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true); // HttpResponse componentToscaModel = AssetRestUtils.getComponentToscaModel(AssetTypeEnum.RESOURCES, resource.getUUID()); - File toscaModelCsarFile = AssetRestUtils.getToscaModelCsarFile(AssetTypeEnum.SERVICES, service.getUUID(), ""); + File toscaModelCsarFile = AssetRestUtils.getToscaModelCsarFile(AssetTypeEnum.SERVICES, service.getUUID()); // validate tosca structure validateCsarContent(service, toscaModelCsarFile); - validateAudit(service); - - + /*validateAudit(service);*/ + } @Test @@ -183,12 +167,12 @@ public class GetCSARofVF extends ComponentBaseTest { AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true); // HttpResponse componentToscaModel = AssetRestUtils.getComponentToscaModel(AssetTypeEnum.RESOURCES, resource.getUUID()); - File toscaModelCsarFile = AssetRestUtils.getToscaModelCsarFile(AssetTypeEnum.SERVICES, service.getUUID(), ""); + File toscaModelCsarFile = AssetRestUtils.getToscaModelCsarFile(AssetTypeEnum.SERVICES, service.getUUID()); // validate tosca structure validateCsarContent(service, toscaModelCsarFile); - validateAudit(service); + /*validateAudit(service);*/ } @@ -230,7 +214,7 @@ public class GetCSARofVF extends ComponentBaseTest { assertTrue("missing files in csar template definitions folder", expectedDefinitionFolderFileList.size() == 0); } - public void validateAudit(Component resource) throws Exception { + /*public void validateAudit(Component resource) throws Exception { ExpectedExternalAudit expectedAudit = null; if (resource.getComponentType().equals(ComponentTypeEnum.RESOURCE)){ expectedAudit = ElementFactory.getDefaultExternalAuditObject(AssetTypeEnum.RESOURCES, AuditingActionEnum.GET_TOSCA_MODEL, ("/" + resource.getUUID() + "/toscaModel")); @@ -245,6 +229,6 @@ public class GetCSARofVF extends ComponentBaseTest { body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, expectedAudit.getRESOURCE_NAME()); AuditValidationUtils.validateExternalAudit(expectedAudit, AuditingActionEnum.GET_TOSCA_MODEL.getName(), body); - } + }*/ } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetFilteredAssetServlet.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetFilteredAssetServlet.java index 70d8ef50f4..57a0f26a90 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetFilteredAssetServlet.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetFilteredAssetServlet.java @@ -20,15 +20,6 @@ package org.openecomp.sdc.externalApis; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -37,40 +28,27 @@ import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.DistributionStatusEnum; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; -import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; -import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ResourceAssetStructure; -import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ServiceAssetStructure; -import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo; -import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; -import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedExternalAudit; +import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.Utils; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; -import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.AssetRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; -import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; -import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils; -import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils; +import org.openecomp.sdc.ci.tests.utils.rest.*; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.annotations.Test; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; + public class GetFilteredAssetServlet extends ComponentBaseTest { private static Logger log = LoggerFactory.getLogger(GetAssetServlet.class.getName()); @@ -115,12 +93,8 @@ public class GetFilteredAssetServlet extends ComponentBaseTest { List getActualAssetNamesList = AssetRestUtils.getResourceNamesList(resourceAssetList); Utils.compareArrayLists(getActualAssetNamesList, expectedAssetNamesList, "Element"); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetListAudit(AssetTypeEnum.RESOURCES, AuditingActionEnum.GET_FILTERED_ASSET_LIST); - expectedAssetListAudit.setRESOURCE_URL(AssetRestUtils.buildUrlWithFilter(expectedAssetListAudit.getRESOURCE_URL(), filter)); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); + /*// Validate audit message + validateSuccessAudit(filter, AssetTypeEnum.RESOURCES);*/ } @@ -145,12 +119,8 @@ public class GetFilteredAssetServlet extends ComponentBaseTest { List getActualAssetNamesList = AssetRestUtils.getServiceNamesList(resourceAssetList); Utils.compareArrayLists(getActualAssetNamesList, expectedAssetNamesList, "Element"); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetListAudit(AssetTypeEnum.RESOURCES, AuditingActionEnum.GET_FILTERED_ASSET_LIST); - expectedAssetListAudit.setRESOURCE_URL(AssetRestUtils.buildUrlWithFilter(expectedAssetListAudit.getRESOURCE_URL(), filter)); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); + /*// Validate audit message + validateSuccessAudit(filter, AssetTypeEnum.RESOURCES);*/ } @Test // (enabled = false) @@ -169,12 +139,8 @@ public class GetFilteredAssetServlet extends ComponentBaseTest { List getActualAssetNamesList = AssetRestUtils.getServiceNamesList(resourceAssetList); Utils.compareArrayLists(getActualAssetNamesList, expectedAssetNamesList, "Element"); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetListAudit(AssetTypeEnum.RESOURCES, AuditingActionEnum.GET_FILTERED_ASSET_LIST); - expectedAssetListAudit.setRESOURCE_URL(AssetRestUtils.buildUrlWithFilter(expectedAssetListAudit.getRESOURCE_URL(), filter)); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); + /*// Validate audit message + validateSuccessAudit(filter, AssetTypeEnum.RESOURCES);*/ } // Failure @@ -192,14 +158,8 @@ public class GetFilteredAssetServlet extends ComponentBaseTest { List variables = Arrays.asList(resourceKey, categoryFilterKey, "NotExistingCategory"); ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_CATEGORY_NOT_FOUND.name(), variables, assetResponse.getResponse()); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetListAudit(AssetTypeEnum.RESOURCES, AuditingActionEnum.GET_FILTERED_ASSET_LIST); - expectedAssetListAudit.setRESOURCE_URL(AssetRestUtils.buildUrlWithFilter(expectedAssetListAudit.getRESOURCE_URL(), filter)); - expectedAssetListAudit.setSTATUS(errorInfo.getCode().toString()); - expectedAssetListAudit.setDESC(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); + /*// Validate audit message + validateFailureAudit(filter, errorInfo, variables, AssetTypeEnum.RESOURCES)*/; } @Test // (enabled = false) @@ -216,14 +176,8 @@ public class GetFilteredAssetServlet extends ComponentBaseTest { List variables = Arrays.asList("Resource", "NotExistingSubCategory", ResourceCategoryEnum.GENERIC_ABSTRACT.getCategory()); ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_SUB_CATEGORY_NOT_FOUND_FOR_CATEGORY.name(), variables, assetResponse.getResponse()); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetListAudit(AssetTypeEnum.RESOURCES, AuditingActionEnum.GET_FILTERED_ASSET_LIST); - expectedAssetListAudit.setRESOURCE_URL(AssetRestUtils.buildUrlWithFilter(expectedAssetListAudit.getRESOURCE_URL(), filter)); - expectedAssetListAudit.setSTATUS(errorInfo.getCode().toString()); - expectedAssetListAudit.setDESC(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); + /*// Validate audit message + validateFailureAudit(filter, errorInfo, variables, AssetTypeEnum.RESOURCES);*/ } @Test // (enabled = false) @@ -240,14 +194,8 @@ public class GetFilteredAssetServlet extends ComponentBaseTest { List variables = Arrays.asList(resourceKey, categoryFilterKey, "NotExistingCategory"); ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_CATEGORY_NOT_FOUND.name(), variables, assetResponse.getResponse()); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetListAudit(AssetTypeEnum.RESOURCES, AuditingActionEnum.GET_FILTERED_ASSET_LIST); - expectedAssetListAudit.setRESOURCE_URL(AssetRestUtils.buildUrlWithFilter(expectedAssetListAudit.getRESOURCE_URL(), filter)); - expectedAssetListAudit.setSTATUS(errorInfo.getCode().toString()); - expectedAssetListAudit.setDESC(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); + /*// Validate audit message + validateFailureAudit(filter, errorInfo, variables, AssetTypeEnum.RESOURCES);*/ } @Test // (enabled = false) @@ -264,14 +212,8 @@ public class GetFilteredAssetServlet extends ComponentBaseTest { List variables = Arrays.asList(subCategoryFilterKey + "1", validFilterParameters); ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FILTER_KEY.name(), variables, assetResponse.getResponse()); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetListAudit(AssetTypeEnum.RESOURCES, AuditingActionEnum.GET_FILTERED_ASSET_LIST); - expectedAssetListAudit.setRESOURCE_URL(AssetRestUtils.buildUrlWithFilter(expectedAssetListAudit.getRESOURCE_URL(), filter)); - expectedAssetListAudit.setSTATUS(errorInfo.getCode().toString()); - expectedAssetListAudit.setDESC(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); + /*// Validate audit message + validateFailureAudit(filter, errorInfo, variables, AssetTypeEnum.RESOURCES);*/ } // --------------------------------------------------------------------------------------------------------- @@ -292,12 +234,8 @@ public class GetFilteredAssetServlet extends ComponentBaseTest { List getActualAssetNamesList = AssetRestUtils.getServiceNamesList(serviceAssetList); Utils.compareArrayLists(getActualAssetNamesList, expectedAssetNamesList, "Element"); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetListAudit(AssetTypeEnum.SERVICES, AuditingActionEnum.GET_FILTERED_ASSET_LIST); - expectedAssetListAudit.setRESOURCE_URL(AssetRestUtils.buildUrlWithFilter(expectedAssetListAudit.getRESOURCE_URL(), filter)); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); + /*// Validate audit message + validateSuccessAudit(filter, AssetTypeEnum.SERVICES);*/ } @Test // (enabled = false) @@ -321,12 +259,8 @@ public class GetFilteredAssetServlet extends ComponentBaseTest { List getActualAssetNamesList = AssetRestUtils.getServiceNamesList(serviceAssetList); Utils.compareArrayLists(getActualAssetNamesList, expectedAssetNamesList, "Element"); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetListAudit(AssetTypeEnum.SERVICES, AuditingActionEnum.GET_FILTERED_ASSET_LIST); - expectedAssetListAudit.setRESOURCE_URL(AssetRestUtils.buildUrlWithFilter(expectedAssetListAudit.getRESOURCE_URL(), filter)); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); + /*// Validate audit message + validateSuccessAudit(filter, AssetTypeEnum.SERVICES);*/ } @Test // (enabled = false) @@ -350,12 +284,8 @@ public class GetFilteredAssetServlet extends ComponentBaseTest { List getActualAssetNamesList = AssetRestUtils.getServiceNamesList(serviceAssetList); Utils.compareArrayLists(getActualAssetNamesList, expectedAssetNamesList, "Element"); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetListAudit(AssetTypeEnum.SERVICES, AuditingActionEnum.GET_FILTERED_ASSET_LIST); - expectedAssetListAudit.setRESOURCE_URL(AssetRestUtils.buildUrlWithFilter(expectedAssetListAudit.getRESOURCE_URL(), filter)); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); + /*// Validate audit message + validateSuccessAudit(filter, AssetTypeEnum.SERVICES);*/ } // Failure @@ -373,14 +303,8 @@ public class GetFilteredAssetServlet extends ComponentBaseTest { List variables = Arrays.asList(serviceKey, categoryFilterKey, "NotExistingCategory"); ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_CATEGORY_NOT_FOUND.name(), variables, assetResponse.getResponse()); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetListAudit(AssetTypeEnum.SERVICES, AuditingActionEnum.GET_FILTERED_ASSET_LIST); - expectedAssetListAudit.setRESOURCE_URL(AssetRestUtils.buildUrlWithFilter(expectedAssetListAudit.getRESOURCE_URL(), filter)); - expectedAssetListAudit.setSTATUS(errorInfo.getCode().toString()); - expectedAssetListAudit.setDESC(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); + /*// Validate audit message + validateFailureAudit(filter, errorInfo, variables, AssetTypeEnum.SERVICES);*/ } @Test // (enabled = false) @@ -396,14 +320,8 @@ public class GetFilteredAssetServlet extends ComponentBaseTest { List variables = Arrays.asList(serviceKey, distributionStatusFilterKey, "NotExistingDistributionStatus"); ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_CATEGORY_NOT_FOUND.name(), variables, assetResponse.getResponse()); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetListAudit(AssetTypeEnum.SERVICES, AuditingActionEnum.GET_FILTERED_ASSET_LIST); - expectedAssetListAudit.setRESOURCE_URL(AssetRestUtils.buildUrlWithFilter(expectedAssetListAudit.getRESOURCE_URL(), filter)); - expectedAssetListAudit.setSTATUS(errorInfo.getCode().toString()); - expectedAssetListAudit.setDESC(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); + /*// Validate audit message + validateFailureAudit(filter, errorInfo, variables, AssetTypeEnum.SERVICES);*/ } @Test // (enabled = false) @@ -420,14 +338,8 @@ public class GetFilteredAssetServlet extends ComponentBaseTest { List variables = Arrays.asList(serviceKey, distributionStatusFilterKey, "NotExistingDistributionStatus"); ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_CATEGORY_NOT_FOUND.name(), variables, assetResponse.getResponse()); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetListAudit(AssetTypeEnum.SERVICES, AuditingActionEnum.GET_FILTERED_ASSET_LIST); - expectedAssetListAudit.setRESOURCE_URL(AssetRestUtils.buildUrlWithFilter(expectedAssetListAudit.getRESOURCE_URL(), filter)); - expectedAssetListAudit.setSTATUS(errorInfo.getCode().toString()); - expectedAssetListAudit.setDESC(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); + /*// Validate audit message + validateFailureAudit(filter, errorInfo, variables, AssetTypeEnum.SERVICES);*/ } @Test // (enabled = false) @@ -444,14 +356,8 @@ public class GetFilteredAssetServlet extends ComponentBaseTest { List variables = Arrays.asList(serviceKey, categoryFilterKey, "NotExistingCategory"); ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_CATEGORY_NOT_FOUND.name(), variables, assetResponse.getResponse()); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetListAudit(AssetTypeEnum.SERVICES, AuditingActionEnum.GET_FILTERED_ASSET_LIST); - expectedAssetListAudit.setRESOURCE_URL(AssetRestUtils.buildUrlWithFilter(expectedAssetListAudit.getRESOURCE_URL(), filter)); - expectedAssetListAudit.setSTATUS(errorInfo.getCode().toString()); - expectedAssetListAudit.setDESC(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); + /*// Validate audit message + validateFailureAudit(filter, errorInfo, variables, AssetTypeEnum.SERVICES);*/ } @Test // (enabled = false) @@ -468,14 +374,8 @@ public class GetFilteredAssetServlet extends ComponentBaseTest { List variables = Arrays.asList(distributionStatusFilterKey + "1", "[" + categoryFilterKey + ", " + distributionStatusFilterKey + "]"); ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FILTER_KEY.name(), variables, assetResponse.getResponse()); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetListAudit(AssetTypeEnum.SERVICES, AuditingActionEnum.GET_FILTERED_ASSET_LIST); - expectedAssetListAudit.setRESOURCE_URL(AssetRestUtils.buildUrlWithFilter(expectedAssetListAudit.getRESOURCE_URL(), filter)); - expectedAssetListAudit.setSTATUS(errorInfo.getCode().toString()); - expectedAssetListAudit.setDESC(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); + /*// Validate audit message + validateFailureAudit(filter, errorInfo, variables, AssetTypeEnum.SERVICES);*/ } @@ -486,226 +386,206 @@ public class GetFilteredAssetServlet extends ComponentBaseTest { RestResponse assetResponse = AssetRestUtils.getFilteredComponentList(AssetTypeEnum.RESOURCES, query); BaseRestUtils.checkErrorResponse(assetResponse, ActionStatus.COMPONENT_CATEGORY_NOT_FOUND, "resource", "category", "Application L3+"); - // Validate audit message + /*// Validate audit message ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getFilteredAssetListAuditCategoryNotFound(AssetTypeEnum.RESOURCES, "?" + query, "Application L3+"); Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); + AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body);*/ } - @Test - public void getFilteredResourceAssetSuccess() throws Exception { - - List expectedAssetNamesList = new ArrayList<>(); - - ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource(ResourceCategoryEnum.APPLICATION_L4_APP_SERVER); -// resourceDetails.setName("ciResource11"); - resourceDetails.setResourceType(ResourceTypeEnum.VF.name()); - RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createResource); - Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class); - expectedAssetNamesList.add(resource.getName()); - - resourceDetails = ElementFactory.getDefaultResource(ResourceCategoryEnum.APPLICATION_L4_BORDER); -// resourceDetails.setName("ciResource22"); - resourceDetails.setResourceType(ResourceTypeEnum.VFC.name()); - createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createResource); - resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - - resourceDetails = ElementFactory.getDefaultResource(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE); -// resourceDetails.setName("ciResource33"); - resourceDetails.setResourceType(ResourceTypeEnum.VF.name()); - createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createResource); - resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - - resourceDetails = ElementFactory.getDefaultResource(ResourceCategoryEnum.APPLICATION_L4_FIREWALL); -// resourceDetails.setName("ciResource44"); - resourceDetails.setResourceType(ResourceTypeEnum.VF.name()); - createResource = ResourceRestUtils.createResource(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createResource); - resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - expectedAssetNamesList.add(resource.getName()); - - log.debug("4 resources created"); - String query = "category=Application%20L4%2B"; - RestResponse assetResponse = AssetRestUtils.getFilteredComponentList(AssetTypeEnum.RESOURCES, query); - BaseRestUtils.checkSuccess(assetResponse); - - List resourceAssetList = AssetRestUtils.getResourceAssetList(assetResponse); - List getActualAssetNamesList = AssetRestUtils.getResourceNamesList(resourceAssetList); - Utils.compareArrayLists(getActualAssetNamesList, expectedAssetNamesList, "Element"); + @Test + public void getFilteredResourceAssetSuccess() throws Exception { + + List expectedAssetNamesList = new ArrayList<>(); + + ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource(ResourceCategoryEnum.APPLICATION_L4_APP_SERVER); + resourceDetails.setResourceType(ResourceTypeEnum.VF.name()); + Resource resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, UserRoleEnum.DESIGNER, true).left().value(); + expectedAssetNamesList.add(resource.getName()); + + resourceDetails = ElementFactory.getDefaultResource(ResourceCategoryEnum.APPLICATION_L4_BORDER); + resourceDetails.setResourceType(ResourceTypeEnum.VFC.name()); + resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, UserRoleEnum.DESIGNER, true).left().value(); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + + resourceDetails = ElementFactory.getDefaultResource(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE); + resourceDetails.setResourceType(ResourceTypeEnum.VF.name()); + resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, UserRoleEnum.DESIGNER, true).left().value(); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + resourceDetails = ElementFactory.getDefaultResource(ResourceCategoryEnum.APPLICATION_L4_FIREWALL); + resourceDetails.setResourceType(ResourceTypeEnum.VF.name()); + resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, UserRoleEnum.DESIGNER, true).left().value(); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + expectedAssetNamesList.add(resource.getName()); + + log.debug("4 resources created"); + String query = "category=Application%20L4%2B"; + RestResponse assetResponse = AssetRestUtils.getFilteredComponentList(AssetTypeEnum.RESOURCES, query); + BaseRestUtils.checkSuccess(assetResponse); + + List resourceAssetList = AssetRestUtils.getResourceAssetList(assetResponse); + List getActualAssetNamesList = AssetRestUtils.getResourceNamesList(resourceAssetList); + Utils.compareArrayLists(getActualAssetNamesList, expectedAssetNamesList, "Element"); // Andrey L. This condition can not be checked in case resources list has two or ore different resource types // AssetRestUtils.checkResourceTypeInObjectList(resourceAssetList, ResourceTypeEnum.VF); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultFilteredAssetListAudit(AssetTypeEnum.RESOURCES, "?" + query); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); - - } - - @Test - public void getFilteredServiceAssetInformationalSuccess() throws Exception { - - List expectedAssetNamesList = new ArrayList<>(); - ArtifactReqDetails artifactDetails = ElementFactory.getArtifactByType(ArtifactTypeEnum.OTHER, ArtifactTypeEnum.OTHER, true); - artifactDetails.setArtifactGroupType(ArtifactGroupTypeEnum.INFORMATIONAL.getType()); - - ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(); - serviceDetails.setName("ciService111"); - RestResponse createService = ServiceRestUtils.createService(serviceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createService); - Service service = ResponseParser.parseToObjectUsingMapper(createService.getResponse(), Service.class); - - serviceDetails.setName("ciService222"); - createService = ServiceRestUtils.createService(serviceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createService); - service = ResponseParser.parseToObjectUsingMapper(createService.getResponse(), Service.class); - RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(artifactDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), service.getUniqueId()); - BaseRestUtils.checkSuccess(addInformationalArtifactToService); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - - ServiceReqDetails certifyService = new ServiceReqDetails(service); - LifecycleRestUtils.changeDistributionStatus(certifyService, certifyService.getVersion(), ElementFactory.getDefaultUser(UserRoleEnum.GOVERNOR), null, DistributionStatusEnum.DISTRIBUTION_APPROVED); - AtomicOperationUtils.distributeService(service, false); - expectedAssetNamesList.add(service.getName()); - - serviceDetails.setName("ciService333"); - createService = ServiceRestUtils.createService(serviceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createService); - service = ResponseParser.parseToObjectUsingMapper(createService.getResponse(), Service.class); - addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(artifactDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), service.getUniqueId()); - BaseRestUtils.checkSuccess(addInformationalArtifactToService); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - certifyService = new ServiceReqDetails(service); - LifecycleRestUtils.changeDistributionStatus(certifyService, certifyService.getVersion(), ElementFactory.getDefaultUser(UserRoleEnum.GOVERNOR), null, DistributionStatusEnum.DISTRIBUTION_APPROVED); - AtomicOperationUtils.distributeService(service, false); - expectedAssetNamesList.add(service.getName()); - - serviceDetails.setName("ciService444"); - createService = ServiceRestUtils.createService(serviceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createService); - service = ResponseParser.parseToObjectUsingMapper(createService.getResponse(), Service.class); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); - - serviceDetails.setName("ciService555"); - createService = ServiceRestUtils.createService(serviceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createService); - service = ResponseParser.parseToObjectUsingMapper(createService.getResponse(), Service.class); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - - String query = "distributionStatus=Distributed"; - RestResponse assetResponse = AssetRestUtils.getFilteredComponentList(AssetTypeEnum.SERVICES, query); - BaseRestUtils.checkSuccess(assetResponse); - - List resourceAssetList = AssetRestUtils.getServiceAssetList(assetResponse); - List getActualAssetNamesList = AssetRestUtils.getServiceNamesList(resourceAssetList); - Utils.compareArrayLists(getActualAssetNamesList, expectedAssetNamesList, "Element"); - - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultFilteredAssetListAudit(AssetTypeEnum.SERVICES, "?" + query); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); - - } - - @Test - public void getFilteredServiceAssetDeploymentSuccess() throws Exception { - - List expectedAssetNamesList = new ArrayList<>(); - ArtifactReqDetails artifactDetails = ElementFactory.getArtifactByType(ArtifactTypeEnum.OTHER, ArtifactTypeEnum.OTHER, true); - - ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(); - serviceDetails.setName("ciService666"); - RestResponse createService = ServiceRestUtils.createService(serviceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createService); - Service service = ResponseParser.parseToObjectUsingMapper(createService.getResponse(), Service.class); - - serviceDetails.setName("ciService777"); - createService = ServiceRestUtils.createService(serviceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createService); - service = ResponseParser.parseToObjectUsingMapper(createService.getResponse(), Service.class); - RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(artifactDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), service.getUniqueId()); - BaseRestUtils.checkSuccess(addInformationalArtifactToService); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - - ServiceReqDetails certifyService = new ServiceReqDetails(service); - LifecycleRestUtils.changeDistributionStatus(certifyService, certifyService.getVersion(), ElementFactory.getDefaultUser(UserRoleEnum.GOVERNOR), null, DistributionStatusEnum.DISTRIBUTION_APPROVED); - AtomicOperationUtils.distributeService(service, false); - expectedAssetNamesList.add(service.getName()); - - serviceDetails.setName("ciService888"); - createService = ServiceRestUtils.createService(serviceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createService); - service = ResponseParser.parseToObjectUsingMapper(createService.getResponse(), Service.class); - addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(artifactDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), service.getUniqueId()); - BaseRestUtils.checkSuccess(addInformationalArtifactToService); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - certifyService = new ServiceReqDetails(service); - LifecycleRestUtils.changeDistributionStatus(certifyService, certifyService.getVersion(), ElementFactory.getDefaultUser(UserRoleEnum.GOVERNOR), null, DistributionStatusEnum.DISTRIBUTION_APPROVED); - AtomicOperationUtils.distributeService(service, false); - expectedAssetNamesList.add(service.getName()); - - serviceDetails.setName("ciService999"); - createService = ServiceRestUtils.createService(serviceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createService); - service = ResponseParser.parseToObjectUsingMapper(createService.getResponse(), Service.class); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); - - serviceDetails.setName("ciService000"); - createService = ServiceRestUtils.createService(serviceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER)); - BaseRestUtils.checkCreateResponse(createService); - service = ResponseParser.parseToObjectUsingMapper(createService.getResponse(), Service.class); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - - String query = "distributionStatus=Distributed"; - RestResponse assetResponse = AssetRestUtils.getFilteredComponentList(AssetTypeEnum.SERVICES, query); - BaseRestUtils.checkSuccess(assetResponse); - - List resourceAssetList = AssetRestUtils.getServiceAssetList(assetResponse); - List getActualAssetNamesList = AssetRestUtils.getServiceNamesList(resourceAssetList); - Utils.compareArrayLists(getActualAssetNamesList, expectedAssetNamesList, "Element"); - - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultFilteredAssetListAudit(AssetTypeEnum.SERVICES, "?" + query); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); - - } - + /*// Validate audit message + validateFilteredAudit(query, AssetTypeEnum.RESOURCES);*/ + + } + + @Test + public void getFilteredServiceAssetInformationalSuccess() throws Exception { + + List expectedAssetNamesList = new ArrayList<>(); + ArtifactReqDetails artifactDetails = ElementFactory.getArtifactByType(ArtifactTypeEnum.OTHER, ArtifactTypeEnum.OTHER, true); + artifactDetails.setArtifactGroupType(ArtifactGroupTypeEnum.INFORMATIONAL.getType()); + + ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(); + Service service = AtomicOperationUtils.createCustomService(serviceDetails, UserRoleEnum.DESIGNER, true).left().value(); + + serviceDetails = ElementFactory.getDefaultService(); + service = AtomicOperationUtils.createCustomService(serviceDetails, UserRoleEnum.DESIGNER, true).left().value(); + RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(artifactDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), service.getUniqueId()); + BaseRestUtils.checkSuccess(addInformationalArtifactToService); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + ServiceReqDetails certifyService = new ServiceReqDetails(service); + LifecycleRestUtils.changeDistributionStatus(certifyService, certifyService.getVersion(), ElementFactory.getDefaultUser(UserRoleEnum.GOVERNOR), null, DistributionStatusEnum.DISTRIBUTION_APPROVED); + AtomicOperationUtils.distributeService(service, false); + expectedAssetNamesList.add(service.getName()); + + serviceDetails = ElementFactory.getDefaultService(); + service = AtomicOperationUtils.createCustomService(serviceDetails, UserRoleEnum.DESIGNER, true).left().value(); + addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(artifactDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), service.getUniqueId()); + BaseRestUtils.checkSuccess(addInformationalArtifactToService); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + certifyService = new ServiceReqDetails(service); + LifecycleRestUtils.changeDistributionStatus(certifyService, certifyService.getVersion(), ElementFactory.getDefaultUser(UserRoleEnum.GOVERNOR), null, DistributionStatusEnum.DISTRIBUTION_APPROVED); + AtomicOperationUtils.distributeService(service, false); + expectedAssetNamesList.add(service.getName()); + + serviceDetails = ElementFactory.getDefaultService(); + service = AtomicOperationUtils.createCustomService(serviceDetails, UserRoleEnum.DESIGNER, true).left().value(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); + + serviceDetails = ElementFactory.getDefaultService(); + service = AtomicOperationUtils.createCustomService(serviceDetails, UserRoleEnum.DESIGNER, true).left().value(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + + String query = "distributionStatus=Distributed"; + RestResponse assetResponse = AssetRestUtils.getFilteredComponentList(AssetTypeEnum.SERVICES, query); + BaseRestUtils.checkSuccess(assetResponse); + + List resourceAssetList = AssetRestUtils.getServiceAssetList(assetResponse); + List getActualAssetNamesList = AssetRestUtils.getServiceNamesList(resourceAssetList); + Utils.compareArrayLists(getActualAssetNamesList, expectedAssetNamesList, "Element"); + + /*// Validate audit message + validateFilteredAudit(query, AssetTypeEnum.SERVICES);*/ + + } + + @Test + public void getFilteredServiceAssetDeploymentSuccess() throws Exception { + + List expectedAssetNamesList = new ArrayList<>(); + ArtifactReqDetails artifactDetails = ElementFactory.getArtifactByType(ArtifactTypeEnum.OTHER, ArtifactTypeEnum.OTHER, true); + + ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(); + Service service = AtomicOperationUtils.createCustomService(serviceDetails, UserRoleEnum.DESIGNER, true).left().value(); + + serviceDetails = ElementFactory.getDefaultService(); + service = AtomicOperationUtils.createCustomService(serviceDetails, UserRoleEnum.DESIGNER, true).left().value(); + RestResponse addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(artifactDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), service.getUniqueId()); + BaseRestUtils.checkSuccess(addInformationalArtifactToService); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + ServiceReqDetails certifyService = new ServiceReqDetails(service); + LifecycleRestUtils.changeDistributionStatus(certifyService, certifyService.getVersion(), ElementFactory.getDefaultUser(UserRoleEnum.GOVERNOR), null, DistributionStatusEnum.DISTRIBUTION_APPROVED); + AtomicOperationUtils.distributeService(service, false); + expectedAssetNamesList.add(service.getName()); + + serviceDetails = ElementFactory.getDefaultService(); + service = AtomicOperationUtils.createCustomService(serviceDetails, UserRoleEnum.DESIGNER, true).left().value(); + addInformationalArtifactToService = ArtifactRestUtils.addInformationalArtifactToService(artifactDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), service.getUniqueId()); + BaseRestUtils.checkSuccess(addInformationalArtifactToService); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + certifyService = new ServiceReqDetails(service); + LifecycleRestUtils.changeDistributionStatus(certifyService, certifyService.getVersion(), ElementFactory.getDefaultUser(UserRoleEnum.GOVERNOR), null, DistributionStatusEnum.DISTRIBUTION_APPROVED); + AtomicOperationUtils.distributeService(service, false); + expectedAssetNamesList.add(service.getName()); + + serviceDetails = ElementFactory.getDefaultService(); + service = AtomicOperationUtils.createCustomService(serviceDetails, UserRoleEnum.DESIGNER, true).left().value(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); + + serviceDetails = ElementFactory.getDefaultService(); + service = AtomicOperationUtils.createCustomService(serviceDetails, UserRoleEnum.DESIGNER, true).left().value(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + + String query = "distributionStatus=Distributed"; + RestResponse assetResponse = AssetRestUtils.getFilteredComponentList(AssetTypeEnum.SERVICES, query); + BaseRestUtils.checkSuccess(assetResponse); + + List resourceAssetList = AssetRestUtils.getServiceAssetList(assetResponse); + List getActualAssetNamesList = AssetRestUtils.getServiceNamesList(resourceAssetList); + Utils.compareArrayLists(getActualAssetNamesList, expectedAssetNamesList, "Element"); + + /*// Validate audit message + validateFilteredAudit(query, AssetTypeEnum.SERVICES);*/ + } + + /*private void validateSuccessAudit(String[] filter, AssetTypeEnum assetType) throws Exception { + ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetListAudit(assetType, AuditingActionEnum.GET_FILTERED_ASSET_LIST); + expectedAssetListAudit.setRESOURCE_URL(AssetRestUtils.buildUrlWithFilter(expectedAssetListAudit.getRESOURCE_URL(), filter)); + Map body = new HashMap<>(); + body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); + AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); + } + + private void validateFilteredAudit(String query, AssetTypeEnum assetType) throws Exception { + ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultFilteredAssetListAudit(assetType, "?" + query); + Map body = new HashMap<>(); + body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); + AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); + } + + private void validateFailureAudit(String[] filter, ErrorInfo errorInfo, List variables, AssetTypeEnum assetType) throws Exception { + ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetListAudit(assetType, AuditingActionEnum.GET_FILTERED_ASSET_LIST); + expectedAssetListAudit.setRESOURCE_URL(AssetRestUtils.buildUrlWithFilter(expectedAssetListAudit.getRESOURCE_URL(), filter)); + expectedAssetListAudit.setSTATUS(errorInfo.getCode().toString()); + expectedAssetListAudit.setDESC(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); + Map body = new HashMap<>(); + body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); + AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); + }*/ } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetSpecificAssetMetadataServlet.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetSpecificAssetMetadataServlet.java index a55a458168..c036c7fb41 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetSpecificAssetMetadataServlet.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetSpecificAssetMetadataServlet.java @@ -21,24 +21,21 @@ package org.openecomp.sdc.externalApis; import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.enums.AssetTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; +import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; -import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.datatypes.ResourceDetailedAssetStructure; import org.openecomp.sdc.ci.tests.datatypes.ServiceDetailedAssetStructure; import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; -import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedExternalAudit; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; @@ -47,9 +44,7 @@ import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils; -import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; import org.testng.annotations.Test; public class GetSpecificAssetMetadataServlet extends ComponentBaseTest { @@ -80,11 +75,8 @@ public class GetSpecificAssetMetadataServlet extends ComponentBaseTest { ResourceDetailedAssetStructure resourceAssetMetadata = AssetRestUtils.getResourceAssetMetadata(assetResponse); AssetRestUtils.resourceMetadataValidatior(resourceAssetMetadata, resourceVF, AssetTypeEnum.RESOURCES); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetMetadataAudit(AssetTypeEnum.RESOURCES, resourceVF); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_ASSET_METADATA.getName(), body); + /* // Validate audit message + validateAudit(resourceVF, AssetTypeEnum.RESOURCES);*/ } @Test // (enabled = false) @@ -103,12 +95,8 @@ public class GetSpecificAssetMetadataServlet extends ComponentBaseTest { ResourceDetailedAssetStructure resourceAssetMetadata = AssetRestUtils.getResourceAssetMetadata(assetResponse); AssetRestUtils.resourceMetadataValidatior(resourceAssetMetadata, resourceVF, AssetTypeEnum.RESOURCES); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory - .getDefaultAssetMetadataAudit(AssetTypeEnum.RESOURCES, resourceVF); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_ASSET_METADATA.getName(), body); + /*// Validate audit message + validateAudit(resourceVF, AssetTypeEnum.RESOURCES);*/ } @Test // (enabled = false) @@ -137,11 +125,8 @@ public class GetSpecificAssetMetadataServlet extends ComponentBaseTest { ResourceDetailedAssetStructure resourceAssetMetadata = AssetRestUtils.getResourceAssetMetadata(assetResponse); AssetRestUtils.resourceMetadataValidatior(resourceAssetMetadata, resourceVF, AssetTypeEnum.RESOURCES); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetMetadataAudit(AssetTypeEnum.RESOURCES, resourceVF); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_ASSET_METADATA.getName(), body); + /* // Validate audit message + validateAudit(resourceVF, AssetTypeEnum.RESOURCES);*/ } @Test // (enabled = false) @@ -170,11 +155,8 @@ public class GetSpecificAssetMetadataServlet extends ComponentBaseTest { ResourceDetailedAssetStructure resourceAssetMetadata = AssetRestUtils.getResourceAssetMetadata(assetResponse); AssetRestUtils.resourceMetadataValidatior(resourceAssetMetadata, resourceVF, AssetTypeEnum.RESOURCES); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetMetadataAudit(AssetTypeEnum.RESOURCES, resourceVF); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_ASSET_METADATA.getName(), body); + /* // Validate audit message + validateAudit(resourceVF, AssetTypeEnum.RESOURCES);*/ } @Test // (enabled = false) @@ -203,11 +185,8 @@ public class GetSpecificAssetMetadataServlet extends ComponentBaseTest { ResourceDetailedAssetStructure resourceAssetMetadata = AssetRestUtils.getResourceAssetMetadata(assetResponse); AssetRestUtils.resourceMetadataValidatior(resourceAssetMetadata, resourceVF, AssetTypeEnum.RESOURCES); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetMetadataAudit(AssetTypeEnum.RESOURCES, resourceVF); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_ASSET_METADATA.getName(), body); + /*// Validate audit message + validateAudit(resourceVF, AssetTypeEnum.RESOURCES);*/ } @Test // (enabled = false) @@ -236,11 +215,8 @@ public class GetSpecificAssetMetadataServlet extends ComponentBaseTest { ResourceDetailedAssetStructure resourceAssetMetadata = AssetRestUtils.getResourceAssetMetadata(assetResponse); AssetRestUtils.resourceMetadataValidatior(resourceAssetMetadata, resourceVF, AssetTypeEnum.RESOURCES); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetMetadataAudit(AssetTypeEnum.RESOURCES, resourceVF); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_ASSET_METADATA.getName(), body); + /* // Validate audit message + validateAudit(resourceVF, AssetTypeEnum.RESOURCES);*/ } @Test // (enabled = false) @@ -265,13 +241,11 @@ public class GetSpecificAssetMetadataServlet extends ComponentBaseTest { ResourceDetailedAssetStructure resourceAssetMetadata = AssetRestUtils.getResourceAssetMetadata(assetResponse); AssetRestUtils.resourceMetadataValidatior(resourceAssetMetadata, resourceVF, AssetTypeEnum.RESOURCES); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetMetadataAudit(AssetTypeEnum.RESOURCES, resourceVF); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_ASSET_METADATA.getName(), body); + /*// Validate audit message + validateAudit(resourceVF, AssetTypeEnum.RESOURCES);*/ } + // Import CSAR // Service @@ -286,11 +260,8 @@ public class GetSpecificAssetMetadataServlet extends ComponentBaseTest { ServiceDetailedAssetStructure serviceAssetMetadata = AssetRestUtils.getServiceAssetMetadata(assetResponse); AssetRestUtils.serviceMetadataValidatior(serviceAssetMetadata, service, AssetTypeEnum.SERVICES); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetMetadataAudit(AssetTypeEnum.SERVICES, service); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_ASSET_METADATA.getName(), body); + /*// Validate audit message + validateAudit(service, AssetTypeEnum.SERVICES);*/ } @Test // (enabled = false) @@ -309,11 +280,8 @@ public class GetSpecificAssetMetadataServlet extends ComponentBaseTest { ServiceDetailedAssetStructure serviceAssetMetadata = AssetRestUtils.getServiceAssetMetadata(assetResponse); AssetRestUtils.serviceMetadataValidatior(serviceAssetMetadata, service, AssetTypeEnum.SERVICES); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetMetadataAudit(AssetTypeEnum.SERVICES, service); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_ASSET_METADATA.getName(), body); + /*// Validate audit message + validateAudit(service, AssetTypeEnum.SERVICES);*/ } @@ -345,11 +313,8 @@ public class GetSpecificAssetMetadataServlet extends ComponentBaseTest { ServiceDetailedAssetStructure serviceAssetMetadata = AssetRestUtils.getServiceAssetMetadata(assetResponse); AssetRestUtils.serviceMetadataValidatior(serviceAssetMetadata, service, AssetTypeEnum.SERVICES); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetMetadataAudit(AssetTypeEnum.SERVICES, service); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_ASSET_METADATA.getName(), body); + /*// Validate audit message + validateAudit(service, AssetTypeEnum.SERVICES);*/ } @@ -385,11 +350,8 @@ public class GetSpecificAssetMetadataServlet extends ComponentBaseTest { ServiceDetailedAssetStructure serviceAssetMetadata = AssetRestUtils.getServiceAssetMetadata(assetResponse); AssetRestUtils.serviceMetadataValidatior(serviceAssetMetadata, service, AssetTypeEnum.SERVICES); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetMetadataAudit(AssetTypeEnum.SERVICES, service); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_ASSET_METADATA.getName(), body); + /*// Validate audit message + validateAudit(service, AssetTypeEnum.SERVICES);*/ } @@ -424,11 +386,8 @@ public class GetSpecificAssetMetadataServlet extends ComponentBaseTest { ServiceDetailedAssetStructure serviceAssetMetadata = AssetRestUtils.getServiceAssetMetadata(assetResponse); AssetRestUtils.serviceMetadataValidatior(serviceAssetMetadata, service, AssetTypeEnum.SERVICES); - // Validate audit message - ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetMetadataAudit(AssetTypeEnum.SERVICES, service); - Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); - AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_ASSET_METADATA.getName(), body); + /*// Validate audit message + validateAudit(service, AssetTypeEnum.SERVICES);*/ } @Test // (enabled = false) @@ -443,4 +402,11 @@ public class GetSpecificAssetMetadataServlet extends ComponentBaseTest { ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.SERVICE_NOT_FOUND.name(), variables, assetResponse.getResponse()); } + /*private void validateAudit(Component component, AssetTypeEnum assetType) throws Exception { + ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetMetadataAudit(assetType, component); + Map body = new HashMap<>(); + body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL()); + AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_ASSET_METADATA.getName(), body); + }*/ + } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/SearchFilterCategoryExternalAPI.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/SearchFilterCategoryExternalAPI.java index ca7c5aefb9..8b174e550d 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/SearchFilterCategoryExternalAPI.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/SearchFilterCategoryExternalAPI.java @@ -20,13 +20,10 @@ package org.openecomp.sdc.externalApis; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; - +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; import org.json.simple.parser.JSONParser; import org.junit.Rule; import org.junit.rules.TestName; @@ -36,34 +33,29 @@ import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.category.CategoryDefinition; import org.openecomp.sdc.be.model.category.SubCategoryDefinition; -import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.config.Config; import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo; import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.SearchCriteriaEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; -import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedExternalAudit; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.utils.rest.CategoryRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; -import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Random; public class SearchFilterCategoryExternalAPI extends ComponentBaseTest { @@ -101,15 +93,19 @@ public class SearchFilterCategoryExternalAPI extends ComponentBaseTest { List variables = Arrays.asList("resourceTypeinvalid", "[resourceType, subCategory, category]"); ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FILTER_KEY.name(), variables, restResponse.getResponse()); + /*validateFailureAudit(variables);*/ + } + + /*private void validateFailureAudit(List variables) throws Exception { ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalAuditObject(AssetTypeEnum.RESOURCES, AuditingActionEnum.GET_FILTERED_ASSET_LIST, "?" + SearchCriteriaEnum.RESOURCE_TYPE.getValue() + "invalid=" + ResourceTypeEnum.VFC.toString()); ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_FILTER_KEY.name()); expectedExternalAudit.setDESC(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); expectedExternalAudit.setSTATUS("400"); - Map body = new HashMap<>(); + Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedExternalAudit.getRESOURCE_URL()); AuditValidationUtils.validateAuditExternalSearchAPI(expectedExternalAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); - } - + }*/ + @DataProvider(name="searchForResourceTypeNegativeTest", parallel=true) public static Object[][] dataProviderSearchForResourceTypeNegativeTest() { return new Object[][] { @@ -129,13 +125,13 @@ public class SearchFilterCategoryExternalAPI extends ComponentBaseTest { List variables = Arrays.asList(); ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_CONTENT.name(), variables, restResponse.getResponse()); - ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalAuditObject(AssetTypeEnum.RESOURCES, AuditingActionEnum.GET_FILTERED_ASSET_LIST, "?" + SearchCriteriaEnum.RESOURCE_TYPE.getValue() + "=" + resourceType); + /*ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalAuditObject(AssetTypeEnum.RESOURCES, AuditingActionEnum.GET_FILTERED_ASSET_LIST, "?" + SearchCriteriaEnum.RESOURCE_TYPE.getValue() + "=" + resourceType); ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_CONTENT.name()); expectedExternalAudit.setDESC(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); expectedExternalAudit.setSTATUS("400"); Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedExternalAudit.getRESOURCE_URL()); - AuditValidationUtils.validateAuditExternalSearchAPI(expectedExternalAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); + AuditValidationUtils.validateAuditExternalSearchAPI(expectedExternalAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body);*/ } // Searching for resource filter incorrect resource type using external API @@ -160,10 +156,10 @@ public class SearchFilterCategoryExternalAPI extends ComponentBaseTest { } - ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalAuditObject(AssetTypeEnum.RESOURCES, AuditingActionEnum.GET_FILTERED_ASSET_LIST, "?" + SearchCriteriaEnum.RESOURCE_TYPE.getValue() + "=" + resourceTypeEnum.toString()); + /*ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalAuditObject(AssetTypeEnum.RESOURCES, AuditingActionEnum.GET_FILTERED_ASSET_LIST, "?" + SearchCriteriaEnum.RESOURCE_TYPE.getValue() + "=" + resourceTypeEnum.toString()); Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedExternalAudit.getRESOURCE_URL()); - AuditValidationUtils.validateAuditExternalSearchAPI(expectedExternalAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); + AuditValidationUtils.validateAuditExternalSearchAPI(expectedExternalAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body);*/ } } @@ -182,10 +178,10 @@ public class SearchFilterCategoryExternalAPI extends ComponentBaseTest { Assert.assertEquals(restResponse.getErrorCode(), expectedResponseCode); validateJsonContainResource(restResponse.getResponse(), createdResoucesName, true); - ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalAuditObject(AssetTypeEnum.RESOURCES, AuditingActionEnum.GET_FILTERED_ASSET_LIST, "?" + SearchCriteriaEnum.RESOURCE_TYPE.getValue() + "=" + resourceTypeEnum.toString()); + /*ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalAuditObject(AssetTypeEnum.RESOURCES, AuditingActionEnum.GET_FILTERED_ASSET_LIST, "?" + SearchCriteriaEnum.RESOURCE_TYPE.getValue() + "=" + resourceTypeEnum.toString()); Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedExternalAudit.getRESOURCE_URL()); - AuditValidationUtils.validateAuditExternalSearchAPI(expectedExternalAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body); + AuditValidationUtils.validateAuditExternalSearchAPI(expectedExternalAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body);*/ } } @@ -209,8 +205,8 @@ public class SearchFilterCategoryExternalAPI extends ComponentBaseTest { Assert.assertEquals(restResponse.getErrorCode(), expectedResponseCode); validateJsonContainResource(restResponse.getResponse(), createdResoucesName, true); - ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalAuditObject(AssetTypeEnum.RESOURCES, AuditingActionEnum.GET_FILTERED_ASSET_LIST, "?" + SearchCriteriaEnum.RESOURCE_TYPE.getValue() + "=" + ResourceTypeEnum.VFCMT.toString()); - AuditValidationUtils.validateAuditExternalSearchAPI(expectedExternalAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), null); + /*ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalAuditObject(AssetTypeEnum.RESOURCES, AuditingActionEnum.GET_FILTERED_ASSET_LIST, "?" + SearchCriteriaEnum.RESOURCE_TYPE.getValue() + "=" + ResourceTypeEnum.VFCMT.toString()); + AuditValidationUtils.validateAuditExternalSearchAPI(expectedExternalAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), null);*/ } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/VFCMTExternalAPI.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/VFCMTExternalAPI.java index cd96af225f..4cd5c1c0d5 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/VFCMTExternalAPI.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/VFCMTExternalAPI.java @@ -20,21 +20,16 @@ package org.openecomp.sdc.externalApis; -import static java.util.Arrays.asList; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; import org.json.simple.parser.JSONParser; import org.junit.Rule; import org.junit.rules.TestName; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.enums.AssetTypeEnum; -import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; import org.openecomp.sdc.ci.tests.config.Config; import org.openecomp.sdc.ci.tests.datatypes.ResourceAssetStructure; @@ -45,25 +40,22 @@ import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo; import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.SearchCriteriaEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; -import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaObject; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.utils.rest.AssetRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtilsExternalAPI; -import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; -import org.openecomp.sdc.common.util.ValidationUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; +import java.util.List; + +import static java.util.Arrays.asList; +import static org.testng.Assert.assertTrue; public class VFCMTExternalAPI extends ComponentBaseTest { @@ -110,12 +102,12 @@ public class VFCMTExternalAPI extends ComponentBaseTest { RestResponse restResponse = ResourceRestUtilsExternalAPI.createResource(defaultResource, defaultUser); ResourceAssetStructure parsedCreatedResponse = gson.fromJson(restResponse.getResponse(), ResourceAssetStructure.class); - // auditing verification + /* // auditing verification AuditingActionEnum action = AuditingActionEnum.CREATE_RESOURCE_BY_API; Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, parsedCreatedResponse.getName()); - ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultCreateResourceExternalAPI(parsedCreatedResponse.getName()); - AuditValidationUtils.validateAuditExternalCreateResource(expectedResourceAuditJavaObject, action.getName(), body); + ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultCreateResourceExternalAPI(parsedCreatedResponse.getName()); + AuditValidationUtils.validateAuditExternalCreateResource(expectedResourceAuditJavaObject, action.getName(), body);*/ // search for vfcmt via external api - validate created resource exist RestResponse searchResult = ResourceRestUtils.getResourceListFilterByCriteria(ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), AssetTypeEnum.RESOURCES.getValue(), SearchCriteriaEnum.RESOURCE_TYPE.getValue(), ResourceTypeEnum.VFCMT.toString()); @@ -158,28 +150,28 @@ public class VFCMTExternalAPI extends ComponentBaseTest { RestResponse firstTryToCreate = ResourceRestUtilsExternalAPI.createResource(defaultResource, defaultUser); ResourceAssetStructure parsedCreatedResponse = gson.fromJson(firstTryToCreate.getResponse(), ResourceAssetStructure.class); - // auditing verification + /*// auditing verification AuditingActionEnum action = AuditingActionEnum.CREATE_RESOURCE_BY_API; Map body = new HashMap<>(); body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, parsedCreatedResponse.getName()); ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultCreateResourceExternalAPI(parsedCreatedResponse.getName()); - AuditValidationUtils.validateAuditExternalCreateResource(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalCreateResource(expectedResourceAuditJavaObject, action.getName(), body);*/ // try to create another vfcmt wit same name RestResponse secondTryToCreate = ResourceRestUtilsExternalAPI.createResource(defaultResource, defaultUser); Assert.assertEquals((int)secondTryToCreate.getErrorCode(), 409); - body.put(AuditingFieldsKeysEnum.AUDIT_STATUS, "409"); + /*body.put(AuditingFieldsKeysEnum.AUDIT_STATUS, "409"); ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_NAME_ALREADY_EXIST.name()); List variables = asList(ComponentTypeEnum.RESOURCE.getValue(), defaultResource.getName()); expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); expectedResourceAuditJavaObject.setStatus("409"); - AuditValidationUtils.validateAuditExternalCreateResource(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalCreateResource(expectedResourceAuditJavaObject, action.getName(), body);*/ } - @DataProvider(name="createVfcmtVariousFailureFlows", parallel=true) + @DataProvider(name="createVfcmtVariousFailureFlows", parallel=true) public static Object[][] dataProviderCreateVfcmtVariousFailureFlows() { return new Object[][] { {"name_missing"}, @@ -217,11 +209,11 @@ public class VFCMTExternalAPI extends ComponentBaseTest { ResourceExternalReqDetails defaultResource = ElementFactory.getDefaultResourceByType("ci", ResourceCategoryEnum.TEMPLATE_MONITORING_TEMPLATE, defaultUser.getUserId(), ResourceTypeEnum.VFCMT.toString()); ErrorInfo errorInfo = null; - List variables = null; + /*List variables = null; AuditingActionEnum action = AuditingActionEnum.CREATE_RESOURCE_BY_API; ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultCreateResourceExternalAPI(defaultResource.getName()); Map body = new HashMap<>(); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, defaultResource.getName()); + body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, defaultResource.getName());*/ switch (flow) { case "name_missing": @@ -229,149 +221,149 @@ public class VFCMTExternalAPI extends ComponentBaseTest { List resourceTags = defaultResource.getTags(); resourceTags.add(""); defaultResource.setTags(resourceTags); - expectedResourceAuditJavaObject.setResourceName(""); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_COMPONENT_NAME.name()); + /*expectedResourceAuditJavaObject.setResourceName(""); variables = asList(ComponentTypeEnum.RESOURCE.getValue()); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, ""); + body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, "");*/ break; case "name_to_long": defaultResource.setName("asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1"); - expectedResourceAuditJavaObject.setResourceName("asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1"); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT.name()); + /*expectedResourceAuditJavaObject.setResourceName("asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1"); variables = asList(ComponentTypeEnum.RESOURCE.getValue(), "1024"); - - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, "asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1"); + body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, "asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1");*/ break; case "name_with_invalid_char": defaultResource.setName("!@#$%^&*("); - expectedResourceAuditJavaObject.setResourceName("!@#$%^&*("); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_COMPONENT_NAME.name()); + /*expectedResourceAuditJavaObject.setResourceName("!@#$%^&*("); variables = asList(ComponentTypeEnum.RESOURCE.getValue()); - body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, "!@#$%^&*("); + body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, "!@#$%^&*(");*/ break; case "description_missing": defaultResource.setDescription(""); - expectedResourceAuditJavaObject.setDesc(""); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name()); - variables = asList(ComponentTypeEnum.RESOURCE.getValue()); + /*expectedResourceAuditJavaObject.setDesc(""); + variables = asList(ComponentTypeEnum.RESOURCE.getValue());*/ break; case "description_to_long": defaultResource.setDescription("asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1"); - expectedResourceAuditJavaObject.setDesc("asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1"); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT.name()); - variables = asList(ComponentTypeEnum.RESOURCE.getValue(), "1024"); + /*expectedResourceAuditJavaObject.setDesc("asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1"); + variables = asList(ComponentTypeEnum.RESOURCE.getValue(), "1024");*/ break; case "description_with_invalid_char": defaultResource.setDescription("\uC2B5"); - expectedResourceAuditJavaObject.setDesc("t"); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_INVALID_DESCRIPTION.name()); - variables = asList(ComponentTypeEnum.RESOURCE.getValue()); + /*expectedResourceAuditJavaObject.setDesc("t"); + variables = asList(ComponentTypeEnum.RESOURCE.getValue());*/ break; // TODO: defect on the flow - need to get error instead create VFC case "resource_type_missing": defaultResource.setResourceType(""); - expectedResourceAuditJavaObject.setResourceType(""); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_CONTENT.name()); - variables = asList(ComponentTypeEnum.RESOURCE.getValue()); + /*expectedResourceAuditJavaObject.setResourceType(""); + variables = asList(ComponentTypeEnum.RESOURCE.getValue());*/ break; // TODO: in audit RESOURCE_NAME is empty case "resource_type_invalid": defaultResource.setResourceType("invalid"); - expectedResourceAuditJavaObject.setResourceType(ComponentTypeEnum.RESOURCE.getValue()); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_RESOURCE_TYPE.name()); - variables = asList(ComponentTypeEnum.RESOURCE.getValue()); + /*expectedResourceAuditJavaObject.setResourceType(ComponentTypeEnum.RESOURCE.getValue()); + variables = asList(ComponentTypeEnum.RESOURCE.getValue());*/ break; case "category_type_missing": defaultResource.setCategory(""); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_MISSING_CATEGORY.name()); - variables = asList(ComponentTypeEnum.RESOURCE.getValue()); + /*variables = asList(ComponentTypeEnum.RESOURCE.getValue());*/ break; // TODO: not correct response code in this flow - 500 instead 400 case "category_type_invalid": defaultResource.setCategory("invalid"); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_INVALID_CATEGORY.name()); - variables = asList(ComponentTypeEnum.RESOURCE.getValue()); + /*variables = asList(ComponentTypeEnum.RESOURCE.getValue());*/ break; case "subcategory_type_missing": defaultResource.setSubcategory(""); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_MISSING_SUBCATEGORY.name()); - variables = asList(ComponentTypeEnum.RESOURCE.getValue()); + /*variables = asList(ComponentTypeEnum.RESOURCE.getValue());*/ break; // TODO: not correct error - it not missing it not correct case "subcategory_type_invalid": defaultResource.setSubcategory("invalid"); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_INVALID_SUBCATEGORY.name()); - variables = asList(ComponentTypeEnum.RESOURCE.getValue()); + /*variables = asList(ComponentTypeEnum.RESOURCE.getValue());*/ break; case "vendor_name_missing": defaultResource.setVendorName(""); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_VENDOR_NAME.name()); - variables = asList(ComponentTypeEnum.RESOURCE.getValue()); + /*variables = asList(ComponentTypeEnum.RESOURCE.getValue());*/ break; case "vendor_name_to_long": defaultResource.setVendorName("asdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdff"); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT.name()); - variables = asList(ValidationUtils.VENDOR_NAME_MAX_LENGTH.toString()); + /*variables = asList(ValidationUtils.VENDOR_NAME_MAX_LENGTH.toString());*/ break; case "vendor_name_with_invalid_char": defaultResource.setVendorName("!@#$*()&*^%$#@"); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_VENDOR_NAME.name()); - variables = asList(ComponentTypeEnum.RESOURCE.getValue()); + /*variables = asList(ComponentTypeEnum.RESOURCE.getValue());*/ break; case "vendor_release_missing": defaultResource.setVendorRelease(""); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_VENDOR_RELEASE.name()); - variables = asList(ComponentTypeEnum.RESOURCE.getValue()); + /*variables = asList(ComponentTypeEnum.RESOURCE.getValue());*/ break; case "vendor_release_to_long": defaultResource.setVendorRelease("asdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdff"); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name()); - variables = asList("25"); + /*variables = asList("25");*/ break; case "vendor_release_with_invalid_char": defaultResource.setVendorRelease("!@#$*()&*^%$#@"); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_VENDOR_RELEASE.name()); - variables = asList(ComponentTypeEnum.RESOURCE.getValue()); + /*variables = asList(ComponentTypeEnum.RESOURCE.getValue());*/ break; case "tags_missing": defaultResource.setTags(asList("")); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_FIELD_FORMAT.name()); - variables = asList(ComponentTypeEnum.RESOURCE.getValue(), "tag"); + /*variables = asList(ComponentTypeEnum.RESOURCE.getValue(), "tag");*/ break; case "tags_to_long": defaultResource.setTags(asList("asdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdffasdff")); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT.name()); - variables = asList("1024"); + /*variables = asList("1024");*/ break; case "tags_invalid": defaultResource.setTags(asList("asfdg")); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME.name()); - variables = asList(ComponentTypeEnum.RESOURCE.getValue()); + /*variables = asList(ComponentTypeEnum.RESOURCE.getValue());*/ break; case "icon_missing": defaultResource.setIcon(""); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_MISSING_ICON.name()); - variables = asList(ComponentTypeEnum.RESOURCE.getValue()); + /*variables = asList(ComponentTypeEnum.RESOURCE.getValue());*/ break; case "user_contact_missing": defaultResource.setContactId(""); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_MISSING_CONTACT.name()); - variables = asList(ComponentTypeEnum.RESOURCE.getValue()); + /*variables = asList(ComponentTypeEnum.RESOURCE.getValue());*/ break; case "user_contact_invalid": default: defaultResource.setContactId("abcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfdabcderfffdfdfd"); errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_INVALID_CONTACT.name()); - variables = asList(ComponentTypeEnum.RESOURCE.getValue()); + /*variables = asList(ComponentTypeEnum.RESOURCE.getValue());*/ break; } // create vfcmt RestResponse restResponse = ResourceRestUtilsExternalAPI.createResource(defaultResource, defaultUser); + assertTrue(errorInfo.getCode().equals(restResponse.getErrorCode()), "Expected response code on [" + flow + "] is: " + errorInfo.getCode() + ", actual is: " + restResponse.getErrorCode()); - expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString()); + /*expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString()); expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables)); - AuditValidationUtils.validateAuditExternalCreateResource(expectedResourceAuditJavaObject, action.getName(), body); + AuditValidationUtils.validateAuditExternalCreateResource(expectedResourceAuditJavaObject, action.getName(), body);*/ } diff --git a/test-apis-ci/src/main/resources/ci/conf/attsdc.yaml b/test-apis-ci/src/main/resources/ci/conf/attsdc.yaml index 904b3d1327..5ee9d0590e 100644 --- a/test-apis-ci/src/main/resources/ci/conf/attsdc.yaml +++ b/test-apis-ci/src/main/resources/ci/conf/attsdc.yaml @@ -42,6 +42,8 @@ cassandraAuditKeySpace: sdcaudit cassandraArtifactKeySpace: sdcartifact url: http://localhost:8181/sdc1/proxy-designer1#/dashboard +sdcHttpMethod: https +localDataCenter: DC-Automate01 stopOnClassFailure: false diff --git a/test-apis-ci/src/main/resources/ci/scripts/addUsersFromList_new.sh b/test-apis-ci/src/main/resources/ci/scripts/addUsersFromList_new.sh index 1b6f0258d6..e695db26b2 100644 --- a/test-apis-ci/src/main/resources/ci/scripts/addUsersFromList_new.sh +++ b/test-apis-ci/src/main/resources/ci/scripts/addUsersFromList_new.sh @@ -46,12 +46,12 @@ function addUser () firstName=`echo $user|awk '{print $3}'` lastName=`echo $user|awk '{print $4}'` email=`echo $user|awk '{print $5}'` - curl --noproxy '*' -i -X post -d '{ "userId" : "'${userId}'", "role" : "'${role}'", "firstName" : "'${firstName}'", "lastName" : "'${lastName}'", "email" : "'${email}'" }' -H "Content-Type: application/json" -H "USER_ID: jh0003" http://${IP}:8080/sdc2/rest/v1/user + curl --noproxy '*' -i -X post -d '{ "userId" : "'${userId}'", "role" : "'${role}'", "firstName" : "'${firstName}'", "lastName" : "'${lastName}'", "email" : "'${email}'" }' -H "Content-Type: application/json" -H "USER_ID: jh0003" https://${IP}:8443/sdc2/rest/v1/user else echo "Host" $IP "Is Unreachable" fi done -curl --noproxy '*' -i -X post -d '{"consumerName": "ci","consumerSalt": "2a1f887d607d4515d4066fe0f5452a50","consumerPassword": "0a0dc557c3bf594b1a48030e3e99227580168b21f44e285c69740b8d5b13e33b"}' -H "Content-Type: application/json" -H "USER_ID: jh0003" -H "Authorization:Basic Y2k6MTIzNDU2" http://${IP}:8080/sdc2/rest/v1/consumers +curl --noproxy '*' -i -X post -d '{"consumerName": "ci","consumerSalt": "2a1f887d607d4515d4066fe0f5452a50","consumerPassword": "0a0dc557c3bf594b1a48030e3e99227580168b21f44e285c69740b8d5b13e33b"}' -H "Content-Type: application/json" -H "USER_ID: jh0003" -H "Authorization:Basic Y2k6MTIzNDU2" https://${IP}:8443/sdc2/rest/v1/consumers } diff --git a/test-apis-ci/src/main/resources/ci/scripts/sendMail.sh b/test-apis-ci/src/main/resources/ci/scripts/sendMail.sh index 4c23a7973e..d2b142a20c 100644 --- a/test-apis-ci/src/main/resources/ci/scripts/sendMail.sh +++ b/test-apis-ci/src/main/resources/ci/scripts/sendMail.sh @@ -6,9 +6,9 @@ REPORT_NAME=$1 VERSION=$2 ENV=$3 -RECIPIENTS1="dl-sdcqa@intl.att.com,ml636r@intl.att.com,bl5783intl.att.com,ak314p@intl.att.com,el489u@intl.att.com,hk096q@intl.att.com,bs5719@intl.att.com" -RECIPIENTS2="dl-asdcqa@intl.att.com" - +RECIPIENTS1="dl-sdcqa@att.com,ml636r@att.com,bl5783@att.com,ak314p@att.com,el489u@att.com,hk096q@att.com,bs5719@att.com" +#RECIPIENTS2="dl-asdcqa@intl.att.com" +RECIPIENTS2="md9897@att.com,ms656r@att.com,al714h@att.com,ak991p@att.com,ya107f@att.com,bv095y@att.com,st198j@att.com,th0695@att.com,vk195d@att.com,gg980r@att.com,il0695@att.com,el489u@att.com" source ExtentReport/versions.info if [ -z "$REPORT_NAME" ] then diff --git a/test-apis-ci/src/main/resources/ci/scripts/startTest.sh b/test-apis-ci/src/main/resources/ci/scripts/startTest.sh index 764e046653..88c9521ac4 100644 --- a/test-apis-ci/src/main/resources/ci/scripts/startTest.sh +++ b/test-apis-ci/src/main/resources/ci/scripts/startTest.sh @@ -91,7 +91,7 @@ ADD_USERS_SCRIPT="addUsersFromList_new.sh" USER_LIST="conf/userList.txt" chmod +x ${ADD_USERS_SCRIPT} echo "add users..." -`./${ADD_USERS_SCRIPT} -ip ${BE_IP} -f ${USER_LIST}` +./${ADD_USERS_SCRIPT} -ip ${BE_IP} -f ${USER_LIST} @@ -137,7 +137,7 @@ fi COPY_REPORT_SCRIPT="copyToStorage.sh" chmod +x ${COPY_REPORT_SCRIPT} echo "copy report to storage..." -sh ./${COPY_REPORT_SCRIPT} ${REPORT_NAME} ${VERSION} ${MYENV} +( ./${COPY_REPORT_SCRIPT} ${REPORT_NAME} ${VERSION} ${MYENV} ) MAILING_SCRIPT_NAME="sendMail.sh" diff --git a/test-apis-ci/src/main/resources/ci/testSuites/ExternalApiSanity.xml b/test-apis-ci/src/main/resources/ci/testSuites/ExternalApiSanity.xml new file mode 100644 index 0000000000..02594526cb --- /dev/null +++ b/test-apis-ci/src/main/resources/ci/testSuites/ExternalApiSanity.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test-apis-ci/src/main/resources/ci/testSuites/externalAPIs.xml b/test-apis-ci/src/main/resources/ci/testSuites/externalAPIs.xml index d32839bdb7..6440dc147b 100644 --- a/test-apis-ci/src/main/resources/ci/testSuites/externalAPIs.xml +++ b/test-apis-ci/src/main/resources/ci/testSuites/externalAPIs.xml @@ -1,6 +1,6 @@ - + diff --git a/test-apis-ci/src/main/resources/ci/testSuites/onap.xml b/test-apis-ci/src/main/resources/ci/testSuites/onap.xml index 4aad3681c9..707500a54c 100644 --- a/test-apis-ci/src/main/resources/ci/testSuites/onap.xml +++ b/test-apis-ci/src/main/resources/ci/testSuites/onap.xml @@ -7,17 +7,6 @@ - - - - \ No newline at end of file diff --git a/test-apis-ci/src/test/java/org/openecomp/sdc/conf/TestAPIConfDependentTest.java b/test-apis-ci/src/test/java/org/openecomp/sdc/conf/TestAPIConfDependentTest.java new file mode 100644 index 0000000000..99b6888211 --- /dev/null +++ b/test-apis-ci/src/test/java/org/openecomp/sdc/conf/TestAPIConfDependentTest.java @@ -0,0 +1,13 @@ +package org.openecomp.sdc.conf; + +import org.junit.BeforeClass; +import org.openecomp.sdc.common.test.BaseConfDependent; + +public class TestAPIConfDependentTest extends BaseConfDependent{ + @BeforeClass + public static void setupBeforeClass() { + componentName = "test-apis-ci"; + confPath = "src/test/resources/config"; + setUp(); + } +} diff --git a/test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/runners/RunTenantIsolationCucumberCI.java b/test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/runners/RunTenantIsolationCucumberCI.java new file mode 100644 index 0000000000..d9183fc5c4 --- /dev/null +++ b/test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/runners/RunTenantIsolationCucumberCI.java @@ -0,0 +1,31 @@ +package org.openecomp.sdc.cucumber.runners; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.runner.RunWith; +import org.openecomp.sdc.conf.TestAPIConfDependentTest; + +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; + +@RunWith(Cucumber.class) +@CucumberOptions(features = "classpath:cucumber/tenantIsolation.feature", glue = "org.openecomp.sdc.cucumber.steps") + +public class RunTenantIsolationCucumberCI extends TestAPIConfDependentTest { + + @BeforeClass + public static void beforeClass() { + } + + @AfterClass + public static void afterClassJUnit() { + } + + @org.testng.annotations.BeforeClass + public static void beforeClassTestNg() { + } + + @org.testng.annotations.AfterClass + public static void afterClassTestNG() { + } +} \ No newline at end of file diff --git a/test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/spring/ImportTableConfig.java b/test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/spring/ImportTableConfig.java new file mode 100644 index 0000000000..f0c7610513 --- /dev/null +++ b/test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/spring/ImportTableConfig.java @@ -0,0 +1,19 @@ +package org.openecomp.sdc.cucumber.spring; + +import org.openecomp.sdc.be.dao.cassandra.CassandraClient; +import org.openecomp.sdc.be.dao.cassandra.OperationalEnvironmentDao; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class ImportTableConfig { + @Bean(name = "cassandra-client") + public CassandraClient cassandraClient() { + return new CassandraClient(); + } + + @Bean(name = "operational-environment-dao") + public OperationalEnvironmentDao operationalEnvironmentDao() { + return new OperationalEnvironmentDao(); + } +} diff --git a/test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/steps/PrecannedTestExpectationCallback.java b/test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/steps/PrecannedTestExpectationCallback.java new file mode 100644 index 0000000000..56802ec7d4 --- /dev/null +++ b/test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/steps/PrecannedTestExpectationCallback.java @@ -0,0 +1,31 @@ +package org.openecomp.sdc.cucumber.steps; + +import static org.mockserver.model.HttpResponse.response; + +import org.apache.http.entity.ContentType; +import org.mockserver.mock.action.ExpectationCallback; +import org.mockserver.model.Header; +import org.mockserver.model.HttpRequest; +import org.mockserver.model.HttpResponse; + +import com.google.common.net.HttpHeaders; + +public class PrecannedTestExpectationCallback implements ExpectationCallback { + private static volatile int countRequests; + + static HttpResponse httpResponse = response() + .withStatusCode(200) + .withHeaders(new Header(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType())); + + @Override + public HttpResponse handle(HttpRequest httpRequest) { + countRequests++; + + System.out.println( + String.format("MSO Server Simulator Recieved %s Final Distribution Complete Rest Reports From ASDC", + countRequests)); + + return httpResponse; + } + +} \ No newline at end of file diff --git a/test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/steps/StepsTenantIsolationCI.java b/test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/steps/StepsTenantIsolationCI.java new file mode 100644 index 0000000000..490b3e0c84 --- /dev/null +++ b/test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/steps/StepsTenantIsolationCI.java @@ -0,0 +1,597 @@ +package org.openecomp.sdc.cucumber.steps; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.mockserver.model.HttpCallback.callback; +import static org.mockserver.model.HttpRequest.request; +import static org.mockserver.model.HttpResponse.response; +import static org.openecomp.sdc.common.datastructure.FunctionalInterfaces.retryMethodOnResult; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.UUID; +import java.util.function.Function; +import java.util.stream.Collectors; + +import org.apache.commons.collections.CollectionUtils; +//import org.openecomp.sdc.dmaap.DmaapPublisher; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpStatus; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.mockserver.integration.ClientAndServer; +import org.mockserver.model.Header; +import org.mockserver.model.HttpRequest; +import org.openecomp.sdc.api.IDistributionClient; +import org.openecomp.sdc.api.consumer.IConfiguration; +import org.openecomp.sdc.api.consumer.IFinalDistrStatusMessage; +import org.openecomp.sdc.api.consumer.INotificationCallback; +import org.openecomp.sdc.api.notification.IArtifactInfo; +import org.openecomp.sdc.api.notification.INotificationData; +import org.openecomp.sdc.api.results.IDistributionClientDownloadResult; +import org.openecomp.sdc.api.results.IDistributionClientResult; +import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; +import org.openecomp.sdc.be.dao.cassandra.OperationalEnvironmentDao; +import org.openecomp.sdc.be.datatypes.enums.EnvironmentStatusEnum; +import org.openecomp.sdc.be.resources.data.OperationalEnvironmentEntry; +import org.openecomp.sdc.common.datastructure.FunctionalInterfaces; +import org.openecomp.sdc.common.datastructure.Wrapper; +import org.openecomp.sdc.cucumber.spring.ImportTableConfig; +import org.openecomp.sdc.http.HttpAsdcClient; +import org.openecomp.sdc.http.HttpAsdcResponse; +import org.openecomp.sdc.http.IHttpAsdcClient; +import org.openecomp.sdc.impl.DistributionClientFactory; +import org.openecomp.sdc.utils.ArtifactTypeEnum; +import org.openecomp.sdc.utils.DistributionActionResultEnum; +import org.openecomp.sdc.utils.DistributionStatusEnum; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; + +import com.google.common.base.Strings; +import com.google.common.net.HttpHeaders; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; + +import cucumber.api.java.After; +import cucumber.api.java.Before; +import cucumber.api.java.en.Given; +import cucumber.api.java.en.Then; +import cucumber.api.java.en.When; +import fj.data.Either; + +public class StepsTenantIsolationCI { + + private Map recordMap = new HashMap<>(); + private OperationalEnvironmentDao operationalEnvironmentDao; + private ClientAndServer aaiMockServer; + private ClientAndServer msoMockServer; + private List distributionClients = new ArrayList<>(); + + private List wdFinalStatusSent = new ArrayList<>(); + + private HttpRequest msoHttpRequest; + private List uuidServicesList; + private boolean cleanFlag = true; + private int maxStepWaitTimeMs; + + private List envIds = new ArrayList<>(); + private List envList = new ArrayList<>(); + private String asdcAddress; + private volatile int numberOfFinalDistributionsSentByASDC; + private int numOfArtifactsToDownload; + private volatile int totalNumOfArtifactsToDownload; + private List envNames = new ArrayList<>(Arrays.asList("Apple", "Orange", "Grape", "Pear", "Watermelon", "Bannana", "Cherry", "Coconut", "Fig", "Mango", "Peach", "Pineapple", "Plum", "Strawberries", "Apricot")); + + private static final String AAI_RESPONSE_BODY_FMT = "{\"operational-environment-id\":\"UUID of Operational Environment\"," + + "\"operational-environment-name\":\"Op Env Name\"," + "\"operational-environment-type\":\"ECOMP\"," + + "\"operational-environment-status\":\"Activate\"," + "\"tenant-context\":\"%s\"," + + "\"workload-context\":\"%s\"," + "\"resource-version\":\"1505228226913\"," + "\"relationship-list\":{}}"; + + private static final String AAI_PATH_REGEX = "/aai/v12/cloud-infrastructure/operational-environments/.*"; + + private static final String MSO_PATH_REGEX = "/onap/mso/infra/modelDistributions/v1/distributions/.*"; + + @Before + public void beforeScenario() { + Collections.shuffle(envNames); + aaiMockServer = ClientAndServer.startClientAndServer(1111); + msoMockServer = ClientAndServer.startClientAndServer(1112); + + this.operationalEnvironmentDao = createDaoObj(); + } + + @After + public void afterScenario() { + System.out.println("Cleaning Up After Scenario..."); + aaiMockServer.stop(); + msoMockServer.stop(); + if (cleanFlag) { + envIds.stream().forEach(operationalEnvironmentDao::delete); + } + distributionClients.stream().forEach(IDistributionClient::stop); + System.out.println("Cleaning Up After Scenario Done"); + } + + // ############################# Given - Start ############################# + + @Given("^clean db after test is (.*)$") + public void clean_db_after_test_is(boolean cleanFlag) { + this.cleanFlag = cleanFlag; + } + + @Given("^AAI returns (.*) and aai_body contains (.*) and (.*)$") + public void aai_returns(int retCode, String tenant, String workload) throws Throwable { + String aaiResponseBody = String.format(AAI_RESPONSE_BODY_FMT, tenant, workload); + + setAaiMockServer(aaiResponseBody); + + System.out.println(aaiMockServer.getClass()); + } + + @Given("^MSO-WD Simulators Started with topic name (.*)$") + public void notification_listner_simulators_started(String topicName) throws Throwable { + envList.forEach(env -> { + final IDistributionClient distClientSim = simulateDistributionClientWD(topicName, env); + distributionClients.add(distClientSim); + }); + + } + + @Given("^MSO Final Distribution Simulator is UP$") + public void mso_Final_Distribution_Simulator_is_UP() throws Throwable { + msoHttpRequest = request().withPath(MSO_PATH_REGEX); + msoMockServer.when(msoHttpRequest).callback( + callback().withCallbackClass("org.openecomp.sdc.cucumber.steps.PrecannedTestExpectationCallback")); + } + + @Given("^ASDC Address is (.*)$") + public void asdc_Address_is(String asdcAddress) throws Throwable { + this.asdcAddress = asdcAddress; + + } + + @Given("^ASDC Contains the following services (.*)$") + public void asdc_Contains_the_following_services(String listOfServicesUUID) throws Throwable { + uuidServicesList = Arrays.asList(listOfServicesUUID.split(",")).stream().map(String::trim) + .collect(Collectors.toList()); + + int maxMinWait = uuidServicesList.size() * envIds.size(); + this.maxStepWaitTimeMs = 60000 * maxMinWait; + System.out.println(String.format("Set Max Step Wait Time To: %s Minutes", maxMinWait)); + } + + @Given("^The number of complete environments is (.*)$") + public void the_number_of_complete_environments_is(int envNum) throws Throwable { + + int counter = 1; + while( envNum > envNames.size()){ + envNames.add(String.valueOf(counter)); + counter++; + } + + + for (int i = 0; i < envNum; i++) { + OperationalEnvironmentEntry preSaveEntry = new OperationalEnvironmentEntry(); + + preSaveEntry.setStatus(EnvironmentStatusEnum.COMPLETED); + preSaveEntry.setLastModified(new Date(System.currentTimeMillis())); + + Set uebAdresses = new HashSet<>(); + uebAdresses.add("uebsb92sfdc.it.att.com"); + preSaveEntry.setDmaapUebAddress(uebAdresses); + preSaveEntry.setIsProduction(false); + preSaveEntry.setUebApikey("sSJc5qiBnKy2qrlc"); + preSaveEntry.setUebSecretKey("4ZRPzNJfEUK0sSNBvccd2m7X"); + preSaveEntry.setTenant("TEST"); + preSaveEntry.setEcompWorkloadContext("ECOMP_E2E-IST"); + + // String envId = UUID.randomUUID().toString(); + String envId = envNames.get(i); + preSaveEntry.setEnvironmentId(envId); + envIds.add(envId); + envList.add(preSaveEntry); + operationalEnvironmentDao.save(preSaveEntry); + } + } + + @Given("^The number of artifacts each Simulator downloads from a service is (.*)$") + public void number_of_artifacts_each_simulator_downloads(int numOfArtifactsToDownload) throws Throwable { + this.numOfArtifactsToDownload = numOfArtifactsToDownload; + } + + // ############################# Given - End ############################# + + // ############################# When - Start ############################# + @When("^Distribution Requests are Sent By MSO$") + public void distribution_Requests_are_Sent_By_MSO() throws Throwable { + envList.stream().forEach(this::distributeServiceInEnv); + + } + + @When("^The Number Of Operational Envrinoments that created is (.*) and Records are added with data (.*)$") + public void operational_envrinoments_records_are_added_with_data(int numOfRecords, String recordData) + throws Throwable { + for (int i = 0; i < numOfRecords; i++) { + OperationalEnvironmentEntry preSaveEntry = new OperationalEnvironmentEntry(); + JsonElement root = new JsonParser().parse(recordData); + + String originalStatus = root.getAsJsonObject().get("status").getAsString(); + int delta = root.getAsJsonObject().get("last_modified_delta").getAsInt(); + preSaveEntry.setStatus(EnvironmentStatusEnum.getByName(originalStatus)); + long last_modified = System.currentTimeMillis() + delta * 1000; + preSaveEntry.setLastModified(new Date(last_modified)); + String envId = UUID.randomUUID().toString(); + preSaveEntry.setEnvironmentId(envId); + envIds.add(envId); + // envrionmentIds.add(envId); + operationalEnvironmentDao.save(preSaveEntry); + + } + + } + + // ############################# When - End ############################# + + // ############################# Then - Start ############################# + @Then("^Operational Environment record contains tenant field (.*$)") + public void operational_environment_record_contains_tenant(boolean tenantExist) throws Throwable { + envIds.forEach(envId -> { + validateStringFieldPresent(tenantExist, OperationalEnvironmentEntry::getTenant, envId, + "Tenant is not as expected"); + }); + } + + @Then("^Operational Environment record contains workload field (.*$)") + public void operational_environment_record_contains_workload(boolean workloadExist) throws Throwable { + envIds.forEach(envId -> { + validateStringFieldPresent(workloadExist, OperationalEnvironmentEntry::getEcompWorkloadContext, envId, + "Workload is not as expected"); + }); + } + + @Then("^Operational Environment record contains UEB Address field (.*$)") + public void operational_environment_record_contains_ueb_address(boolean uebAddresExist) throws Throwable { + envIds.forEach(envId -> { + validateStringFieldPresent(uebAddresExist, this::convertUebAddressToList, envId, + "UEB Address is not as expected"); + }); + } + + @Then("^The Number Of Environment is (.*) with status (.*)$") + public void the_Number_Of_Environment_Created_is(int numberOfEnvsCreated, String status) throws Throwable { + // Write code here that turns the phrase above into concrete actions + + retryMethodOnResult(() -> getCurrentEnvironmets(status), envList -> envList.size() == numberOfEnvsCreated, + 40000, 500); + + List environmentsFound = getCurrentEnvironmets(status); + + assertThat(environmentsFound.size(), is(numberOfEnvsCreated)); + + environmentsFound.forEach(env -> recordMap.put(env.getEnvironmentId(), env)); + envList.addAll(environmentsFound); + } + + @Then("^MSO Final Distribution Recieved Correct Number Of Request$") + public void mso_final_distribution_recieved_request() throws Throwable { + int expectedNumberOfRequestsSentByASDC = calculateExcpectedNumberOfDistributionRequets(); + Function resultVerifier = actualStatusList -> actualStatusList >= expectedNumberOfRequestsSentByASDC; + retryMethodOnResult(() -> numberOfFinalDistributionsSentByASDC(expectedNumberOfRequestsSentByASDC), + resultVerifier, maxStepWaitTimeMs, 500); + int actualNumberOfRequestsSentByASDC = numberOfFinalDistributionsSentByASDC(expectedNumberOfRequestsSentByASDC); + assertThat(actualNumberOfRequestsSentByASDC, is(expectedNumberOfRequestsSentByASDC)); + } + + @Then("^All MSO-WD Simulators Sent The Distribution Complete Notifications$") + public void all_mso_wd_simulators_sent_the_distribution_complete_notifications() { + // Wait Watch Dogs To Send Final Distribution + int excpectedNumberOfDistributionCompleteNotifications = calculateExcpectedNumberOfDistributionRequets(); + final Function, Boolean> resultVerifier = actualStatusList -> actualStatusList + .size() == excpectedNumberOfDistributionCompleteNotifications; + retryMethodOnResult(() -> wdFinalStatusSent, resultVerifier, maxStepWaitTimeMs, 500); + assertThat(wdFinalStatusSent.size(), is(excpectedNumberOfDistributionCompleteNotifications)); + } + @Then("^All Artifacts were downloaded by Simulators$") + public void all_artifacts_downloaded() { + // Wait Watch Dogs To Send Final Distribution + int excpectedNumberOfArtifactsToDownload = numOfArtifactsToDownload * envIds.size() * uuidServicesList.size(); + assertThat(totalNumOfArtifactsToDownload, is(excpectedNumberOfArtifactsToDownload)); + } + // ############################# Then - End ############################# + + private List getCurrentEnvironmets(String status) { + Either, CassandraOperationStatus> eitherStatus = operationalEnvironmentDao + .getByEnvironmentsStatus(EnvironmentStatusEnum.getByName(status)); + assertThat(eitherStatus.isLeft(), is(true)); + + List environmentsRetrieved = eitherStatus.left().value(); + + List environmentsFound = environmentsRetrieved.stream() + .filter(env -> envIds.contains(env.getEnvironmentId())).collect(Collectors.toList()); + return environmentsFound; + } + + private int numberOfFinalDistributionsSentByASDC(int expectedNumberOfRequestsSentByASDC) { + final int newVal = msoMockServer.retrieveRecordedRequests(msoHttpRequest).length; + if (newVal != numberOfFinalDistributionsSentByASDC) { + System.out.println(String.format( + "MSO Server Simulator Recieved %s/%s Final Distribution Complete Rest Reports From ASDC", newVal, + expectedNumberOfRequestsSentByASDC)); + numberOfFinalDistributionsSentByASDC = newVal; + } + + return newVal; + } + + private int calculateExcpectedNumberOfDistributionRequets() { + int numberOfDistributionRequests = envList.size() * uuidServicesList.size(); + return numberOfDistributionRequests; + } + + private static OperationalEnvironmentDao createDaoObj() { + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ImportTableConfig.class); + final OperationalEnvironmentDao openvDao = (OperationalEnvironmentDao) context + .getBean("operational-environment-dao"); + return openvDao; + } + + private OperationalEnvironmentEntry getRecord(String environmentId) { + Either result = operationalEnvironmentDao + .get(environmentId); + return result.isLeft() ? result.left().value() : null; + } + + private void validateStringFieldPresent(boolean fieldExist, + Function getFieldFunc, String envId, String msg) { + OperationalEnvironmentEntry record = recordMap.computeIfAbsent(envId, this::getRecord); + + assertNotNull(record, "Expected DB record was not found"); + + String actualValue = getFieldFunc.apply(record); + + assertEquals(fieldExist, !Strings.isNullOrEmpty(actualValue), msg); + } + + private void setAaiMockServer(String aaiResponseBody) { + HttpRequest httpRequest = request().withMethod("GET").withPath(AAI_PATH_REGEX) + .withHeaders(new Header(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType())); + + aaiMockServer.when(httpRequest) + .respond(response() + .withHeaders(new Header(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType())) + .withBody(aaiResponseBody)); + } + + private IDistributionClient simulateDistributionClientWD(String topicName, OperationalEnvironmentEntry opEnv) { + + IDistributionClient client = DistributionClientFactory.createDistributionClient(); + final IConfiguration buildDistributionClientConfiguration = buildDistributionClientConfiguration(topicName, + opEnv); + IDistributionClientResult initResult = client.init(buildDistributionClientConfiguration, + new INotificationCallback() { + + @Override + public void activateCallback(INotificationData data) { + buildWdSimulatorCallback(opEnv, client, buildDistributionClientConfiguration, data); + + } + + }); + assertThat(initResult.getDistributionActionResult(), is(DistributionActionResultEnum.SUCCESS)); + IDistributionClientResult startResult = client.start(); + assertThat(startResult.getDistributionActionResult(), is(DistributionActionResultEnum.SUCCESS)); + System.out.println(String.format("WD Simulator On Environment:\"%s\" Started Successfully", + buildDistributionClientConfiguration.getConsumerID())); + return client; + } + + private IFinalDistrStatusMessage buildFinalDistribution() { + return new IFinalDistrStatusMessage() { + + @Override + public long getTimestamp() { + return System.currentTimeMillis(); + } + + @Override + public DistributionStatusEnum getStatus() { + return DistributionStatusEnum.DISTRIBUTION_COMPLETE_OK; + } + + @Override + public String getDistributionID() { + return "FakeDistributionId"; + } + }; + } + + private IConfiguration buildDistributionClientConfiguration(String topicName, OperationalEnvironmentEntry opEnv) { + return new IConfiguration() { + + public String getUser() { + return "ci"; + } + + public int getPollingTimeout() { + return 20; + } + + public int getPollingInterval() { + return 20; + } + + public String getPassword() { + return "123456"; + } + + public String getEnvironmentName() { + return topicName; + } + + public String getConsumerID() { + return opEnv.getEnvironmentId(); + } + + public String getConsumerGroup() { + return String.format("BenchMarkDistributionClientConsumerGroup%s", opEnv.getEnvironmentId()); + } + + public String getAsdcAddress() { + return String.format("%s:8443", asdcAddress); + } + + @Override + public String getKeyStorePath() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getKeyStorePassword() { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean activateServerTLSAuth() { + // TODO Auto-generated method stub + return false; + } + + @Override + public List getRelevantArtifactTypes() { + return Arrays.asList(ArtifactTypeEnum.values()).stream() + .map(artifactTypeEnum -> artifactTypeEnum.name()).collect(Collectors.toList()); + } + + @Override + public boolean isFilterInEmptyResources() { + // TODO Auto-generated method stub + return false; + } + + @Override + public Boolean isUseHttpsWithDmaap() { + return null; + } + + @Override + public List getMsgBusAddress() { + return opEnv.getDmaapUebAddress().stream().map(this::extractHost).collect(Collectors.toList()); + } + + private String extractHost(String url) { + return url.split(":")[0]; + } + }; + } + + private void distributeServiceInEnv(OperationalEnvironmentEntry env) { + uuidServicesList.stream().forEach(serviceUUID -> distributeSingleService(env, serviceUUID)); + } + + private void distributeSingleService(OperationalEnvironmentEntry env, String serviceUUID) { + IHttpAsdcClient client = new HttpAsdcClient(buildDistributionClientConfiguration(StringUtils.EMPTY, env)); + String pattern = "/sdc/v1/catalog/services/%s/distribution/%s/activate"; + String requestUrl = String.format(pattern, serviceUUID, env.getEnvironmentId()); + String requestBody = String.format("{\"workloadContext\":\"%s\"}", env.getEnvironmentId()); + StringEntity body = new StringEntity(requestBody, ContentType.APPLICATION_JSON); + Map headersMap = new HashMap<>(); + headersMap.put("USER_ID", "cs0008"); + headersMap.put("X-ECOMP-InstanceID", "test"); + headersMap.put("Content-Type", "application/json"); + + HttpAsdcResponse postRequest = FunctionalInterfaces.retryMethodOnResult( + () -> distributeMethod(client, requestUrl, serviceUUID, body, headersMap, env.getEnvironmentId()), + resp -> resp.getStatus() == HttpStatus.SC_ACCEPTED); + assertThat(postRequest.getStatus(), is(HttpStatus.SC_ACCEPTED)); + + } + + private HttpAsdcResponse distributeMethod(IHttpAsdcClient client, String requestUrl, String serviceUUID, + StringEntity body, Map headersMap, String envId) { + + final HttpAsdcResponse postRequest = client.postRequest(requestUrl, body, headersMap); + final String message = String.format( + "MSO Client Simulator Distributes Service:%s On Environment:\"%s\" - Recieved Response: %s", serviceUUID, envId, + postRequest.getStatus()); + if (postRequest.getStatus() != HttpStatus.SC_ACCEPTED) { + System.err.println(message); + } else { + System.out.println(message); + } + + return postRequest; + } + + private String convertUebAddressToList(OperationalEnvironmentEntry op) { + Set dmaapUebAddress = op.getDmaapUebAddress(); + Wrapper resultWrapper = new Wrapper<>(StringUtils.EMPTY); + if (!CollectionUtils.isEmpty(dmaapUebAddress)) { + dmaapUebAddress.stream() + .forEach(uebAddress -> resultWrapper.setInnerElement(resultWrapper.getInnerElement() + uebAddress)); + } + + return resultWrapper.getInnerElement(); + } + + private void buildWdSimulatorCallback(OperationalEnvironmentEntry opEnv, IDistributionClient client, + final IConfiguration buildDistributionClientConfiguration, INotificationData data) { + if (StringUtils.equals(data.getWorkloadContext(), opEnv.getEnvironmentId())) { + + final String expectedArtifactType = org.openecomp.sdc.common.api.ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.name(); + Optional optional = data.getServiceArtifacts().stream().filter( artifact -> { + return StringUtils.equals(artifact.getArtifactType(), expectedArtifactType); + }).findAny(); + + for (int i = 0; i < numOfArtifactsToDownload; i++) { + optional.ifPresent( artifactInfo -> simulateDownload(client , artifactInfo, data) ); + optional.orElseThrow( () -> handleArtifactNotFound(expectedArtifactType, data)); + + } + if( numOfArtifactsToDownload > 0 ){ + System.out.println(String.format( + "ASDC Consumer Simulator On Environment:\"%s\" Downloaded %s Artifacts From ASDC Service with UUID:%s Total Artifacts Downloaded from ASDC is: %s", + data.getWorkloadContext(), numOfArtifactsToDownload, + data.getServiceUUID(), totalNumOfArtifactsToDownload)); + } + + IDistributionClientResult finalDistrStatus = client.sendFinalDistrStatus(buildFinalDistribution()); + assertThat(finalDistrStatus.getDistributionActionResult(), is(DistributionActionResultEnum.SUCCESS)); + wdFinalStatusSent.add(data.getWorkloadContext()); + + System.out.println(String.format( + "WD Simulator On Environment:\"%s\" Recieved Notification From ASDC On WorkLoad: %s And Service UUID:%s And Sends Distribution Complete Notification", + buildDistributionClientConfiguration.getConsumerID(), data.getWorkloadContext(), + data.getServiceUUID())); + } + } + + private IllegalStateException handleArtifactNotFound(String expectedArtifactType, INotificationData data ){ + final String stringMessage = String.format("Did Not Find Artifact of type: %s to download from service with UUID:%s", expectedArtifactType, data.getServiceUUID()); + System.err.println(stringMessage); + return new IllegalStateException(stringMessage); + + } + + private void simulateDownload(IDistributionClient client, IArtifactInfo info, INotificationData data){ + IDistributionClientDownloadResult downloadResult = client.download(info); + if( downloadResult.getDistributionActionResult() != DistributionActionResultEnum.SUCCESS ){ + System.err.println(String.format("Client Simulator %s Failed to download artifact from service : %s", client.getConfiguration().getConsumerID(), data.getServiceUUID())); + assertThat(downloadResult.getDistributionActionResult(), is(DistributionActionResultEnum.SUCCESS)); + } + else{ + totalNumOfArtifactsToDownload++; + + } + } +} diff --git a/test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/utils/RunnerSession.java b/test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/utils/RunnerSession.java new file mode 100644 index 0000000000..c93b3d2f0c --- /dev/null +++ b/test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/utils/RunnerSession.java @@ -0,0 +1,61 @@ +package org.openecomp.sdc.cucumber.utils; + +import java.util.HashMap; +import java.util.Map; + +/** + * Store Data here that is relevant for the whole runner and not just a single scenario. + * @author ms172g + * + */ +public class RunnerSession { + private static final RunnerSession instance = new RunnerSession(); + private Map stringElements; + private Map intElements; + private Map elements; + private RunnerSession(){ + stringElements = new HashMap<>(); + intElements = new HashMap<>(); + elements = new HashMap<>(); + } + public static RunnerSession getSession(){ + return instance; + } + + public void putInSession(String key, String value){ + stringElements.put(key, value); + } + + public String getString(String key){ + return stringElements.get(key); + + } + + public void putInSession(String key, Integer value){ + intElements.put(key, value); + } + + + public Integer getInt(String key){ + return intElements.get(key); + } + + public void putInSession(String key, Object value) { + elements.put(key, value); + + } + + public Object get(String key){ + return elements.get(key); + } + + public void clean(){ + intElements.clear(); + stringElements.clear(); + } + + + + + +} diff --git a/test-apis-ci/src/test/resources/CI/tests/tenantIsolationCI/aai_error.properties b/test-apis-ci/src/test/resources/CI/tests/tenantIsolationCI/aai_error.properties new file mode 100644 index 0000000000..b4ae9e332b --- /dev/null +++ b/test-apis-ci/src/test/resources/CI/tests/tenantIsolationCI/aai_error.properties @@ -0,0 +1,10 @@ +400=Bad Request +401=Unauthorized +403=Forbidden +404=Not Found +405=Method Not Allowed +409=The request could not be completed due to a conflict with the current state of the target resource +410=You are using a version of the API that has been retired +412=Precondition failed +415=Unsupported Media Type +500=Internal Server Error \ No newline at end of file diff --git a/test-apis-ci/src/test/resources/catalogMgmtTest.properties b/test-apis-ci/src/test/resources/catalogMgmtTest.properties new file mode 100644 index 0000000000..7a26a0c905 --- /dev/null +++ b/test-apis-ci/src/test/resources/catalogMgmtTest.properties @@ -0,0 +1,34 @@ +TransportType=DME2 +Latitude =32.109333 +Longitude =34.855499 +Version =1.0 +ServiceName =dmaap-v1.dev.dmaap.dt.saat.acsi.att.com/events +Environment =TEST +Partner=BOT_R +routeOffer=MR1 +SubContextPath =/ +Protocol =http +MethodType =POST +username = m09875@sdc.att.com +password =Aa123456 +contenttype = application/json +Authorization = Basic bTEzMzMxQGNjZC5hdHQuY29tOkFhMTIzNDU2 +authKey= +authDate= +#Dmaap Server Url port 3904-HTTP 3905-https +host=olsd004.wnsnet.attws.com:3904 +###topic=com.att.ccd.CCD-CatalogManagement-go539p or com.att.sdc.SDCforTestDev | com.att.sdc.23911-SDCforTestDev-v001 +topic=com.att.sdc.23911-SDCforTestDev-v001 +partition=1 +maxBatchSize=100 +maxAgeMs=250 +AFT_DME2_EXCHANGE_REQUEST_HANDLERS=com.att.nsa.test.PreferredRouteRequestHandler +AFT_DME2_EXCHANGE_REPLY_HANDLERS=com.att.nsa.test.PreferredRouteReplyHandler +AFT_DME2_REQ_TRACE_ON=true +AFT_ENVIRONMENT=AFTUAT +AFT_DME2_EP_CONN_TIMEOUT=15000 +AFT_DME2_ROUNDTRIP_TIMEOUT_MS=240000 +AFT_DME2_EP_READ_TIMEOUT_MS=50000 +sessionstickinessrequired=NO +DME2preferredRouterFilePath=src/test/resources/preferredRouter.txt +MessageSentThreadOccurance=50 \ No newline at end of file diff --git a/test-apis-ci/src/test/resources/catalogMgmtTest.yaml b/test-apis-ci/src/test/resources/catalogMgmtTest.yaml new file mode 100644 index 0000000000..ee419f4f50 --- /dev/null +++ b/test-apis-ci/src/test/resources/catalogMgmtTest.yaml @@ -0,0 +1,6 @@ +publisherPropertiesFilePath: "catalogMgmtTest.properties" +topicMessages: + - "{\"transactionId\": \"221e8cbe-493d-4848-b46c-a552b8928075\",\"notificationReason\":[\"product\"],\"republish\":\"No\",\"Authorization\": \"Basic bTEzMzMxQGNjZC5hdHQuY29tOkFhMTIzNDU2\"}" + #- "{\"transactionId\": \"221e8cbe-493d-4848-b46c-a552b8928075\",\"notificationReason\":[\"logo\"],\"republish\":\"No\"}" + #- "{\"transactionId\": \"221e8cbe-493d-4848-b46c-a552b8928075\",\"notificationReason\":[\"availabilitymatrix\"],\"republish\":\"No\"}" + #- "{\"transactionId\": \"221e8cbe-493d-4848-b46c-a552b8928075\",\"notificationReason\":[\"product\",\"availabilitymatrix\"],\"republish\":\"No\"}" \ No newline at end of file diff --git a/test-apis-ci/src/test/resources/config/configuration1.yaml b/test-apis-ci/src/test/resources/config/configuration1.yaml new file mode 100644 index 0000000000..12ab2c777f --- /dev/null +++ b/test-apis-ci/src/test/resources/config/configuration1.yaml @@ -0,0 +1,17 @@ +version: 1.0 +released: 2012-11-30 + +# Connection parameters +connection: + url: jdbc:mysql://localhost:3306/db + poolSize: 5 + +# Protocols +protocols: + - http + - https + +# Users +users: + tom: passwd + bob: passwd \ No newline at end of file diff --git a/test-apis-ci/src/test/resources/config/elasticsearch.yml b/test-apis-ci/src/test/resources/config/elasticsearch.yml new file mode 100644 index 0000000000..a6a2c1b950 --- /dev/null +++ b/test-apis-ci/src/test/resources/config/elasticsearch.yml @@ -0,0 +1,387 @@ + +cluster.name: elasticsearch_1_5_2 + +discovery.zen.ping.multicast.enabled: false +discovery.zen.ping.unicast.enabled: true +discovery.zen.ping.unicast.hosts: elasticsearch_host + + + +##################### Elasticsearch Configuration Example ##################### + +# This file contains an overview of various configuration settings, +# targeted at operations staff. Application developers should +# consult the guide at . +# +# The installation procedure is covered at +# . +# +# Elasticsearch comes with reasonable defaults for most settings, +# so you can try it out without bothering with configuration. +# +# Most of the time, these defaults are just fine for running a production +# cluster. If you're fine-tuning your cluster, or wondering about the +# effect of certain configuration option, please _do ask_ on the +# mailing list or IRC channel [http://elasticsearch.org/community]. + +# Any element in the configuration can be replaced with environment variables +# by placing them in ${...} notation. For example: +# +# node.rack: ${RACK_ENV_VAR} + +# For information on supported formats and syntax for the config file, see +# + + +################################### Cluster ################################### + +# Cluster name identifies your cluster for auto-discovery. If you're running +# multiple clusters on the same network, make sure you're using unique names. +# +# cluster.name: elasticsearch + + +#################################### Node ##################################### + +# Node names are generated dynamically on startup, so you're relieved +# from configuring them manually. You can tie this node to a specific name: +# +# node.name: "Franz Kafka" + +# Every node can be configured to allow or deny being eligible as the master, +# and to allow or deny to store the data. +# +# Allow this node to be eligible as a master node (enabled by default): +# +# node.master: true +# +# Allow this node to store data (enabled by default): +# +# node.data: true + +# You can exploit these settings to design advanced cluster topologies. +# +# 1. You want this node to never become a master node, only to hold data. +# This will be the "workhorse" of your cluster. +# +# node.master: false +# node.data: true +# +# 2. You want this node to only serve as a master: to not store any data and +# to have free resources. This will be the "coordinator" of your cluster. +# +# node.master: true +# node.data: false +# +# 3. You want this node to be neither master nor data node, but +# to act as a "search load balancer" (fetching data from nodes, +# aggregating results, etc.) +# +# node.master: false +# node.data: false + +# Use the Cluster Health API [http://localhost:9200/_cluster/health], the +# Node Info API [http://localhost:9200/_nodes] or GUI tools +# such as , +# , +# and +# to inspect the cluster state. + +# A node can have generic attributes associated with it, which can later be used +# for customized shard allocation filtering, or allocation awareness. An attribute +# is a simple key value pair, similar to node.key: value, here is an example: +# +# node.rack: rack314 + +# By default, multiple nodes are allowed to start from the same installation location +# to disable it, set the following: +# node.max_local_storage_nodes: 1 + + +#################################### Index #################################### + +# You can set a number of options (such as shard/replica options, mapping +# or analyzer definitions, translog settings, ...) for indices globally, +# in this file. +# +# Note, that it makes more sense to configure index settings specifically for +# a certain index, either when creating it or by using the index templates API. +# +# See and +# +# for more information. + +# Set the number of shards (splits) of an index (5 by default): +# +# index.number_of_shards: 5 + +# Set the number of replicas (additional copies) of an index (1 by default): +# +# index.number_of_replicas: 1 + +# Note, that for development on a local machine, with small indices, it usually +# makes sense to "disable" the distributed features: +# +index.number_of_shards: 1 +index.number_of_replicas: 0 + +# These settings directly affect the performance of index and search operations +# in your cluster. Assuming you have enough machines to hold shards and +# replicas, the rule of thumb is: +# +# 1. Having more *shards* enhances the _indexing_ performance and allows to +# _distribute_ a big index across machines. +# 2. Having more *replicas* enhances the _search_ performance and improves the +# cluster _availability_. +# +# The "number_of_shards" is a one-time setting for an index. +# +# The "number_of_replicas" can be increased or decreased anytime, +# by using the Index Update Settings API. +# +# Elasticsearch takes care about load balancing, relocating, gathering the +# results from nodes, etc. Experiment with different settings to fine-tune +# your setup. + +# Use the Index Status API () to inspect +# the index status. + + +#################################### Paths #################################### + +# Path to directory containing configuration (this file and logging.yml): +# +path.conf: /src/test/resources + +# Path to directory where to store index data allocated for this node. +# +path.data: target/esdata +# +# Can optionally include more than one location, causing data to be striped across +# the locations (a la RAID 0) on a file level, favouring locations with most free +# space on creation. For example: +# +# path.data: /path/to/data1,/path/to/data2 + +# Path to temporary files: +# +path.work: /target/eswork + +# Path to log files: +# +path.logs: /target/eslogs + +# Path to where plugins are installed: +# +# path.plugins: /path/to/plugins + + +#################################### Plugin ################################### + +# If a plugin listed here is not installed for current node, the node will not start. +# +# plugin.mandatory: mapper-attachments,lang-groovy + + +################################### Memory #################################### + +# Elasticsearch performs poorly when JVM starts swapping: you should ensure that +# it _never_ swaps. +# +# Set this property to true to lock the memory: +# +# bootstrap.mlockall: true + +# Make sure that the ES_MIN_MEM and ES_MAX_MEM environment variables are set +# to the same value, and that the machine has enough memory to allocate +# for Elasticsearch, leaving enough memory for the operating system itself. +# +# You should also make sure that the Elasticsearch process is allowed to lock +# the memory, eg. by using `ulimit -l unlimited`. + + +############################## Network And HTTP ############################### + +# Elasticsearch, by default, binds itself to the 0.0.0.0 address, and listens +# on port [9200-9300] for HTTP traffic and on port [9300-9400] for node-to-node +# communication. (the range means that if the port is busy, it will automatically +# try the next port). + +# Set the bind address specifically (IPv4 or IPv6): +# +# network.bind_host: 192.168.0.1 + +# Set the address other nodes will use to communicate with this node. If not +# set, it is automatically derived. It must point to an actual IP address. +# +# network.publish_host: 192.168.0.1 + +# Set both 'bind_host' and 'publish_host': +# +# network.host: 192.168.0.1 + +# Set a custom port for the node to node communication (9300 by default): +# +# transport.tcp.port: 9300 + +# Enable compression for all communication between nodes (disabled by default): +# +# transport.tcp.compress: true + +# Set a custom port to listen for HTTP traffic: +# +# http.port: 9200 + +# Set a custom allowed content length: +# +# http.max_content_length: 100mb + +# Disable HTTP completely: +# +# http.enabled: false + + +################################### Gateway ################################### + +# The gateway allows for persisting the cluster state between full cluster +# restarts. Every change to the state (such as adding an index) will be stored +# in the gateway, and when the cluster starts up for the first time, +# it will read its state from the gateway. + +# There are several types of gateway implementations. For more information, see +# . + +# The default gateway type is the "local" gateway (recommended): +# +# gateway.type: local + +# Settings below control how and when to start the initial recovery process on +# a full cluster restart (to reuse as much local data as possible when using shared +# gateway). + +# Allow recovery process after N nodes in a cluster are up: +# +gateway.recover_after_nodes: 1 + +# Set the timeout to initiate the recovery process, once the N nodes +# from previous setting are up (accepts time value): +# +# gateway.recover_after_time: 5m + +# Set how many nodes are expected in this cluster. Once these N nodes +# are up (and recover_after_nodes is met), begin recovery process immediately +# (without waiting for recover_after_time to expire): +# +gateway.expected_nodes: 1 + + +############################# Recovery Throttling ############################# + +# These settings allow to control the process of shards allocation between +# nodes during initial recovery, replica allocation, rebalancing, +# or when adding and removing nodes. + +# Set the number of concurrent recoveries happening on a node: +# +# 1. During the initial recovery +# +# cluster.routing.allocation.node_initial_primaries_recoveries: 4 +# +# 2. During adding/removing nodes, rebalancing, etc +# +# cluster.routing.allocation.node_concurrent_recoveries: 2 + +# Set to throttle throughput when recovering (eg. 100mb, by default 20mb): +# +# indices.recovery.max_bytes_per_sec: 20mb + +# Set to limit the number of open concurrent streams when +# recovering a shard from a peer: +# +# indices.recovery.concurrent_streams: 5 + + +################################## Discovery ################################## + +# Discovery infrastructure ensures nodes can be found within a cluster +# and master node is elected. Multicast discovery is the default. + +# Set to ensure a node sees N other master eligible nodes to be considered +# operational within the cluster. Its recommended to set it to a higher value +# than 1 when running more than 2 nodes in the cluster. +# +# discovery.zen.minimum_master_nodes: 1 + +# Set the time to wait for ping responses from other nodes when discovering. +# Set this option to a higher value on a slow or congested network +# to minimize discovery failures: +# +# discovery.zen.ping.timeout: 3s + +# For more information, see +# + +# Unicast discovery allows to explicitly control which nodes will be used +# to discover the cluster. It can be used when multicast is not present, +# or to restrict the cluster communication-wise. +# +# 1. Disable multicast discovery (enabled by default): +# +# discovery.zen.ping.multicast.enabled: false +# +# 2. Configure an initial list of master nodes in the cluster +# to perform discovery when new nodes (master or data) are started: +# +# discovery.zen.ping.unicast.hosts: ["host1", "host2:port"] + +# EC2 discovery allows to use AWS EC2 API in order to perform discovery. +# +# You have to install the cloud-aws plugin for enabling the EC2 discovery. +# +# For more information, see +# +# +# See +# for a step-by-step tutorial. + +# GCE discovery allows to use Google Compute Engine API in order to perform discovery. +# +# You have to install the cloud-gce plugin for enabling the GCE discovery. +# +# For more information, see . + +# Azure discovery allows to use Azure API in order to perform discovery. +# +# You have to install the cloud-azure plugin for enabling the Azure discovery. +# +# For more information, see . + +################################## Slow Log ################################## + +# Shard level query and fetch threshold logging. + +#index.search.slowlog.threshold.query.warn: 10s +#index.search.slowlog.threshold.query.info: 5s +#index.search.slowlog.threshold.query.debug: 2s +#index.search.slowlog.threshold.query.trace: 500ms + +#index.search.slowlog.threshold.fetch.warn: 1s +#index.search.slowlog.threshold.fetch.info: 800ms +#index.search.slowlog.threshold.fetch.debug: 500ms +#index.search.slowlog.threshold.fetch.trace: 200ms + +#index.indexing.slowlog.threshold.index.warn: 10s +#index.indexing.slowlog.threshold.index.info: 5s +#index.indexing.slowlog.threshold.index.debug: 2s +#index.indexing.slowlog.threshold.index.trace: 500ms + +################################## GC Logging ################################ + +#monitor.jvm.gc.young.warn: 1000ms +#monitor.jvm.gc.young.info: 700ms +#monitor.jvm.gc.young.debug: 400ms + +#monitor.jvm.gc.old.warn: 10s +#monitor.jvm.gc.old.info: 5s +#monitor.jvm.gc.old.debug: 2s + diff --git a/test-apis-ci/src/test/resources/config/test-apis-ci/DME2preferredRouter.txt b/test-apis-ci/src/test/resources/config/test-apis-ci/DME2preferredRouter.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test-apis-ci/src/test/resources/config/test-apis-ci/configuration.yaml b/test-apis-ci/src/test/resources/config/test-apis-ci/configuration.yaml new file mode 100644 index 0000000000..f138ba15e5 --- /dev/null +++ b/test-apis-ci/src/test/resources/config/test-apis-ci/configuration.yaml @@ -0,0 +1,677 @@ +identificationHeaderFields: + - HTTP_IV_USER + - HTTP_CSP_FIRSTNAME + - HTTP_CSP_LASTNAME + - HTTP_IV_REMOTE_ADDRESS + - HTTP_CSP_WSTYPE + +# catalog backend hostname +beFqdn: localhost +# sdccatalog.att.com + +# catalog backend http port +beHttpPort: 8080 + +# catalog backend http context +beContext: /sdc/rest/config/get + +# catalog backend protocol +beProtocol: http + +# catalog backend ssl port +beSslPort: 8443 + +version: 1.1.0 +released: 2012-11-30 +toscaConformanceLevel: 5.0 +minToscaConformanceLevel: 3.0 + +titanCfgFile: /home/vagrant/catalog-be/config/catalog-be/titan.properties +titanInMemoryGraph: false +titanLockTimeout: 1800 + +# The interval to try and reconnect to titan DB when it is down during ASDC startup: +titanReconnectIntervalInSeconds: 3 + +# The read timeout towards Titan DB when health check is invoked: +titanHealthCheckReadTimeout: 1 + +# The interval to try and reconnect to Elasticsearch when it is down during ASDC startup: +esReconnectIntervalInSeconds: 3 +uebHealthCheckReconnectIntervalInSeconds: 15 +uebHealthCheckReadTimeout: 4 + +# Protocols +protocols: + - http + - https + +# Default imports +defaultImports: + - nodes: + file: nodes.yml + - datatypes: + file: data.yml + - capabilities: + file: capabilities.yml + - relationships: + file: relationships.yml + - groups: + file: groups.yml + - policies: + file: policies.yml + +# Users +users: + tom: passwd + bob: passwd + +neo4j: + host: neo4jhost + port: 7474 + user: neo4j + password: "12345" + +cassandraConfig: + cassandraHosts: ['localhost'] + localDataCenter: datacenter1 + reconnectTimeout : 30000 + authenticate: false + username: koko + password: bobo + ssl: false + truststorePath : /path/path + truststorePassword : 123123 + keySpaces: + - { name: sdcaudit, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} + - { name: sdcartifact, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} + - { name: sdccomponent, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} + - { name: sdcrepository, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} + +#Application-specific settings of ES +elasticSearch: + # Mapping of index prefix to time-based frame. For example, if below is configured: + # + # - indexPrefix: auditingevents + # creationPeriod: minute + # + # then ES object of type which is mapped to "auditingevents-*" template, and created on 2015-12-23 13:24:54, will enter "auditingevents-2015-12-23-13-24" index. + # Another object created on 2015-12-23 13:25:54, will enter "auditingevents-2015-12-23-13-25" index. + # If creationPeriod: month, both of the above will enter "auditingevents-2015-12" index. + # + # PLEASE NOTE: the timestamps are created in UTC/GMT timezone! This is needed so that timestamps will be correctly presented in Kibana. + # + # Legal values for creationPeriod - year, month, day, hour, minute, none (meaning no time-based behaviour). + # + # If no creationPeriod is configured for indexPrefix, default behavour is creationPeriod: month. + + indicesTimeFrequency: + - indexPrefix: auditingevents + creationPeriod: month + - indexPrefix: monitoring_events + creationPeriod: month + +artifactTypes: + - CHEF + - PUPPET + - SHELL + - YANG + - YANG_XML + - HEAT + - BPEL + - DG_XML + - MURANO_PKG + - WORKFLOW + - NETWORK_CALL_FLOW + - TOSCA_TEMPLATE + - TOSCA_CSAR + - AAI_SERVICE_MODEL + - AAI_VF_MODEL + - AAI_VF_MODULE_MODEL + - AAI_VF_INSTANCE_MODEL + - OTHER + - SNMP_POLL + - SNMP_TRAP + - GUIDE + +licenseTypes: + - User + - Installation + - CPU + +#Deployment artifacts placeHolder +resourceTypes: &allResourceTypes + - VFC + - CP + - VL + - VF + - VFCMT + - Abstract + - CVFC + +# validForResourceTypes usage +# validForResourceTypes: +# - VF +# - VL +deploymentResourceArtifacts: +# heat: +# displayName: "Base HEAT Template" +# type: HEAT +# validForResourceTypes: *allResourceTypes +# heatVol: +# displayName: "Volume HEAT Template" +# type: HEAT_VOL +# validForResourceTypes: *allResourceTypes +# heatNet: +# displayName: "Network HEAT Template" +# type: HEAT_NET +# validForResourceTypes: *allResourceTypes + +deploymentResourceInstanceArtifacts: + heatEnv: + displayName: "HEAT ENV" + type: HEAT_ENV + description: "Auto-generated HEAT Environment deployment artifact" + fileExtension: "env" + VfHeatEnv: + displayName: "VF HEAT ENV" + type: HEAT_ENV + description: "VF Auto-generated HEAT Environment deployment artifact" + fileExtension: "env" + +#tosca artifacts placeholders +toscaArtifacts: + assetToscaTemplate: + artifactName: -template.yml + displayName: Tosca Template + type: TOSCA_TEMPLATE + description: TOSCA representation of the asset + assetToscaCsar: + artifactName: -csar.csar + displayName: Tosca Model + type: TOSCA_CSAR + description: TOSCA definition package of the asset + + +#Informational artifacts placeHolder +excludeResourceCategory: + - Generic +excludeResourceType: + - PNF +informationalResourceArtifacts: + features: + displayName: Features + type: OTHER + capacity: + displayName: Capacity + type: OTHER + vendorTestResult: + displayName: Vendor Test Result + type: OTHER + testScripts: + displayName: Test Scripts + type: OTHER + CloudQuestionnaire: + displayName: Cloud Questionnaire (completed) + type: OTHER + HEATTemplateFromVendor: + displayName: HEAT Template from Vendor + type: HEAT + resourceSecurityTemplate: + displayName: Resource Security Template + type: OTHER + +excludeServiceCategory: + +informationalServiceArtifacts: + serviceArtifactPlan: + displayName: Service Artifact Plan + type: OTHER + summaryOfImpactsToECOMPElements: + displayName: Summary of impacts to ECOMP elements,OSSs, BSSs + type: OTHER + controlLoopFunctions: + displayName: Control Loop Functions + type: OTHER + dimensioningInfo: + displayName: Dimensioning Info + type: OTHER + affinityRules: + displayName: Affinity Rules + type: OTHER + operationalPolicies: + displayName: Operational Policies + type: OTHER + serviceSpecificPolicies: + displayName: Service-specific Policies + type: OTHER + engineeringRules: + displayName: Engineering Rules (ERD) + type: OTHER + distributionInstructions: + displayName: Distribution Instructions + type: OTHER + certificationTestResults: + displayName: TD Certification Test Results + type: OTHER + deploymentVotingRecord: + displayName: Deployment Voting Record + type: OTHER + serviceQuestionnaire: + displayName: Service Questionnaire + type: OTHER + serviceSecurityTemplate: + displayName: Service Security Template + type: OTHER + +serviceApiArtifacts: + configuration: + displayName: Configuration + type: OTHER + instantiation: + displayName: Instantiation + type: OTHER + monitoring: + displayName: Monitoring + type: OTHER + reporting: + displayName: Reporting + type: OTHER + logging: + displayName: Logging + type: OTHER + testing: + displayName: Testing + type: OTHER + +additionalInformationMaxNumberOfKeys: 50 + +systemMonitoring: + enabled: false + isProxy: false + probeIntervalInSeconds: 15 + +defaultHeatArtifactTimeoutMinutes: 60 + +serviceDeploymentArtifacts: + YANG_XML: + acceptedTypes: + - xml + VNF_CATALOG: + acceptedTypes: + - xml + MODEL_INVENTORY_PROFILE: + acceptedTypes: + - xml + MODEL_QUERY_SPEC: + acceptedTypes: + - xml + UCPE_LAYER_2_CONFIGURATION: + acceptedTypes: + - xml + +#AAI Artifacts + AAI_SERVICE_MODEL: + acceptedTypes: + - xml + AAI_VF_MODULE_MODEL: + acceptedTypes: + - xml + AAI_VF_INSTANCE_MODEL: + acceptedTypes: + - xml + OTHER: + acceptedTypes: + +resourceDeploymentArtifacts: + HEAT: + acceptedTypes: + - yaml + - yml + validForResourceTypes: *allResourceTypes + HEAT_VOL: + acceptedTypes: + - yaml + - yml + validForResourceTypes: *allResourceTypes + HEAT_NET: + acceptedTypes: + - yaml + - yml + validForResourceTypes: *allResourceTypes + HEAT_NESTED: + acceptedTypes: + - yaml + - yml + validForResourceTypes: *allResourceTypes + HEAT_ARTIFACT: + acceptedTypes: + validForResourceTypes: *allResourceTypes + YANG_XML: + acceptedTypes: + - xml + validForResourceTypes: *allResourceTypes + VNF_CATALOG: + acceptedTypes: + - xml + validForResourceTypes: *allResourceTypes + VF_LICENSE: + acceptedTypes: + - xml + validForResourceTypes: *allResourceTypes + VENDOR_LICENSE: + acceptedTypes: + - xml + validForResourceTypes: *allResourceTypes + MODEL_INVENTORY_PROFILE: + acceptedTypes: + - xml + validForResourceTypes: *allResourceTypes + MODEL_QUERY_SPEC: + acceptedTypes: + - xml + validForResourceTypes: *allResourceTypes + LIFECYCLE_OPERATIONS: + acceptedTypes: + - yaml + - yml + validForResourceTypes: + - VF + - VFC + VES_EVENTS: + acceptedTypes: + - yaml + - yml + validForResourceTypes: *allResourceTypes + PERFORMANCE_COUNTER: + acceptedTypes: + - csv + validForResourceTypes: *allResourceTypes + APPC_CONFIG: + acceptedTypes: + validForResourceTypes: + - VF + DCAE_TOSCA: + acceptedTypes: + - yml + - yaml + validForResourceTypes: + - VF + - VFCMT + DCAE_JSON: + acceptedTypes: + - json + validForResourceTypes: + - VF + - VFCMT + DCAE_POLICY: + acceptedTypes: + - emf + validForResourceTypes: + - VF + - VFCMT + DCAE_DOC: + acceptedTypes: + validForResourceTypes: + - VF + - VFCMT + DCAE_EVENT: + acceptedTypes: + validForResourceTypes: + - VF + - VFCMT + AAI_VF_MODEL: + acceptedTypes: + - xml + validForResourceTypes: + - VF + AAI_VF_MODULE_MODEL: + acceptedTypes: + - xml + validForResourceTypes: + - VF + OTHER: + acceptedTypes: + validForResourceTypes: *allResourceTypes + SNMP_POLL: + acceptedTypes: + validForResourceTypes: *allResourceTypes + SNMP_TRAP: + acceptedTypes: + validForResourceTypes: *allResourceTypes + +resourceInstanceDeploymentArtifacts: + HEAT_ENV: + acceptedTypes: + - env + VF_MODULES_METADATA: + acceptedTypes: + - json + VES_EVENTS: + acceptedTypes: + - yaml + - yml + PERFORMANCE_COUNTER: + acceptedTypes: + - csv + DCAE_INVENTORY_TOSCA: + acceptedTypes: + - yml + - yaml + DCAE_INVENTORY_JSON: + acceptedTypes: + - json + DCAE_INVENTORY_POLICY: + acceptedTypes: + - emf + DCAE_INVENTORY_DOC: + acceptedTypes: + DCAE_INVENTORY_BLUEPRINT: + acceptedTypes: + DCAE_INVENTORY_EVENT: + acceptedTypes: + SNMP_POLL: + acceptedTypes: + validForResourceTypes: *allResourceTypes + SNMP_TRAP: + acceptedTypes: + validForResourceTypes: *allResourceTypes + +resourceInformationalArtifacts: + CHEF: + acceptedTypes: + validForResourceTypes: *allResourceTypes + PUPPET: + acceptedTypes: + validForResourceTypes: *allResourceTypes + SHELL: + acceptedTypes: + validForResourceTypes: *allResourceTypes + YANG: + acceptedTypes: + validForResourceTypes: *allResourceTypes + YANG_XML: + acceptedTypes: + validForResourceTypes: *allResourceTypes + HEAT: + acceptedTypes: + validForResourceTypes: *allResourceTypes + BPEL: + acceptedTypes: + validForResourceTypes: *allResourceTypes + DG_XML: + acceptedTypes: + validForResourceTypes: *allResourceTypes + MURANO_PKG: + acceptedTypes: + validForResourceTypes: *allResourceTypes + OTHER: + acceptedTypes: + validForResourceTypes: + - VFC + - CVFC + - CP + - VL + - VF + - VFCMT + - Abstract + - PNF + SNMP_POLL: + acceptedTypes: + validForResourceTypes: *allResourceTypes + SNMP_TRAP: + acceptedTypes: + validForResourceTypes: *allResourceTypes + GUIDE: + acceptedTypes: + validForResourceTypes: + - VF + - VFC + - CVFC + +resourceInformationalDeployedArtifacts: + +requirementsToFulfillBeforeCert: + +capabilitiesToConsumeBeforeCert: + +unLoggedUrls: + - /sdc2/rest/healthCheck + +cleanComponentsConfiguration: + cleanIntervalInMinutes: 1440 + componentsToClean: + - Resource + - Service + +artifactsIndex: resources + +heatEnvArtifactHeader: "" +heatEnvArtifactFooter: "" + +onboarding: + protocol: http + host: localhost + port: 8080 + downloadCsarUri: "/onboarding-api/v1.0/vendor-software-products/packages" + healthCheckUri: "/onboarding-api/v1.0/healthcheck" + +dcae: + protocol: http + host: 127.0.0.1 + port: 8080 + healthCheckUri: "/dcae/healthCheck" + +switchoverDetector: + gBeFqdn: AIO-BE.ecomp.idns.cip.com + gFeFqdn: AIO-FE.ecomp.idns.cip.com + beVip: 0.0.0.0 + feVip: 0.0.0.0 + beResolveAttempts: 3 + feResolveAttempts: 3 + enabled: false + interval: 60 + changePriorityUser: ecompasdc + changePriorityPassword: ecompasdc123 + publishNetworkUrl: "http://xxx.com/crt/CipDomain.ECOMP-ASDC-DEVST/config/update_network?user=root" + publishNetworkBody: '{"note":"publish network"}' + groups: + beSet: { changePriorityUrl: "http://xxx.com/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-BE.ecomp.idns.com?user=root", + changePriorityBody: '{"name":"AIO-BE.ecomp.idns.com","uri":"/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-BE.ecomp.idns.com","no_ad_redirection":false,"v4groups":{"failover_groups":["/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_mg_be","/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_bs_be"],"failover_policy":["FAILALL"]},"comment":"AIO BE G-fqdn","intended_app_proto":"DNS"}'} + feSet: { changePriorityUrl: "http://xxx.com/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-FE.ecomp.idns.com?user=root", + changePriorityBody: '{"comment":"AIO G-fqdn","name":"AIO-FE.ecomp.idns.com","v4groups":{"failover_groups":["/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_mg_fe","/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_bs_fe"],"failover_policy":["FAILALL"]},"no_ad_redirection":false,"intended_app_proto":"DNS","uri":"/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-FE.ecomp.idns.com"}'} + +applicationL1Cache: + datatypes: + enabled: true + firstRunDelay: 10 + pollIntervalInSec: 60 + +applicationL2Cache: + enabled: true + catalogL1Cache: + enabled: true + resourcesSizeInCache: 300 + servicesSizeInCache: 200 + productsSizeInCache: 100 + queue: + syncIntervalInSecondes: 43200 + waitOnShutDownInMinutes: 10 + numberOfCacheWorkers: 4 + +toscaValidators: + stringMaxLength: 2500 + +disableAudit: false + +vfModuleProperties: + min_vf_module_instances: + forBaseModule: 1 + forNonBaseModule: 0 + max_vf_module_instances: + forBaseModule: 1 + forNonBaseModule: + initial_count: + forBaseModule: 1 + forNonBaseModule: 0 + vf_module_type: + forBaseModule: Base + forNonBaseModule: Expansion + +genericAssetNodeTypes: + VFC: org.openecomp.resource.abstract.nodes.VFC + CVFC: org.openecomp.resource.abstract.nodes.VFC + VF : org.openecomp.resource.abstract.nodes.VF + PNF: org.openecomp.resource.abstract.nodes.PNF + Service: org.openecomp.resource.abstract.nodes.service + +workloadContext: Production +environmentContext: + defaultValue: General_Revenue-Bearing + validValues: + - Critical_Revenue-Bearing + - Vital_Revenue-Bearing + - Essential_Revenue-Bearing + - Important_Revenue-Bearing + - Needed_Revenue-Bearing + - Useful_Revenue-Bearing + - General_Revenue-Bearing + - Critical_Non-Revenue + - Vital_Non-Revenue + - Essential_Non-Revenue + - Important_Non-Revenue + - Needed_Non-Revenue + - Useful_Non-Revenue + - General_Non-Revenue + +dmaapConsumerConfiguration: + hosts: olsd004.wnsnet.attws.com:3905 + consumerGroup: asdc + consumerId: mama + timeoutMs: 15000 + limit: 1 + pollingInterval: 2 + topic: com.att.sdc.23911-SDCforTestDev-v001 + latitude: 32.109333 + longitude: 34.855499 + version: 1.0 + serviceName: dmaap-v1.dev.dmaap.dt.saat.acsi.att.com/events + environment: TEST + partner: BOT_R + routeOffer: MR1 + protocol: https + contenttype: application/json + dme2TraceOn: true + aftEnvironment: AFTUAT + aftDme2ConnectionTimeoutMs: 15000 + aftDme2RoundtripTimeoutMs: 240000 + aftDme2ReadTimeoutMs: 50000 + dme2preferredRouterFilePath: DME2preferredRouter.txt + timeLimitForNotificationHandleMs: 0 + credential: + username: m09875@sdc.att.com + password: hmXYcznAljMSisdy8zgcag== + +dmeConfiguration: + dme2Search: DME2SEARCH + dme2Resolve: DME2RESOLVE diff --git a/test-apis-ci/src/test/resources/config/test-apis-ci/distribution-engine-configuration.yaml b/test-apis-ci/src/test/resources/config/test-apis-ci/distribution-engine-configuration.yaml new file mode 100644 index 0000000000..00ae8f59c0 --- /dev/null +++ b/test-apis-ci/src/test/resources/config/test-apis-ci/distribution-engine-configuration.yaml @@ -0,0 +1,77 @@ +uebServers: + - uebsb91kcdc.it.att.com + - uebsb92kcdc.it.att.com +# - uebsb93kcdc.it.att.com + +uebPublicKey: 8F3MDAtMSBwwpSMy + +uebSecretKey: gzFmsTxSCtO5RQfAccM6PqqX + +distributionNotifTopicName: ASDC-DISTR-NOTIF-TOPIC +distributionStatusTopicName: ASDC-DISTR-STATUS-TOPIC + +initRetryIntervalSec: 5 +initMaxIntervalSec: 60 + +distribNotifServiceArtifactTypes: + info: + - MURANO-PKG + +distribNotifResourceArtifactTypes: + lifecycle: + - HEAT + - DG-XML + +environments: + - PROD + +distributionStatusTopic: + pollingIntervalSec: 60 + fetchTimeSec: 15 + consumerGroup: asdc + consumerId: asdc-id + +distributionNotificationTopic: + minThreadPoolSize: 0 + maxThreadPoolSize: 10 + maxWaitingAfterSendingSeconds: 5 + +createTopic: + partitionCount: 1 + replicationCount: 1 + +startDistributionEngine: true + + +aaiConfig: + serverRootUrl: https://127.0.0.1/aai/v1 + resourceNamespaces: + operationalEnvironments: /aai/cloud-infrastructure/operational-environments + + httpRequestConfig: + readTimeoutMs: 5000 + connectTimeoutMs: 1000 + maxReadConnectionRetry: 3 + userName: abcd + password: hmXYcznAljMSisdy8zgcag== + clientSslAuthentication: false + keyStore: opt/app/catalog-be/cert/.keystore + keyStorePassword: hmXYcznAljMSisdy8zgcag== + + httpRequestHeaders: + XFromAppId: asdc + +opEnvRecoveryIntervalSec: 180 +allowedTimeBeforeStaleSec: 300 + +msoConfig: + serverRootUrl: https://127.0.0.1/onap/so/infra/modelDistributions/v1 + resourceNamespaces: + distributions: /distributions + + httpClientConfig: + readTimeout: 2000 + connectTimeout: 500 + numOfRetries: 3 + userName: asdc + password: OTLEp5lfVhYdyw5EAtTUBQ== \ No newline at end of file diff --git a/test-apis-ci/src/test/resources/config/test-apis-ci/ecomp-error-configuration.yaml b/test-apis-ci/src/test/resources/config/test-apis-ci/ecomp-error-configuration.yaml new file mode 100644 index 0000000000..9d7cd74a2b --- /dev/null +++ b/test-apis-ci/src/test/resources/config/test-apis-ci/ecomp-error-configuration.yaml @@ -0,0 +1,383 @@ +########################################### +# Note the conventions of the field values: +# type can be one of: CONFIG_ERROR, SYSTEM_ERROR, DATA_ERROR, CONNECTION_PROBLEM, AUTHENTICATION_PROBLEM +# severity can be one of: WARN, ERROR, FATAL +# alarmSeverity can be one of: CRITICAL,MAJOR,MINOR,INFORMATIONAL,NONE +# code is a unique integer in range of 3003-9999 (3000-3002 are occupied for internal usage) +# The above enumeration values are out-of-the-box and can be changed in code. +# In case of config and code mismatch, the appropriate error will be printed to log +# +## Range of BE codes - 3010-7999 + +errors: + + BeRestApiGeneralError: { + type: SYSTEM_ERROR, + code: ASDC_4000, + severity: ERROR, + description: "Unexpected error during BE REST API execution", + alarmSeverity: CRITICAL + } + + BeHealthCheckError: { + type: SYSTEM_ERROR, + code: ASDC_3010, + severity: ERROR, + description: "Error during BE Health Check", + alarmSeverity: CRITICAL + } + + BeInitializationError: { + type: SYSTEM_ERROR, + code: ASDC_4019, + severity: ERROR, + description: "Catalog-BE was not initialized properly", + alarmSeverity: CRITICAL + } + + BeResourceMissingError: { + type: SYSTEM_ERROR, + code: ASDC_3011, + severity: ERROR, + description: "Mandatory resource %s cannot be found in repository", + alarmSeverity: MAJOR + } + + BeServiceMissingError: { + type: SYSTEM_ERROR, + code: ASDC_3012, + severity: ERROR, + description: "Mandatory service %s cannot be found in repository", + alarmSeverity: MAJOR + } + + BeFailedAddingResourceInstanceError: { + type: SYSTEM_ERROR, + code: ASDC_3013, + severity: ERROR, + description: "Failed to add resource instance of resource %s to service %s", + alarmSeverity: MAJOR + } + + BeIncorrectServiceError: { + type: SYSTEM_ERROR, + code: ASDC_3014, + severity: ERROR, + description: "Service %s is not valid", + alarmSeverity: MAJOR + } + + BeRepositoryDeleteError: { + type: SYSTEM_ERROR, + code: ASDC_3015, + severity: ERROR, + description: "Failed to delete object %s from repository", + alarmSeverity: CRITICAL + } + + BeRepositoryQueryError: { + type: SYSTEM_ERROR, + code: ASDC_3016, + severity: ERROR, + description: "Failed to fetch from repository %s", + alarmSeverity: MAJOR + } + + BeInvalidConfigurationError: { + type: CONFIG_ERROR, + code: ASDC_3017, + severity: FATAL, + description: "Configuration parameter %s is invalid. Value configured is %s", + alarmSeverity: MAJOR + } + + BeUebConnectionError: { + type: CONNECTION_PROBLEM, + code: ASDC_4001, + severity: ERROR, + description: "Connection problem towards U-EB server. Reason: %s", + alarmSeverity: MAJOR + } + + BeUebSystemError: { + type: SYSTEM_ERROR, + code: ASDC_3019, + severity: ERROR, + description: "Error occured during access to U-EB Server. Operation: %s", + alarmSeverity: MAJOR + } + + BeUebObjectNotFoundError: { + type: DATA_ERROR, + code: ASDC_4005, + severity: ERROR, + description: "Error occured during access to U-EB Server. Data not found: %s", + alarmSeverity: MAJOR + } + + BeDistributionEngineSystemError: { + type: SYSTEM_ERROR, + code: ASDC_3021, + severity: ERROR, + description: "Error occured in Distribution Engine. Failed operation: %s", + alarmSeverity: MAJOR + } + + BeUebAuthenticationError: { + type: AUTHENTICATION_PROBLEM, + code: ASDC_4003, + severity: ERROR, + description: "Authentication problem towards U-EB server. Reason: %s", + alarmSeverity: MAJOR + } + + BeUebUnkownHostError: { + type: CONNECTION_PROBLEM, + code: ASDC_4002, + severity: ERROR, + description: "Connection problem towards U-EB server. Cannot reach host %s", + alarmSeverity: MAJOR + } + + BeDistributionEngineInvalidArtifactType: { + type: DATA_ERROR, + code: ASDC_4006, + severity: WARN, + description: "The artifact type %s does not appear in the list of valid artifacts %s", + alarmSeverity: MAJOR + } + BeInvalidTypeError: { + type: DATA_ERROR, + code: ASDC_4008, + severity: WARN, + description: "The type %s of %s is invalid", + alarmSeverity: MAJOR + } + BeInvalidValueError: { + type: DATA_ERROR, + code: ASDC_3028, + severity: WARN, + description: "The value %s of %s from type %s is invalid", + alarmSeverity: MAJOR + } + + BeFailedDeletingResourceInstanceError: { + type: SYSTEM_ERROR, + code: ASDC_3029, + severity: ERROR, + description: "Failed to delete resource instance %s from service %s", + alarmSeverity: MAJOR + } + + BeMissingConfigurationError: { + type: CONFIG_ERROR, + code: ASDC_3030, + severity: FATAL, + description: "Configuration parameter %s is missing", + alarmSeverity: MAJOR + } + + BeConfigurationInvalidListSizeError: { + type: CONFIG_ERROR, + code: ASDC_3031, + severity: FATAL, + description: "Configuration parameter %s is invalid. At least %s values shall be configured", + alarmSeverity: MAJOR + } + + ErrorConfigFileFormat: { + type: CONFIG_ERROR, + code: ASDC_3032, + severity: ERROR, + description: "Error element not found in YAML name: %s", + alarmSeverity: MAJOR + } + + BeMissingArtifactInformationError: { + type: DATA_ERROR, + code: ASDC_4010, + severity: ERROR, + description: "Artifact uploaded has missing information. Missing %s", + alarmSeverity: MAJOR + } + + BeArtifactMissingError: { + type: DATA_ERROR, + code: ASDC_4011, + severity: ERROR, + description: "Artifact %s requested is not found", + alarmSeverity: MAJOR + } + + BeArtifactPayloadInvalid: { + type: DATA_ERROR, + code: ASDC_4012, + severity: ERROR, + description: "Payload of artifact uploaded is invalid (invalid MD5 or encryption)", + alarmSeverity: MAJOR + } + + BeUserMissingError: { + type: DATA_ERROR, + code: ASDC_4009, + severity: ERROR, + description: "User %s requested is not found", + alarmSeverity: MAJOR + } + + BeArtifactInformationInvalidError: { + type: DATA_ERROR, + code: ASDC_4013, + severity: ERROR, + description: "Input for artifact metadata is invalid", + alarmSeverity: MAJOR + } + BeFailedAddingCapabilityTypeError: { + type: DATA_ERROR, + code: ASDC_4015, + severity: ERROR, + description: "Failed adding capability type", + alarmSeverity: CRITICAL + } + + BeCapabilityTypeMissingError: { + type: DATA_ERROR, + code: ASDC_4016, + severity: ERROR, + description: "Capability Type %s not found", + alarmSeverity: CRITICAL + } + + BeInterfaceMissingError: { + type: DATA_ERROR, + code: ASDC_4020, + severity: ERROR, + description: "Interface %s required is missing", + alarmSeverity: MAJOR + } + + BeDaoSystemError: { + type: SYSTEM_ERROR, + code: ASDC_4014, + severity: ERROR, + description: "Operation towards database failed", + alarmSeverity: CRITICAL + } + + BeSystemError: { + type: SYSTEM_ERROR, + code: ASDC_4017, + severity: ERROR, + description: "Unexpected error during operation", + alarmSeverity: CRITICAL + } + + BeFailedLockObjectError: { + type: SYSTEM_ERROR, + code: ASDC_4007, + severity: WARN, + description: "Failed to lock object for update", + alarmSeverity: CRITICAL + } + + BeInvalidJsonInput: { + type: SYSTEM_ERROR, + code: ASDC_4018, + severity: ERROR, + description: "Failed to convert json input to object", + alarmSeverity: MAJOR + } + + BeDistributionMissingError: { + type: DATA_ERROR, + code: ASDC_4021, + severity: ERROR, + description: "Distribution %s required is missing", + alarmSeverity: MAJOR + } + + BeHealthCheckRecovery: { + type: RECOVERY, + code: ASDC_4022, + severity: INFO, + description: "BE Health Check Recovery", + alarmSeverity: INFORMATIONAL + } + BeFailedCreateNodeError: { + type: DATA_ERROR, + code: ASDC_6000, + severity: ERROR, + description: "Failed to create node %s on graph. status is %s", + alarmSeverity: MAJOR + } + BeFailedUpdateNodeError: { + type: DATA_ERROR, + code: ASDC_6001, + severity: ERROR, + description: "Failed to update node %s on graph. Status is %s", + alarmSeverity: MAJOR + } + + BeFailedDeleteNodeError: { + type: DATA_ERROR, + code: ASDC_6002, + severity: ERROR, + description: "Failed to delete node %s on graph. Status is %s", + alarmSeverity: MAJOR + } + + BeFailedRetrieveNodeError: { + type: DATA_ERROR, + code: ASDC_6003, + severity: ERROR, + description: "Failed to retrieve node %s from graph. Status is %s", + alarmSeverity: MAJOR + } + + BeExecuteRollbackError: { + type: DATA_ERROR, + code: ASDC_6004, + severity: ERROR, + description: "Going to execute rollback on graph.", + alarmSeverity: MAJOR + } + + BeFailedFindParentError: { + type: DATA_ERROR, + code: ASDC_6005, + severity: ERROR, + description: "Failed to find parent node %s on graph. Status is %s", + alarmSeverity: MAJOR + } + + BeFailedFindAllNodesError: { + type: DATA_ERROR, + code: ASDC_6006, + severity: ERROR, + description: "Failed to fetch all nodes with type %s of parent node %s . Status is %s", + alarmSeverity: MAJOR + } + + BeFailedFindAssociationError: { + type: DATA_ERROR, + code: ASDC_6007, + severity: ERROR, + description: "Cannot find node with type %s associated with node %s . Status is %s", + alarmSeverity: MAJOR + } + + BeFailedFindAssociationError: { + type: DATA_ERROR, + code: ASDC_6008, + severity: ERROR, + description: "Cannot find node with type %s associated with node %s . Status is %s", + alarmSeverity: MAJOR + } + BeComponentCleanerSystemError: { + type: SYSTEM_ERROR, + code: ASDC_6009, + severity: ERROR, + description: "Error occured in Component Cleaner Task. Failed operation: %s", + alarmSeverity: MAJOR + } + \ No newline at end of file diff --git a/test-apis-ci/src/test/resources/config/test-apis-ci/error-configuration.yaml b/test-apis-ci/src/test/resources/config/test-apis-ci/error-configuration.yaml new file mode 100644 index 0000000000..5494c2fce3 --- /dev/null +++ b/test-apis-ci/src/test/resources/config/test-apis-ci/error-configuration.yaml @@ -0,0 +1,1883 @@ +# Errors +errors: + OK: { + code: 200, + message: "OK" + } + CREATED: { + code: 201, + message: "OK" + } + ACCEPTED: { + code: 202, + message: "Accepted" + } + NO_CONTENT: { + code: 204, + message: "No Content" + } +#--------POL4050----------------------------- + NOT_ALLOWED: { + code: 405, + message: "Error: Method not allowed.", + messageId: "POL4050" + } +#--------POL5000----------------------------- + GENERAL_ERROR: { + code: 500, + message: "Error: Internal Server Error. Please try again later.", + messageId: "POL5000" + } +#---------POL5001------------------------------ + MISSING_X_ECOMP_INSTANCE_ID: { + code: 400 , + message: "Error: Missing 'X-ECOMP-InstanceID' HTTP header.", + messageId: "POL5001" + } +#---------POL5002------------------------------ + AUTH_REQUIRED: { + code: 401 , + message: "Error: Authentication is required to use the API.", + messageId: "POL5002" + } +#---------POL5003------------------------------ + AUTH_FAILED: { + code: 403 , + message: "Error: Not authorized to use the API.", + messageId: "POL5003" + } +#---------POL5004------------------------------ + MISSING_USER_ID: { + code: 400 , + message: "Error: Missing 'USER_ID' HTTP header.", + messageId: "POL5004" + } +#---------SVC4000----------------------------- + INVALID_CONTENT: { + code: 400, + message: "Error: Invalid content.", + messageId: "SVC4000" + } +#---------SVC4002----------------------------- + MISSING_INFORMATION: { + code: 403, + message: "Error: Missing information.", + messageId: "SVC4002" + } +#---------SVC4003------------------------------ +# %1 - Users's ID + USER_NOT_FOUND: { + code: 404, + message: "Error: User '%1' was not found.", + messageId: "SVC4003" + } +#---------SVC4004----------------------------- +# %1 - Users's email address + INVALID_EMAIL_ADDRESS: { + code: 400, + message: "Error: Invalid email address '%1'.", + messageId: "SVC4004" + } +#---------SVC4005------------------------------ +# %1 - role + INVALID_ROLE: { + code: 400, + message: "Error: Invalid role '%1'.", + messageId: "SVC4005" + } +#---------SVC4006------------------------------ +# %1 - Users's USER_ID + USER_ALREADY_EXIST: { + code: 409, + message: "Error: User with '%1' ID already exists.", + messageId: "SVC4006" + } +#---------SVC4007------------------------------ + DELETE_USER_ADMIN_CONFLICT: { + code: 409, + message: "Error: An administrator can only be deleted by another administrator.", + messageId: "SVC4007" + } +#---------SVC4008----------------------------- +# %1 - Users's userId + INVALID_USER_ID: { + code: 400, + message: "Error: Invalid userId '%1'.", + messageId: "SVC4008" + } + +#---------SVC4049------------------------------ +# %1 - service/resource + COMPONENT_MISSING_CONTACT: { + code: 400, + message: "Error: Invalid Content. Missing %1 contact.", + messageId: "SVC4051" + } +#---------SVC4050----------------------------- +# %1 - Service/Resource/Additional parameter +# %2 - service/resource/label name + COMPONENT_NAME_ALREADY_EXIST: { + code: 409, + message: "Error: %1 with name '%2' already exists.", + messageId: "SVC4050" + } +#---------SVC4051------------------------------ +# %1 - resource/service + COMPONENT_MISSING_CATEGORY: { + code: 400, + message: "Error: Invalid Content. Missing %1 category.", + messageId: "SVC4051" + } + +#---------SVC4052------------------------------ + COMPONENT_MISSING_TAGS: { + code: 400, + message: "Error: Invalid Content. At least one tag has to be specified.", + messageId: "SVC4052" + } + +#---------SVC4053------------------------------ +# %1 - service/resource + COMPONENT_MISSING_DESCRIPTION: { + code: 400, + message: "Error: Invalid Content. Missing %1 description.", + messageId: "SVC4053" + } +#---------SVC4054------------------------------ +# %1 - resource/service + COMPONENT_INVALID_CATEGORY: { + code: 400, + message: "Error: Invalid Content. Invalid %1 category.", + messageId: "SVC4054" + } +#---------SVC4055------------------------------ + MISSING_VENDOR_NAME: { + code: 400, + message: "Error: Invalid Content. Missing vendor name.", + messageId: "SVC4055" + } +#---------SVC4056------------------------------ + MISSING_VENDOR_RELEASE: { + code: 400, + message: "Error: Invalid Content. Missing vendor release.", + messageId: "SVC4056" + } + +#---------SVC4057------------------------------ + MISSING_DERIVED_FROM_TEMPLATE: { + code: 400, + message: "Error: Invalid Content. Missing derived from template specification.", + messageId: "SVC4057" + } + +#---------SVC4058------------------------------ +# %1 - service/resource + COMPONENT_MISSING_ICON: { + code: 400, + message: "Error: Invalid Content. Missing %1 icon.", + messageId: "SVC4058" + } +#---------SVC4059------------------------------ +# %1 - service/resource + COMPONENT_INVALID_ICON: { + code: 400, + message: "Error: Invalid Content. Invalid %1 icon.", + messageId: "SVC4059" + } +#---------SVC4060------------------------------ + PARENT_RESOURCE_NOT_FOUND: { + code: 400, + message: "Error: Invalid Content. Derived from resource template was not found.", + messageId: "SVC4060" + } +#---------SVC4061------------------------------ + MULTIPLE_PARENT_RESOURCE_FOUND: { + code: 400, + message: "Error: Invalid Content. Multiple derived from resource template is not allowed.", + messageId: "SVC4061" + } + +#---------SVC4062------------------------------ +# %1 - service/resource + MISSING_COMPONENT_NAME: { + code: 400, + message: "Error: Invalid Content. Missing %1 name.", + messageId: "SVC4062" + } +#---------SVC4063------------------------------ + #%1  -  resource/service name + RESOURCE_NOT_FOUND: { + code: 404, + message: "Error: Requested '%1' resource was not found.", + messageId: "SVC4063" + } + +#---------SVC4064------------------------------ +# %1 - Service/Resource/Property + COMPONENT_INVALID_DESCRIPTION: { + code: 400, + message: "Error: Invalid Content. %1 description contains non-english characters.", + messageId: "SVC4064" + } +#---------SVC4065------------------------------ +# %1 - Service/Resource/Property +# %2 - max resource/service name length + COMPONENT_DESCRIPTION_EXCEEDS_LIMIT: { + code: 400, + message: "Error: Invalid Content. %1 description exceeds limit of %2 characters.", + messageId: "SVC4065" + } +#---------SVC4066------------------------------ +# %1 - max length + COMPONENT_TAGS_EXCEED_LIMIT: { + code: 400, + message: "Error: Invalid Content. Tags overall length exceeds limit of %1 characters.", + messageId: "SVC4066" + } +#---------SVC4067------------------------------ +# %1 - max length + VENDOR_NAME_EXCEEDS_LIMIT: { + code: 400, + message: "Error: Invalid Content. Vendor name exceeds limit of %1 characters.", + messageId: "SVC4067" + } +#---------SVC4068------------------------------ +# %1 - max length + VENDOR_RELEASE_EXCEEDS_LIMIT: { + code: 400, + message: "Error: Invalid Content. Vendor release exceeds limit of %1 characters.", + messageId: "SVC4068" + } + +#---------SVC4069------------------------------ +# %1 - Service/Resource/Product + COMPONENT_INVALID_CONTACT: { + code: 400, + message: "Error: Invalid Content. %1 Contact Id should be in format 'mnnnnnn' or 'aannna' or 'aannnn', where m=m ,a=a-zA-Z and n=0-9", + messageId: "SVC4069" + } +#---------SVC4070------------------------------ +# %1 - Service/Resource + INVALID_COMPONENT_NAME: { + code: 400, + message: 'Error: Invalid Content. %1 name is not allowed to contain characters like <>:"\/|?* and space characters other than regular space.', + messageId: "SVC4070" + } + +#---------SVC4071------------------------------ + INVALID_VENDOR_NAME: { + code: 400, + message: 'Error: Invalid Content. Vendor name is not allowed to contain characters like <>:"\/|?* and space characters other than regular space.', + messageId: "SVC4071" + } +#---------SVC4072------------------------------ + INVALID_VENDOR_RELEASE: { + code: 400, + message: 'Error: Invalid Content. Vendor release is not allowed to contain characters like <>:"\/|?* and space characters other than regular space.', + messageId: "SVC4072" + } +#---------SVC4073------------------------------ +# %1 - Service/Resource +# %2 - max resource/service name + COMPONENT_NAME_EXCEEDS_LIMIT: { + code: 400, + message: "Error: Invalid Content. %1 name exceeds limit of %2 characters.", + messageId: "SVC4073" + } +#---------SVC4080------------------------------ +# %1 - resource/service name +# %2 - resource/service +# %3 - First name of last modifier +# %4 - Last name of last modifier +# %5 - USER_ID of last modifier + COMPONENT_IN_CHECKOUT_STATE: { + code: 403, + message: "Error: Requested '%1' %2 is locked for modification by %3 %4(%5).", + messageId: "SVC4080" + } +#---------SVC4081----------------------------- +# %1 - resource/service name +# %2 - resource/service +# %3 - First name of last modifier +# %4 - Last name of last modifier +# %5 - USER_ID of last modifier + COMPONENT_IN_CERT_IN_PROGRESS_STATE: { + code: 403, + message: "Error: Requested '%1' %2 is locked for certification by %3 %4(%5).", + messageId: "SVC4081" + } + +#-----------SVC4082--------------------------- +# %1 - resource/service name +# %2 - resource/service +# %3 - First name of last modifier +# %4 - Last name of last modifier +# %5 - USER_ID of last modifier + COMPONENT_SENT_FOR_CERTIFICATION: { + code: 403, + message: "Error: Requested '%1' %2 is sent for certification by %3 %4(%5).", + messageId: "SVC4082" + } +#-----------SVC4083--------------------------- + COMPONENT_VERSION_ALREADY_EXIST: { + code: 409, + message: "Error: Version of this %1 was already promoted.", + messageId: "SVC4083" + } +#-----------SVC4084--------------------------- +# %1 - resource/service/product name +# %2 - resource/service/product +# %3 - First name of last modifier +# %4 - Last name of last modifier +# %5 - USER_ID of last modifier + COMPONENT_ALREADY_CHECKED_IN: { + code: 409, + message: "Error: The current version of '%1' %2 was already checked-in by %3 %4(%5).", + messageId: "SVC4084" + } +#-----------SVC4085--------------------------- +# %1 - resource/service/product name +# %2 - resource/service/product +# %3 - First name of last modifier +# %4 - Last name of last modifier +# %5 - USER_ID of last modifier + COMPONENT_CHECKOUT_BY_ANOTHER_USER: { + code: 403, + message: "Error: %1 %2 has already been checked out by %3 %4(%5).", + messageId: "SVC4085" + } +#-----------SVC4086--------------------------- +# %1  - resource/service name +# %2  - resource/service + COMPONENT_IN_USE: { + code: 403, + message: "Error: Requested '%1' %2 is in use by another user.", + messageId: "SVC4086" + } +#-----------SVC4087--------------------------- +# %1 - component name +# %2 - resource/service/product + COMPONENT_HAS_NEWER_VERSION: { + code: 409, + message: "Error: Checking out of the requested version of the '%1' %2 is not allowed as a newer version exists.", + messageId: "SVC4087" + } +#-----------SVC4088--------------------------- +# %1 - resource/service name +# %2 - resource/service +# %3 - First name of last modifier +# %4 - Last name of last modifier +# %5 - USER_ID of last modifier + COMPONENT_ALREADY_CERTIFIED: { + code: 403, + message: "Error: Requested %1 %2 has already been certified by %3 %4(%5).", + messageId: "SVC4088" + } +#-----------SVC4089--------------------------- +# %1 - resource/service name +# %2 - resource/service + COMPONENT_NOT_READY_FOR_CERTIFICATION: { + code: 403, + message: "Error: Requested '%1' %2 is not ready for certification.", + messageId: "SVC4089" + } +#-----------SVC4100--------------------------- +#%1 - property name + PROPERTY_NOT_FOUND: { + code: 404, + message: "Error: Requested '%1' property was not found.", + messageId: "SVC4100" + } +#-----------SVC4101--------------------------- +#%1 - property name + PROPERTY_ALREADY_EXIST: { + code: 409, + message: "Error: Property with '%1' name already exists.", + messageId: "SVC4101" + } + +#-----------SVC4102--------------------------- +# %1 - capability type name + CAPABILITY_TYPE_ALREADY_EXIST: { + code: 409, + message: "Error: Capability Type with name '%1' already exists.", + messageId: "SVC4102" + } +#-----------SVC4114--------------------------- + AUTH_FAILED_INVALIDE_HEADER: { + code: 400, + message: "Error: Invalid Authorization header.", + messageId: "SVC4114" + } +#-----------SVC4115--------------------------- +# %1 - capability type name + MISSING_CAPABILITY_TYPE: { + code: 400, + message: "Error: Invalid Content. Missing Capability Type '%1'.", + messageId: "SVC4115" + } + RESOURCE_INSTANCE_BAD_REQUEST: { + code: 400, + message: "Error: Invalid Content.", + messageId: "SVC4116" + } +#-----------SVC4117--------------------------- +# %1 - resource instance name +# %2 - resource instance name +# %3 - requirement name + RESOURCE_INSTANCE_MATCH_NOT_FOUND: { + code: 404, + message: "Error: Match not found between resource instance '%1' and resource instance '%2' for requirement '%3'.", + messageId: "SVC4117" + } +#-----------SVC4118--------------------------- +# %1 - resource instance name +# %2 - resource instance name +# %3 - requirement name + RESOURCE_INSTANCE_ALREADY_EXIST: { + code: 409, + message: "Error: Resource instances '%1' and '%2' are already associated with requirement '%3'.", + messageId: "SVC4118" + } +#-----------SVC4119--------------------------- +# %1 - resource instance name +# %2 - resource instance name +# %3 - requirement name + RESOURCE_INSTANCE_RELATION_NOT_FOUND: { + code: 404, + message: "Error: No relation found between resource instances '%1' and '%2' for requirement '%3'.", + messageId: "SVC4119" + } +#-----------SVC4120--------------------------- +# %1 - User's USER_ID + USER_INACTIVE: { + code: 404, + message: "Error: User %1 was not found.", + messageId: "SVC4120" + } +#-----------SVC4121--------------------------- +# %1 - User's USER_ID + USER_HAS_ACTIVE_ELEMENTS: { + code: 403, + message: "Error: User with %1 ID can not be deleted since it has active elements(resources/services/artifacts).", + messageId: "SVC4121" + } +#-----------SVC4122--------------------------- +# %1 - artifact type + ARTIFACT_TYPE_NOT_SUPPORTED: { + code: 400, + message: "Error: Invalid artifact type '%1'.", + messageId: "SVC4122" + } +#-----------SVC4123--------------------------- + ARTIFACT_LOGICAL_NAME_CANNOT_BE_CHANGED: { + code: 400, + message: "Error: Artifact logical name cannot be changed.", + messageId: "SVC4123" + } +#-----------SVC4124--------------------------- + MISSING_ARTIFACT_TYPE: { + code: 400, + message: "Error: Missing artifact type.", + messageId: "SVC4124" + } +#-----------SVC4125--------------------------- +# %1-artifact name + ARTIFACT_EXIST: { + code: 400, + message: "Error: Artifact '%1' already exists.", + messageId: "SVC4125" + } +#---------SVC4126------------------------------ +# %1 - resource/service/product/... +# %2 - field (tag, vendor name...) + INVALID_FIELD_FORMAT: { + code: 400, + message: "Error: Invalid %1 %2 format.", + messageId: "SVC4126" + } +#-----------SVC4127--------------------------- + ARTIFACT_INVALID_MD5: { + code: 400, + message: "Error: Invalid artifact checksum.", + messageId: "SVC4127" + } +#-----------SVC4128--------------------------- + MISSING_ARTIFACT_NAME: { + code: 400, + message: "Error: Invalid content. Missing artifact name.", + messageId: "SVC4128" + } +#-----------SVC4129--------------------------- + MISSING_PROJECT_CODE: { + code: 400, + message: "Error: Invalid Content. Missing PROJECT_CODE number.", + messageId: "SVC4129" + } +#-----------SVC4130--------------------------- + INVALID_PROJECT_CODE: { + code: 400, + message: "Error: Invalid Content. PROJECT_CODE must be from 3 up to 50 characters.", + messageId: "SVC4130" + } +#-----------SVC4131--------------------------- +# %1-resource/service +# %2-srtifact/artifacts +# %3-semicolomn separated list of artifact + COMPONENT_MISSING_MANDATORY_ARTIFACTS: { + code: 403, + message: "Error: Missing mandatory informational %1 %2: [%3].", + messageId: "SVC4131" + } +#-----------SVC4132--------------------------- +# %1 - lifecycle type name + LIFECYCLE_TYPE_ALREADY_EXIST: { + code: 409, + message: "Error: Lifecycle Type with name '%1' already exists.", + messageId: "SVC4132" + } +#-----------SVC4133--------------------------- +# %1 - service version +# %2 - service name + SERVICE_NOT_AVAILABLE_FOR_DISTRIBUTION: { + code: 403, + message: "Error: Version %1 of '%2' service is not available for distribution.", + messageId: "SVC4133" + } +#-----------SVC4134--------------------------- + MISSING_LIFECYCLE_TYPE: { + code: 400, + message: "Error: Invalid Content. Missing interface life-cycle type.", + messageId: "SVC4134" + } +#---------SVC4135------------------------------ + SERVICE_CATEGORY_CANNOT_BE_CHANGED: { + code: 400, + message: "Error: Service category cannot be changed once the service is certified.", + messageId: "SVC4135" + } +#---------SVC4136------------------------------ +# %1 - distribution environment name + DISTRIBUTION_ENVIRONMENT_NOT_AVAILABLE: { + code: 500, + message: "Error: Requested distribution environment '%1' is not available.", + messageId: "SVC4136" + } +#---------SVC4137------------------------------ +# %1 - distribution environment name + DISTRIBUTION_ENVIRONMENT_NOT_FOUND: { + code: 400, + message: "Error: Requested distribution environment '%1' was not found.", + messageId: "SVC4137" + } +#---------SVC4138------------------------------ + DISTRIBUTION_ENVIRONMENT_INVALID: { + code: 400, + message: "Error: Invalid distribution environment.", + messageId: "SVC4138" + } +#---------SVC4139------------------------------ +# %1 - service name + DISTRIBUTION_ARTIFACT_NOT_FOUND: { + code: 409, + message: "Error: Service '%1' cannot be distributed due to missing deployment artifacts.", + messageId: "SVC4139" + } +#---------SVC4200------------------------------ +# %1 - Service/Resource +# %2 - max icon name length + COMPONENT_ICON_EXCEEDS_LIMIT: { + code: 400, + message: "Error: Invalid Content. %1 icon name exceeds limit of %2 characters.", + messageId: "SVC4200" + } +#---------SVC4300------------------------------ + RESTRICTED_ACCESS: { + code: 403, + message: "Error: Restricted access.", + messageId: "SVC4300" + } +#---------SVC4301------------------------------ + RESTRICTED_OPERATION: { + code: 409, + message: "Error: Restricted operation.", + messageId: "SVC4301" + } +#---------SVC4500------------------------------ + MISSING_BODY: { + code: 400 , + message: "Error: Missing request body.", + messageId: "SVC4500" + } +#---------SVC4501------------------------------ + MISSING_PUBLIC_KEY: { + code: 400 , + message: "Error: Invalid Content. Missing mandatory parameter 'apiPublicKey'." , + messageId: "SVC4501" + } +#---------SVC4502------------------------------ + DISTRIBUTION_ENV_DOES_NOT_EXIST: { + code: 400 , + message: "Error: Invalid Body : Missing mandatory parameter 'distrEnvName'." , + messageId: "SVC4502" + } +#-----------SVC4503--------------------------- +# %1 - service name + SERVICE_NOT_FOUND: { + code: 404, + message: "Error: Requested '%1' service was not found.", + messageId: "SVC4503" + } + +#---------SVC4504------------------------------ +# %1 - Service/Resource +# %2 - service/resource version + COMPONENT_VERSION_NOT_FOUND: { + code: 404, + message: "Error: %1 version %2 was not found.", + messageId: "SVC4504" + } +#-----------SVC4505--------------------------- + #%1-artifact name + + ARTIFACT_NOT_FOUND: { + code: 404, + message: "Error: Artifact '%1' was not found.", + messageId: "SVC4505" + } +#---------SVC4506------------------------------ + MISSING_ENV_NAME: { + code: 400 , + message: "Error: Invalid Content. Missing mandatory parameter 'distrEnvName'.", + messageId: "SVC4506" + } +#---------SVC4507------------------------------ + COMPONENT_INVALID_TAGS_NO_COMP_NAME: { + code: 400, + message: "Error: Invalid Content. One of the tags should be the component name.", + messageId: "SVC4507" + } + +#---------SVC4508------------------------------ + SERVICE_NAME_CANNOT_BE_CHANGED: { + code: 400, + message: "Error: Service name cannot be changed once the service is certified.", + messageId: "SVC4508" + } + +#---------SVC4509------------------------------ + SERVICE_ICON_CANNOT_BE_CHANGED: { + code: 400, + message: "Error: Icon cannot be changed once the service is certified.", + messageId: "SVC4509" + } +#---------SVC4510------------------------------ +# %1 - icon name max length + SERVICE_ICON_EXCEEDS_LIMIT: { + code: 400, + message: "Error: Invalid Content. Icon name exceeds limit of %1 characters.", + messageId: "SVC4510" + } +#---------SVC4511------------------------------ + DISTRIBUTION_REQUESTED_NOT_FOUND: { + code: 404, + message: "Error: Requested distribution was not found.", + messageId: "SVC4511" + } +#---------SVC4512------------------------------ +# %1 - Distribution ID + DISTRIBUTION_REQUESTED_FAILED: { + code: 403, + message: "Error: Requested distribution '%1' failed.", + messageId: "SVC4512" + } +#---------SVC4513------------------------------ + RESOURCE_CATEGORY_CANNOT_BE_CHANGED: { + code: 400, + message: "Error: Resource category cannot be changed once the resource is certified.", + messageId: "SVC4513" + } +#---------SVC4514------------------------------ + RESOURCE_NAME_CANNOT_BE_CHANGED: { + code: 400, + message: "Error: Resource name cannot be changed once the resource is certified.", + messageId: "SVC4514" + } +#---------SVC4515------------------------------ + RESOURCE_ICON_CANNOT_BE_CHANGED: { + code: 400, + message: "Error: Icon cannot be changed once the resource is certified.", + messageId: "SVC4515" + } +#---------SVC4516------------------------------ + RESOURCE_VENDOR_NAME_CANNOT_BE_CHANGED: { + code: 400, + message: "Error: Vendor name cannot be changed once the resource is certified.", + messageId: "SVC4516" + } +#---------SVC4517------------------------------ + RESOURCE_DERIVED_FROM_CANNOT_BE_CHANGED: { + code: 400, + message: "Error: Derived from resource template cannot be changed once the resource is certified.", + messageId: "SVC4517" + } +#---------SVC4518------------------------------ +# %1 - max length + COMPONENT_SINGLE_TAG_EXCEED_LIMIT: { + code: 400, + message: "Error: Invalid Content. Single tag exceeds limit of %1 characters.", + messageId: "SVC4518" + } +#---------SVC4519------------------------------ + INVALID_DEFAULT_VALUE: { + code: 400, + message: "Error: mismatch in data-type occurred for property %1. data type is %2 and default value found is %3.", + messageId: "SVC4519" + } +#---------SVC4520------------------------------ +# %1 - service or resource + ADDITIONAL_INFORMATION_MAX_NUMBER_REACHED: { + code: 409, + message: "Error: Maximal number of additional %1 parameters was reached.", + messageId: "SVC4520" + } +#---------SVC4521------------------------------ + ADDITIONAL_INFORMATION_EMPTY_STRING_NOT_ALLOWED: { + code: 400, + message: "Error: Invalid Content. The Additional information label and value cannot be empty.", + messageId: "SVC4521" + } +#---------SVC4522------------------------------ +# %1 - label/value +# %2 - Maximal length of %1 + ADDITIONAL_INFORMATION_EXCEEDS_LIMIT: { + code: 400, + message: "Error: Invalid Content. Additional information %1 exceeds limit of %2 characters.", + messageId: "SVC4522" + } +#---------SVC4523------------------------------ + ADDITIONAL_INFORMATION_KEY_NOT_ALLOWED_CHARACTERS: { + code: 400, + message: 'Error: Invalid Content. Additional information label is not allowed to contain characters like <>:"\/|?* and space characters other than regular space.', + messageId: "SVC4523" + } +#---------SVC4524------------------------------ + ADDITIONAL_INFORMATION_NOT_FOUND: { + code: 409, + message: "Error: Requested additional information was not found.", + messageId: "SVC4524" + } +#---------SVC4525------------------------------ + ADDITIONAL_INFORMATION_VALUE_NOT_ALLOWED_CHARACTERS: { + code: 400, + message: 'Error: Invalid Content. Additional information contains non-english characters.', + messageId: "SVC4525" + } +#---------SVC4526------------------------------ + RESOURCE_INSTANCE_NOT_FOUND: { + code: 404, + message: "Error: Requested '%1' resource instance was not found.", + messageId: "SVC4526" + } +#---------SVC4527------------------------------ + ASDC_VERSION_NOT_FOUND: { + code: 500, + message: 'Error: ASDC version cannot be displayed.', + messageId: "SVC4527" + } +#---------SVC4528------------------------------ +# %1-artifact url/artifact label/artifact description/VNF Service Indicator + MISSING_DATA: { + code: 400, + message: "Error: Invalid content. Missing %1.", + messageId: "SVC4528" + } +#---------SVC4529------------------------------ +# %1-artifact url/artifact label/artifact description/artifact name +# %2 - Maximal length of %1 + EXCEEDS_LIMIT: { + code: 400, + message: "Error: Invalid Content. %1 exceeds limit of %2 characters.", + messageId: "SVC4529" + } +#---------SVC4530------------------------------ + ARTIFACT_INVALID_TIMEOUT: { + code: 400, + message: "Error: Invalid Content. Artifact Timeout should be set to valid positive non-zero number of minutes.", + messageId: "SVC4530" + } +#---------SVC4531------------------------------ + SERVICE_IS_VNF_CANNOT_BE_CHANGED: { + code: 400, + message: "Error: VNF Indicator cannot be updated for certified service.", + messageId: "SVC4531" + } + #---------SVC4532------------------------------ + RESOURCE_INSTANCE_NOT_FOUND_ON_SERVICE: { + code: 404, + message: "Error: Requested '%1' resource instance was not found on the service '%2.", + messageId: "SVC4532" + } + #---------SVC4533------------------------------ + # %1 - "HEAT"/"HEAT_ENV"/"MURANO_PKG"/"YANG_XML" + WRONG_ARTIFACT_FILE_EXTENSION: { + code: 400, + message: "Error: Invalid file extension for %1 artifact type.", + messageId: "SVC4533" + } + +#---------SVC4534------------------------------ +# %1 - "HEAT"/"HEAT_ENV" + INVALID_YAML: { + code: 400, + message: "Error: Uploaded YAML file for %1 artifact is invalid.", + messageId: "SVC4534" + } + +#---------SVC4535------------------------------ +# %1 - "HEAT" + INVALID_DEPLOYMENT_ARTIFACT_HEAT: { + code: 400, + message: "Error: Invalid %1 artifact.", + messageId: "SVC4535" + } +#---------SVC4536------------------------------ +# %1 - "Resource"/"Service" +# %2 - resource/service name +# %3 - "HEAT"/"HEAT_ENV"/"MURANO_PKG" +# %4 - "HEAT"/"HEAT_ENV"/"MURANO_PKG + DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS: { + code: 400, + message: "Error: %1 '%2' already has a deployment artifact of %3 type .Please delete or update an existing %4 artifact.", + messageId: "SVC4536" + } + +#---------SVC4537------------------------------ + MISSING_HEAT: { + code: 400, + message: "Error: Missing HEAT artifact. HEAT_ENV artifact cannot be uploaded without corresponding HEAT template.", + messageId: "SVC4537" + } +#---------SVC4538------------------------------ + MISMATCH_HEAT_VS_HEAT_ENV: { + code: 400, + message: "Error: Invalid artifact content. Parameter's set in HEAT_ENV '%1' artifact doesn't match the parameters in HEAT '%2' artifact.", + messageId: "SVC4538" + } +#---------SVC4539------------------------------ + INVALID_RESOURCE_PAYLOAD: { + code: 400, + message: "Error: Invalid resource payload.", + messageId: "SVC4539" + } +#---------SVC4540------------------------------ + INVALID_TOSCA_FILE_EXTENSION: { + code: 400, + message: "Error: Invalid file extension for TOSCA template.", + messageId: "SVC4540" + } +#---------SVC4541------------------------------ + INVALID_YAML_FILE: { + code: 400, + message: "Error: Invalid YAML file.", + messageId: "SVC4541" + } +#---------SVC4542------------------------------ + INVALID_TOSCA_TEMPLATE: { + code: 400, + message: "Error: Invalid TOSCA template.", + messageId: "SVC4542" + } +#---------SVC4543------------------------------ + NOT_RESOURCE_TOSCA_TEMPLATE: { + code: 400, + message: "Error: Imported Service TOSCA template.", + messageId: "SVC4543" + } +#---------SVC4544------------------------------ + NOT_SINGLE_RESOURCE: { + code: 400, + message: "Error: Imported TOSCA template should contain one resource definition.", + messageId: "SVC4544" + } +#---------SVC4545------------------------------ + INVALID_RESOURCE_NAMESPACE: { + code: 400, + message: "Error: Invalid resource namespace.", + messageId: "SVC4545" + } +#---------SVC4546------------------------------ + RESOURCE_ALREADY_EXISTS: { + code: 400, + message: "Error: Imported resource already exists in ASDC Catalog.", + messageId: "SVC4546" + } +#---------SVC4549------------------------------ + INVALID_RESOURCE_CHECKSUM: { + code: 400, + message: "Error: Invalid resource checksum.", + messageId: "SVC4549" + } +#---------SVC4550------------------------------ + #%1  -  Consumer salt + INVALID_LENGTH: { + code: 400, + message: "Error: Invalid %1 length.", + messageId: "SVC4550" + } + #---------SVC4551------------------------------ + #%1  -  ECOMP User name + ECOMP_USER_NOT_FOUND: { + code: 404, + message: "Error: ECOMP User '%1' was not found.", + messageId: "SVC4551" + } +#---------SVC4552------------------------------ + CONSUMER_ALREADY_EXISTS: { + code: 409, + message: "Error: ECOMP User already exists.", + messageId: "SVC4552" + } +#---------SVC4553----------------------------- + #%1  -  Consumer name / Consumer password/ Consumer salt + INVALID_CONTENT_PARAM: { + code: 400, + message: "Error: %1 is invalid.", + messageId: "SVC4553" + } + #---------SVC4554------------------------------ +# %1 - "Resource"/"Service" + COMPONENT_ARTIFACT_NOT_FOUND: { + code: 404, + message: "Error: Requested artifact doesn't belong to specified %1.", + messageId: "SVC4554" + } +#---------SVC4554------------------------------ +# %1 - "Service name" + SERVICE_DEPLOYMENT_ARTIFACT_NOT_FOUND: { + code: 403, + message: "Error: Requested '%1' service is not ready for certification. Service has to have at least one deployment artifact.", + messageId: "SVC4554" + } +#---------SVC4555------------------------------ +#%1 - "Resource"/"Service"/"Product" +#%2 - "category" + COMPONENT_ELEMENT_INVALID_NAME_LENGTH: { + code: 400, + message: "Error: Invalid %1 %2 name length.", + messageId: "SVC4555" + } +#---------SVC4556------------------------------ +#%1 - "Resource"/"Service"/"Product" +#%2 - "category" + COMPONENT_ELEMENT_INVALID_NAME_FORMAT: { + code: 400, + message: "Error: Invalid %1 %2 name format.", + messageId: "SVC4556" + } +#---------SVC4557------------------------------ +#%1 - "Resource"/"Service"/"Product" +#%2 - "category name" + COMPONENT_CATEGORY_ALREADY_EXISTS: { + code: 409, + message: "Error: %1 category name '%2' already exists.", + messageId: "SVC4557" + } +#---------SVC4558------------------------------ +# %1 - "service"/"VF" +# %2 - "Resource name" + VALIDATED_RESOURCE_NOT_FOUND: { + code: 403, + message: "Error: Submit for Testing is not permitted as your '%1' includes non-validated '%2' resource.", + messageId: "SVC4558" + } +#---------SVC4559------------------------------ +# %1 - "service"/"VF" +# %2 - "Resource name" + FOUND_ALREADY_VALIDATED_RESOURCE: { + code: 403, + message: "Error: Submit for Testing is not permitted as your '%1' includes non-validated '%2' resource. Please use already available validated resource version.", + messageId: "SVC4559" + } +#---------SVC4560------------------------------ +# %1 - "service"/"VF" +# %2 - "Resource name" + FOUND_LIST_VALIDATED_RESOURCES: { + code: 403, + message: "Error: Submit for Testing is not permitted as your '%1' includes non-validated '%2' resource. Please use one of available validated resource versions.", + messageId: "SVC4560" + } +#---------SVC4561------------------------------ +# %1 - "resource"/"product" +# %2 - "category" +# %3 - "category name" + COMPONENT_CATEGORY_NOT_FOUND: { + code: 404, + message: "Error: Requested %1 %2 '%3' was not found.", + messageId: "SVC4561" + } +#---------SVC4562------------------------------ +# %1 - "Resource"/"Product" +# %2 - "sub-category name" +# %3 - "category name" + COMPONENT_SUB_CATEGORY_EXISTS_FOR_CATEGORY: { + code: 409, + message: "Error: %1 sub-category '%2' already exists under '%3' category.", + messageId: "SVC4562" + } +#---------SVC4563------------------------------ +# %1 - "Product" +# %2 - "grouping name" +# %3 - "sub-category name" + COMPONENT_GROUPING_EXISTS_FOR_SUB_CATEGORY: { + code: 409, + message: "Error: %1 grouping '%2' already exists under '%3' sub-category.", + messageId: "SVC4563" + } +#---------SVC4564------------------------------ +# %1 - product name + PRODUCT_NOT_FOUND: { + code: 404, + message: "Error: Requested '%1' product was not found.", + messageId: "SVC4564" + } +#---------SVC4565------------------------------ +# %1 - "HEAT" +# %2 - parameter type ("string" , "boolean" , "number") +# %3 - parameter name + INVALID_HEAT_PARAMETER_VALUE: { + code: 400, + message: "Error: Invalid %1 artifact. Invalid %2 value set for '%3' parameter.", + messageId: "SVC4565" + } +#---------SVC4566------------------------------ +# %1 - "HEAT" +# %2 - parameter type ("string" , "boolean" , "number") + INVALID_HEAT_PARAMETER_TYPE: { + code: 400, + message: "Error: Invalid %1 artifact. Unsupported '%2' parameter type.", + messageId: "SVC4566" + } +#---------SVC4567------------------------------ +# %1 - "YANG_XML" + INVALID_XML: { + code: 400, + message: "Error: Uploaded XML file for %1 artifact is invalid.", + messageId: "SVC4567" + } +#---------SVC4567------------------------------ +# %1 - "User Name and UserId" +# %2 -"checked-out"/"in-certification" + CANNOT_DELETE_USER_WITH_ACTIVE_ELEMENTS: { + code: 409, + message: "Error: User cannot be deleted. User '%1' has %2 projects.", + messageId: "SVC4567" + } +#---------SVC4568------------------------------ +# %1 - "User Name and UserId" +# %2 -"checked-out"/"in-certification" + CANNOT_UPDATE_USER_WITH_ACTIVE_ELEMENTS: { + code: 409, + message: "Error: Role cannot be changed. User '%1' has %2 projects.", + messageId: "SVC4568" + } +#---------SVC4570------------------------------ + UPDATE_USER_ADMIN_CONFLICT: { + code: 409, + message: "Error: An administrator is not allowed to change his/her role.", + messageId: "SVC4570" + } +#---------SVC4571------------------------------ + SERVICE_CANNOT_CONTAIN_SUBCATEGORY: { + code: 400, + message: "Error: Sub category cannot be defined for service", + messageId: "SVC4571" + } +#---------SVC4572------------------------------ +# %1 - "Resource"/"Service" + COMPONENT_TOO_MUCH_CATEGORIES: { + code: 400, + message: "Error: %1 must have only 1 category", + messageId: "SVC4572" + } +#---------SVC4574------------------------------ + RESOURCE_TOO_MUCH_SUBCATEGORIES: { + code: 400, + message: "Error: Resource must have only 1 sub category", + messageId: "SVC4574" + } +#---------SVC4575------------------------------ + COMPONENT_MISSING_SUBCATEGORY: { + code: 400, + message: "Error: Missing sub category", + messageId: "SVC4575" + } + #---------SVC4576------------------------------ +# %1 - "component type" + UNSUPPORTED_ERROR: { + code: 400, + message: "Error : Requested component type %1 is unsupported.", + messageId: "SVC4576" + } + #---------SVC4577------------------------------ +# %1 - "resource type" + RESOURCE_CANNOT_CONTAIN_RESOURCE_INSTANCES: { + code: 409, + message: "Error : Resource of type %1 cannot contain resource instances.", + messageId: "SVC4577" + } +#---------SVC4578------------------------------ +# %1 - "Resource"/"Service" +# %2 - resource/service name +# %3 - "artifact name" + DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS: { + code: 400, + message: "Error: %1 '%2' already has a deployment artifact named '%3'.", + messageId: "SVC4578" + } +#---------SVC4579------------------------------ +# %1 - "Category"/"Sub-Category"/"Group" +# %2 - category/sub-category/grouping name. + INVALID_GROUP_ASSOCIATION: { + code: 400, + message: "Error: Invalid group association. %1 '%2' was not found.", + messageId: "SVC4579" + } +#---------SVC4580------------------------------ + EMPTY_PRODUCT_CONTACTS_LIST: { + code: 400, + message: "Error: Invalid content. At least one Product Contact has to be specified.", + messageId: "SVC4580" + } +#---------SVC4581------------------------------ +# %1 - UserId + INVALID_PRODUCT_CONTACT: { + code: 400, + message: "Error: Invalid content. User '%1' cannot be set as Product Contact.", + messageId: "SVC4581" + } +#---------SVC4582------------------------------ +# %1 - Product +# %2 - "abbreviated"/"full" + MISSING_ONE_OF_COMPONENT_NAMES: { + code: 400, + message: "Error: Invalid content. Missing %1 %2 name.", + messageId: "SVC4582" + } +#---------SVC4583------------------------------ +# %1 - "Icon" +# %2 - "resource"/"service"/"product" + COMPONENT_PARAMETER_CANNOT_BE_CHANGED: { + code: 400, + message: "Error: %1 cannot be changed once the %2 is certified.", + messageId: "SVC4583" + } +#---------SVC4584------------------------------ +# %1 - service/VF name +# %2 - "service" /"VF" +# %3 - resource instance origin type +# %4 - resource instance name +# %5 - requirement/capability +# %6 - requirement/capability name +# %7 - "fulfilled" (for req)/"consumed (for cap)" + REQ_CAP_NOT_SATISFIED_BEFORE_CERTIFICATION: { + code: 403, + message: "Error: Requested '%1' %2 is not ready for certification. %3 '%4' has to have %5 '%6' %7.", + messageId: "SVC4584" + } +#---------SVC4585------------------------------ + INVALID_OCCURRENCES: { + code: 400, + message: "Error: Invalid occurrences format.", + messageId: "SVC4585" + } +#---------SVC4586------------------------------ +#---------SVC4586------------------------------ + INVALID_SERVICE_API_URL: { + code: 400, + message: 'Error: Invalid Service API URL. Please check whether your URL has a valid domain extension and does not contain the following characters - #?&@%+;,=$<>~^`\[]{}|"*!', + messageId: "SVC4586" + } +#---------SVC4587------------------------------ +# %1 - Data type name + DATA_TYPE_ALREADY_EXIST: { + code: 409, + message: 'Error: Data type %1 already exists.', + messageId: "SVC4587" + } +#---------SVC4588------------------------------ +# %1 - Data type name + DATA_TYPE_NOR_PROPERTIES_NEITHER_DERIVED_FROM: { + code: 400, + message: 'Error: Invalid Data type %1. Data type must have either a valid derived from declaration or at least one valid property', + messageId: "SVC4588" + } +#---------SVC4589------------------------------ +# %1 - Data type name + DATA_TYPE_PROPERTIES_CANNOT_BE_EMPTY: { + code: 400, + message: "Error: Invalid Data type %1. 'properties' parameter cannot be empty if provided.", + messageId: "SVC4589" + } +#---------SVC4590------------------------------ +# %1 - Property type name +# %2 - Property name + INVALID_PROPERTY_TYPE: { + code: 400, + message: "Error: Invalid Property type %1 in property %2.", + messageId: "SVC4590" + } +#---------SVC4591------------------------------ +# %1 - Property inner type +# %2 - Property name + INVALID_PROPERTY_INNER_TYPE: { + code: 400, + message: "Error: Invalid property inner type %1, in property %2", + messageId: "SVC4591" + } +#---------SVC4592------------------------------ +# %1 - component instance name +# %2 - "resource instance"/"service instance" + COMPONENT_INSTANCE_NOT_FOUND: { + code: 404, + message: "Error: Requested '%1' %2 was not found.", + messageId: "SVC4592" + } +#---------SVC4593------------------------------ +# %1 - component instance name +# %2 - "resource instance"/"service instance" +# %3 - "resource/"service"/"product" +# %4 - container name + COMPONENT_INSTANCE_NOT_FOUND_ON_CONTAINER: { + code: 404, + message: "Error: Requested '%1' %2 was not found on the %3 '%4'.", + messageId: "SVC4593" + } +#---------SVC4594------------------------------ +#%1 - requirement / capability +#%2 - requirement name + IMPORT_DUPLICATE_REQ_CAP_NAME: { + code: 400, + message: "Error: Imported TOSCA template contains more than one %1 named '%2'.", + messageId: "SVC4594" + } +#---------SVC4595------------------------------ +#%1 - requirement / capability +#%2 - requirement name +#%3 - parent containing the requirement + IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED: { + code: 400, + message: "Error: Imported TOSCA template contains %1 '%2' that is already defined by derived template %3.", + messageId: "SVC4595" + } +#---------SVC4596------------------------------ +# %1 - Data type name + DATA_TYPE_DERIVED_IS_MISSING: { + code: 400, + message: "Error: Invalid Content. The ancestor data type %1 cannot be found in the system.", + messageId: "SVC4596" + } +#---------SVC4597------------------------------ +# %1 - Data type name +# %2 - Property names + DATA_TYPE_PROPERTY_ALREADY_DEFINED_IN_ANCESTOR: { + code: 400, + message: "Error: Invalid Content. The data type %1 contains properties named %2 which are already defined in one of its ancestors.", + messageId: "SVC4597" + } +#---------SVC4598------------------------------ +# %1 - Data type name + DATA_TYPE_DUPLICATE_PROPERTY: { + code: 400, + message: "Error: Invalid Content. The data type %1 contains duplicate property.", + messageId: "SVC4598" + } +#---------SVC4599------------------------------ +# %1 - Data type name +# %2 - Property names + DATA_TYPE_PROEPRTY_CANNOT_HAVE_SAME_TYPE_OF_DATA_TYPE: { + code: 400, + message: "Error: Invalid Content. The data type %1 contains properties %2 which their type is this data type.", + messageId: "SVC4599" + } +#---------SVC4600------------------------------ +# %1 - Data type name + DATA_TYPE_CANNOT_HAVE_PROPERTIES: { + code: 400, + message: "Error: Invalid Content. The data type %1 cannot have properties since it is of type scalar", + messageId: "SVC4600" + } +#---------SVC4601------------------------------ + NOT_TOPOLOGY_TOSCA_TEMPLATE: { + code: 400, + message: "Error: TOSCA yaml file %1 cannot be modeled to VF as it does not contain 'topology_template.", + messageId: "SVC4601" + } +#---------SVC4602-------------------------------- +# %1 - yaml file name +# %2 - node_template label +# %3 - node_template type + INVALID_NODE_TEMPLATE: { + code: 400, + message: "Error: TOSCA yaml file '%1' contains node_template '%2' of type '%3' that does not represent existing VFC/CP/VL", + messageId: "SVC4602" + } +#---------SVC4603------------------------------ +# %1 - component type +# %2 - component name +# %3 - state + ILLEGAL_COMPONENT_STATE: { + code: 403, + message: "Error: Component instance of %1 can not be created because the component '%2' is in an illegal state %3.", + messageId: "SVC4603" + } +#---------SVC4604------------------------------ +# %1 - csar file name + CSAR_INVALID: { + code: 400, + message: "Error: TOSCA CSAR '%1' is invalid. 'TOSCA-Metadata/Tosca.meta' file must be provided.", + messageId: "SVC4604" + } +#---------SVC4605------------------------------ +# %1 - csar file name + CSAR_INVALID_FORMAT: { + code: 400, + message: "Error: TOSCA CSAR '%1' is invalid. Invalid 'TOSCA-Metadata/Tosca.meta' file format.", + messageId: "SVC4605" + } +#---------SVC4606------------------------------ +# %1 - property name +# %2 - property type +# %3 - property innerType +# %4 - default value is + INVALID_COMPLEX_DEFAULT_VALUE: { + code: 400, + message: "Error: Invalid default value of property %1. Data type is %2 with inner type %3 and default value found is %4.", + messageId: "SVC4606" + } +#---------SVC4607------------------------------ +# %1 - csar file name + CSAR_NOT_FOUND: { + code: 400, + message: "Error: TOSCA CSAR '%1' is not found.", + messageId: "SVC4607" + } +#---------SVC4608------------------------------ +# %1 - artifact name +# %2 - component type +# %3 - actual component type + MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE: { + code: 400, + message: "Error: Artifact %1 is only compatible with component of type %2, but component type is %3.", + messageId: "SVC4608" + } + +#---------SVC4609------------------------------ +# %1 - "INVALID_JSON" + INVALID_JSON: { + code: 400, + message: "Error: Uploaded JSON file for %1 artifact is invalid.", + messageId: "SVC4609" + } +#---------SVC4610------------------------------ +# %1 - csar file name +# %2 - missing file name + YAML_NOT_FOUND_IN_CSAR: { + code: 400, + message: "Error - TOSCA CSAR %1 is invalid. TOSCA-Metadata/Tosca.meta refers to file %2 that is not provided.", + messageId: "SVC4610" + } +#---------SVC4611------------------------------ +# %1 - group name + GROUP_MEMBER_EMPTY: { + code: 400, + message: "Error: Invalid Content. Group %1 member list was provided but does not have values", + messageId: "SVC4611" + } +#---------SVC4612------------------------------ +# %1 - group name + GROUP_TYPE_ALREADY_EXIST: { + code: 409, + message: 'Error: Group type %1 already exists.', + messageId: "SVC4612" + } +#---------SVC4613------------------------------ +# %1 - group name +# %2 - VF name(component name) +# %3 - actual component type [VF] + GROUP_ALREADY_EXIST: { + code: 409, + message: "Error: Group with name '%1' already exists in %2 %3.", + messageId: "SVC4613" + } +#---------SVC4614------------------------------ +# %1 - group type + GROUP_TYPE_IS_INVALID: { + code: 400, + message: "Error: Invalid content. Group type %1 does not exist", + messageId: "SVC4614" + } +#---------SVC4615------------------------------ +# %1 - group name + GROUP_MISSING_GROUP_TYPE: { + code: 400, + message: "Error: Invalid Content. Missing Group Type for group '%1'", + messageId: "SVC4615" + } +#---------SVC4616------------------------------ +# %1 - member name +# %2 - group name +# %3 - VF name +# %4 - component type [VF ] + GROUP_INVALID_COMPONENT_INSTANCE: { + code: 400, + message: "Error: Member '%1' listed in group '%2' is not part of '%3' %4.", + messageId: "SVC4616" + } +#---------SVC4617------------------------------ +# %1 - member name +# %2 - group name +# %3 - group type + GROUP_INVALID_TOSCA_NAME_OF_COMPONENT_INSTANCE: { + code: 400, + message: "Error: member %1 listed in group %2 is not part of allowed members of group type %3.", + messageId: "SVC4617" + } +#---------SVC4618------------------------------ +# %1 - missing file name +# %2 - csar file name + ARTIFACT_NOT_FOUND_IN_CSAR: { + code: 400, + message: "Error: artifact %1 is defined in CSAR %2 manifest but is not provided", + messageId: "SVC4618" + } +#---------SVC4619------------------------------ +# %1 - artifact name +# %2 - artifact type +# %3 - existing artifact type + ARTIFACT_ALRADY_EXIST_IN_DIFFERENT_TYPE_IN_CSAR: { + code: 400, + message: "Error: artifact %1 in type %2 already exists in type %3.", + messageId: "SVC4619" + } +#---------SVC4620------------------------------ + FAILED_RETRIVE_ARTIFACTS_TYPES: { + code: 400, + message: "Error: Failed to retrieve list of suported artifact types.", + messageId: "SVC4620" + } +#---------SVC4621------------------------------ +# %1 - artifact name +# %2 - master + ARTIFACT_ALRADY_EXIST_IN_MASTER_IN_CSAR: { + code: 400, + message: "Error: artifact %1 already exists in master %2 .", + messageId: "SVC4621" + } +#---------SVC4622------------------------------ +# %1 - artifact name +# %2 - artifact type +# %3 - master name +# %4 - master type + ARTIFACT_NOT_VALID_IN_MASTER: { + code: 400, + message: "Error: artifact %1 in type %2 can not be exists under master %3 in type %4.", + messageId: "SVC4622" + } +#---------SVC4623------------------------------ +# %1 - artifact name +# %2 - artifact type +# %3 - env name +# %4 - existing env + ARTIFACT_NOT_VALID_ENV: { + code: 400, + message: "Error: Artifact %1 in type %2 with env %3 already exists with another env %4", + messageId: "SVC4623" + } +#---------SVC4624------------------------------ +# %1 - groups names +# %2 - VF name +# %3 - component type [VF ] + GROUP_IS_MISSING: { + code: 400, + message: "Error: Invalid Content. The groups '%1' cannot be found under %2 %3.", + messageId: "SVC4624" + } +#---------SVC4625------------------------------ +# %1 - groups name + GROUP_ARTIFACT_ALREADY_ASSOCIATED: { + code: 400, + message: "Error: Invalid Content. Artifact already associated to group '%1'.", + messageId: "SVC4625" + } +#---------SVC4626------------------------------ +# %1 - groups name + GROUP_ARTIFACT_ALREADY_DISSOCIATED: { + code: 400, + message: "Error: Invalid Content. Artifact already dissociated from group '%1'.", + messageId: "SVC4626" + } +#---------SVC4627------------------------------ +# %1 - property name +# %2 - group name +# %3 - group type name + GROUP_PROPERTY_NOT_FOUND: { + code: 400, + message: "Error: property %1 listed in group %2 is not exist in group type %3.", + messageId: "SVC4627" + } +#---------SVC4628------------------------------ +# %1 - csarUUID +# %2 - VF name + VSP_ALREADY_EXISTS: { + code: 400, + message: "Error: The VSP with UUID %1 was already imported for VF %2. Please select another or update the existing VF.", + messageId: "SVC4628" + } +#---------SVC4629------------------------------ +# %1 - VF name + MISSING_CSAR_UUID: { + code: 400, + message: "Error: The Csar UUID or payload name is missing for VF %1.", + messageId: "SVC4629" + } +#---------SVC4630------------------------------ +# %1 - VF name +# %2 - new csarUUID +# %3 - old csarUUID + RESOURCE_LINKED_TO_DIFFERENT_VSP: { + code: 400, + message: "Error: Resource %1 cannot be updated using CsarUUID %2 since the resource is linked to a different VSP with csarUUID %3.", + messageId: "SVC4630" + } +#---------SVC4631------------------------------ +# %1 - policy name + POLICY_TYPE_ALREADY_EXIST: { + code: 409, + message: "Error: Policy type %1 already exists.", + messageId: "SVC4631" + } +#---------SVC4632------------------------------ +# %1 - target name +# %2 - policy type name + TARGETS_NON_VALID: { + code: 400, + message: "Error: target %1 listed in policy type %2 is not a group or resource.", + messageId: "SVC4632" + } +#---------SVC4633------------------------------ +# %1 - policy name + TARGETS_EMPTY: { + code: 400, + message: "Error: Invalid Content. Policy %1 target list was provided but does not have values", + messageId: "SVC4633" + } +#---------SVC4634------------------------------ + DATA_TYPE_CANNOT_BE_EMPTY: { + code: 500, + message: "Error: Data types are empty. Please import the data types.", + messageId: "SVC4634" + } +#---------SVC4635------------------------------ +# %1 - csar uuid + RESOURCE_FROM_CSAR_NOT_FOUND: { + code: 400, + message: "Error: resource from csar uuid %1 not found", + messageId: "SVC4635" + } +#---------SVC4636------------------------------ +# %1 - Data type name + DATA_TYPE_CANNOT_BE_UPDATED_BAD_REQUEST: { + code: 400, + message: 'Error: Data type %1 cannot be upgraded. The new data type does not contain old properties or the type of one of the properties has been changed.', + messageId: "SVC4636" + } +#-----------SVC4637--------------------------- +#%1 - attribute name + ATTRIBUTE_NOT_FOUND: { + code: 404, + message: "Error: Requested '%1' attribute was not found.", + messageId: "SVC4637" + } +#-----------SVC4638--------------------------- +#%1 - attribute name + ATTRIBUTE_ALREADY_EXIST: { + code: 409, + message: "Error: Attribute with '%1' name already exists.", + messageId: "SVC4638" + } +#-----------SVC4639--------------------------- +#%1 - property name + PROPERTY_NAME_ALREADY_EXISTS: { + code: 409, + message: "Error: Property with '%1' name and different type already exists.", + messageId: "SVC4639" + } +#-----------SVC4640--------------------------- +#%1 - property name + INVALID_PROPERTY: { + code: 409, + message: "Error: Invalid property received.", + messageId: "SVC4640" + } +#---------SVC4641----------------------------- +#%1 - invalid filter +#%2 - valid filters + INVALID_FILTER_KEY: { + code: 400, + message: "Error: The filter %1 is not applicable. Please use one of the following filters: %2", + messageId: "SVC4641" + } +#---------SVC4642----------------------------- +#%1 - asset type +#%2 - filter + NO_ASSETS_FOUND: { + code: 404, + message: "No %1 were found to match criteria %2", + messageId: "SVC4642" + } +#---------SVC4643------------------------------ +# %1 - "Resource"/"Product" +# %2 - "sub-category name" +# %3 - "category name" + COMPONENT_SUB_CATEGORY_NOT_FOUND_FOR_CATEGORY: { + code: 404, + message: "Error: %1 sub-category '%2' not found under category '%3'.", + messageId: "SVC4643" + } +#---------SVC4644------------------------------ +# %1 - Format + CORRUPTED_FORMAT: { + code: 400, + message: "Error: %1 format is corrupted.", + messageId: "SVC4644" + } +#---------SVC4645------------------------------ +# %1 - "groupType" + INVALID_VF_MODULE_TYPE: { + code: 400, + message: "Error: Invalid group type '%1' (should be VfModule).", + messageId: "SVC4645" + } +#---------SVC4646------------------------------ +# %1 - "groupName" + INVALID_VF_MODULE_NAME: { + code: 400, + message: "Error: Invalid Content. VF Module name '%1' contains invalid characters", + messageId: "SVC4646" + } + +#---------SVC4647------------------------------ +# %1 - "modifiedName" + INVALID_VF_MODULE_NAME_MODIFICATION: { + code: 400, + message: "Error: Invalid VF Module name modification, can not modify '%1'", + messageId: "SVC4647" + } +#---------SVC4648------------------------------ +# %1 - "inputId" +# %2 - "componentId" + INPUT_IS_NOT_CHILD_OF_COMPONENT: { + code: 400, + message: "Error: Input id: '%1' is not child of component id: '%2'", + messageId: "SVC4648" + } +#---------SVC4649------------------------------ +# %1 - "groupName" + GROUP_HAS_CYCLIC_DEPENDENCY: { + code: 400, + message: "Error: The group '%1' has cyclic dependency", + messageId: "SVC4649" + } +#---------SVC4650------------------------------ +# %1 - "Component Type" +# %2 - +# %3 - error description + AAI_ARTIFACT_GENERATION_FAILED: { + code: 500, + message: "Error: %1 %2 automatic generation of artifacts failed. Description: %3", + messageId: "SVC4650" + } +#---------SVC4651------------------------------ + PARENT_RESOURCE_DOES_NOT_EXTEND: { + code: 400, + message: "Error: Once resource is certified, derived_from can be changed only to a sibling", + messageId: "SVC4651" + } +#---------SVC4652------------------------------ +# %1 - resource/service + COMPONENT_INVALID_SUBCATEGORY: { + code: 400, + message: "Error: Invalid Content. Invalid %1 sub category.", + messageId: "SVC4652" + } +#---------SVC4653------------------------------ +# %1 - group instance uniqueId +# %2 - service uniqueId + GROUP_INSTANCE_NOT_FOUND_ON_COMPONENT_INSTANCE: { + code: 404, + message: "Error: Requested group instance %1 was not found on component %2.", + messageId: "SVC4653" + } +#---------SVC4654------------------------------ +# %1 - group property name +# %2 - valid min limit value +# %3 - valid max limit value + INVALID_GROUP_MIN_MAX_INSTANCES_PROPERTY_VALUE: { + code: 400, + message: "Error: Value of %1 must be not higher than %2, and not lower than %3.", + messageId: "SVC4654" + } +#---------SVC4655------------------------------ +# %1 - group property name +# %2 - valid min limit value +# %3 - valid max limit value + INVALID_GROUP_INITIAL_COUNT_PROPERTY_VALUE: { + code: 400, + message: "Error: Value of %1 must be between %2 and %3.", + messageId: "SVC4655" + } +#---------SVC4656------------------------------ +# %1 - group property name +# %2 - lower/higher +# %3 - valid max/min value + INVALID_GROUP_PROPERTY_VALUE_LOWER_HIGHER: { + code: 400, + message: "Error: Value of %1 must be %2 or equals to %3.", + messageId: "SVC4656" + } +#---------SVC4657------------------------------ +# %1 - certificationRequest / startTesting + RESOURCE_VFCMT_LIFECYCLE_STATE_NOT_VALID: { + code: 400, + message: "Error - Lifecycle state %1 is not valid for resource of type VFCMT", + messageId: "SVC4657" + } +#---------SVC4658------------------------------ +# %1 – asset type [service / resource ] +# %2 – main asset uuid +# %3 – not found asset type [service / resource] +# %4 – not found asset name + ASSET_NOT_FOUND_DURING_CSAR_CREATION: { + code: 400, + message: "Error: CSAR packaging failed for %1 %2. %3 %4 was not found", + messageId: "SVC4658" + } +#---------SVC4659------------------------------ +# %1 – asset type [service / resource ] +# %2 – main asset uuid +# %3 – Artifact name +# %4 – Artifact uuid + ARTIFACT_PAYLOAD_NOT_FOUND_DURING_CSAR_CREATION: { + code: 400, + message: "Error: CSAR packaging failed for %1 %2. Artifact %3 [%4] was not found", + messageId: "SVC4659" + } +#---------SVC4660------------------------------ +# %1 - assetType +# %2 - matching generic node type name + GENERIC_TYPE_NOT_FOUND: { + code: 404, + message: "Creation of %1 failed. Generic type %2 was not found", + messageId: "SVC4660" + } +#---------SVC4661------------------------------ +# %1 - assetType +# %2 - matching generic node type name + TOSCA_SCHEMA_FILES_NOT_FOUND: { + code: 400, + message: "Error: CSAR packaging failed. TOSCA schema files for SDC-Version: %1 and Conformance-Level %2 were not found", + messageId: "SVC4661" + } +#---------SVC4662------------------------------ +# %1 - file name +# %2 - parser error + TOSCA_PARSE_ERROR: { + code: 400, + message: "Error: Invalid TOSCA template in file %1. %2", + messageId: "SVC4662" + } +#---------SVC4663------------------------------ +# %1 - max length + RESOURCE_VENDOR_MODEL_NUMBER_EXCEEDS_LIMIT: { + code: 400, + message: "Error: Invalid Content. Resource vendor model number exceeds limit of %1 characters.", + messageId: "SVC4663" + } +#---------SVC4664------------------------------ + INVALID_RESOURCE_VENDOR_MODEL_NUMBER: { + code: 400, + message: 'Error: Invalid Content. Resource vendor model number is not allowed to contain characters like <>:"\/|?* and space characters other than regular space.', + messageId: "SVC4664" + } +#---------SVC4665------------------------------ +# %1 - max length + SERVICE_TYPE_EXCEEDS_LIMIT: { + code: 400, + message: "Error: Invalid Content. Service type exceeds limit of %1 characters.", + messageId: "SVC4665" + } +#---------SVC4666------------------------------ + INVALID_SERVICE_TYPE: { + code: 400, + message: 'Error: Invalid Content. Serivce type is not allowed to contain characters like <>:"\/|?* and space characters other than regular space.', + messageId: "SVC4666" + } +#---------SVC4667------------------------------ +# %1 - max length + SERVICE_ROLE_EXCEEDS_LIMIT: { + code: 400, + message: "Error: Invalid Content. Service role exceeds limit of %1 characters.", + messageId: "SVC4667" + } +#---------SVC4668------------------------------ + INVALID_SERVICE_ROLE: { + code: 400, + message: 'Error: Invalid Content. Service role is not allowed to contain characters like <>:"\/|?* and space characters other than regular space.', + messageId: "SVC4668" + } + +#---------SVC4669----------------------------- + INVALID_RESOURCE_TYPE: { + code: 400, + message: "Error: Invalid resource type.", + messageId: "SVC4669" + } +#---------SVC4670------------------------------ + ARTIFACT_NAME_INVALID: { + code: 400, + message: "Error: Artifact name is invalid.", + messageId: "SVC4670" + } +#---------SVC4671------------------------------ +# %1 - VSP name +# %2 - VFC name + CFVC_LOOP_DETECTED: { + code: 400, + message: 'Error: VSP %1 cannot be imported. The VSP contains internal loop in VFC %2', + messageId: "SVC4671" + } +#---------SVC4672------------------------------ +# %1 - capability uniqueId +# %2 - instance uniqueId +# %3 - container uniqueId + COMPONENT_INSTANCE_NOT_FOUND_ON_CONTAINER: { + code: 404, + message: "Error: Requested capability %1 of instance %2 was not found on the container %3.", + messageId: "SVC4672" + } + + +#---------SVC4673------------------------------ + INVALID_SERVICE_STATE: { + code: 409, + message: "Error: Invalid service state. Expected state: %1, actual state: %2", + messageId: "SVC4673" + } + +#---------SVC4674------------------------------ + INVALID_RESPONSE_FROM_PROXY: { + code: 502, + message: "Error: The server was acting as a gateway or proxy and received an invalid response from the upstream server", + messageId: "SVC4674" + } \ No newline at end of file diff --git a/test-apis-ci/src/test/resources/config/test-apis-ci/neo4j-errors-configuration.yaml b/test-apis-ci/src/test/resources/config/test-apis-ci/neo4j-errors-configuration.yaml new file mode 100644 index 0000000000..7a0d6dbfd4 --- /dev/null +++ b/test-apis-ci/src/test/resources/config/test-apis-ci/neo4j-errors-configuration.yaml @@ -0,0 +1,60 @@ +# Errors +errors: + Neo_ClientError_General_ReadOnly: "This is a read only database, writing or modifying the database is not allowed." + Neo_ClientError_LegacyIndex_NoSuchIndex: "The request (directly or indirectly) referred to a index that does not exist." + Neo_ClientError_Request_Invalid: "The client provided an invalid Request." + Neo_ClientError_Request_InvalidFormat: "The client provided a request that was missing required fields, or had values that are not allowed." + Neo_ClientError_Schema_ConstraintAlreadyExists: "Unable to perform operation because it would clash with a pre-existing constraint." + Neo_ClientError_Schema_ConstraintVerificationFailure: "Unable to create constraint because data that exists in the database violates it." + Neo_ClientError_Schema_ConstraintViolation: "A constraint imposed by the database was violated." + Neo_ClientError_Schema_IllegalTokenName: "A token name, such as a label, relationship type or property key, used is not valid. Tokens cannot be empty strings and cannot be null." + Neo_ClientError_Schema_IndexAlreadyExists: "Unable to perform operation because it would clash with a pre-existing index." + Neo_ClientError_Schema_IndexBelongsToConstraint: "A requested operation can not be performed on the specified index because the index is part of a constraint. If you want to drop the index, for instance, you must drop the constraint." + Neo_ClientError_Schema_IndexLimitReached: "The maximum number of index entries supported has been reached, no more entities can be indexed." + Neo_ClientError_Schema_LabelLimitReached: "The maximum number of labels supported has been reached, no more labels can be created." + Neo_ClientError_Schema_NoSuchConstraint: "The request (directly or indirectly) referred to a constraint that does not exist." + Neo_ClientError_Schema_NoSuchIndex: "The request (directly or indirectly) referred to an index that does not exist." + Neo_ClientError_Security_AuthenticationFailed: "The client provided an incorrect username and/or password." + Neo_ClientError_Security_AuthenticationRateLimit: "The client has provided incorrect authentication details too many times in a row." + Neo_ClientError_Security_AuthorizationFailed: "The client does not have privileges to perform the operation requested." + Neo_ClientError_Statement_ArithmeticError: "Invalid use of arithmetic, such as dividing by zero." + Neo_ClientError_Statement_ConstraintViolation: "A constraint imposed by the statement is violated by the data in the database." + Neo_ClientError_Statement_EntityNotFound: "The statement is directly referring to an entity that does not exist." + Neo_ClientError_Statement_InvalidArguments: "The statement is attempting to perform operations using invalid arguments" + Neo_ClientError_Statement_InvalidSemantics: "The statement is syntactically valid, but expresses something that the database cannot do." + Neo_ClientError_Statement_InvalidSyntax: "The statement contains invalid or unsupported syntax." + Neo_ClientError_Statement_InvalidType: "The statement is attempting to perform operations on values with types that are not supported by the operation." + Neo_ClientError_Statement_NoSuchLabel: "The statement is referring to a label that does not exist." + Neo_ClientError_Statement_NoSuchProperty: "The statement is referring to a property that does not exist." + Neo_ClientError_Statement_ParameterMissing: "The statement is referring to a parameter that was not provided in the Request." + Neo_ClientError_Transaction_ConcurrentRequest: "There were concurrent requests accessing the same transaction, which is not allowed." + Neo_ClientError_Transaction_EventHandlerThrewException: "A transaction event handler threw an exception. The transaction will be rolled back." + Neo_ClientError_Transaction_HookFailed: "Transaction hook failure." + Neo_ClientError_Transaction_InvalidType: "The transaction is of the wrong type to service the Request_ For instance, a transaction that has had schema modifications performed in it cannot be used to subsequently perform data operations, and vice versa." + Neo_ClientError_Transaction_MarkedAsFailed: "Transaction was marked as both successful and failed. Failure takes precedence and so this transaction was rolled back although it may have looked like it was going to be committed" + Neo_ClientError_Transaction_UnknownId: "The request referred to a transaction that does not exist." + Neo_ClientError_Transaction_ValidationFailed: "Transaction changes did not pass validation checks" + Neo_DatabaseError_General_CorruptSchemaRule: "A malformed schema rule was encountered. Please contact your support representative." + Neo_DatabaseError_General_FailedIndex: "The request (directly or indirectly) referred to an index that is in a failed state. The index needs to be dropped and recreated manually." + Neo_DatabaseError_General_UnknownFailure: "An unknown failure occurred." + Neo_DatabaseError_Schema_ConstraintCreationFailure: "Creating a requested constraint failed." + Neo_DatabaseError_Schema_ConstraintDropFailure: "The database failed to drop a requested constraint." + Neo_DatabaseError_Schema_IndexCreationFailure: "Failed to create an index." + Neo_DatabaseError_Schema_IndexDropFailure: "The database failed to drop a requested index." + Neo_DatabaseError_Schema_NoSuchLabel: "The request accessed a label that did not exist." + Neo_DatabaseError_Schema_NoSuchPropertyKey: "The request accessed a property that does not exist." + Neo_DatabaseError_Schema_NoSuchRelationshipType: "The request accessed a relationship type that does not exist." + Neo_DatabaseError_Schema_NoSuchSchemaRule: "The request referred to a schema rule that does not exist." + Neo_DatabaseError_Statement_ExecutionFailure: "The database was unable to execute the Statement." + Neo_DatabaseError_Transaction_CouldNotBegin: "The database was unable to start the Transaction." + Neo_DatabaseError_Transaction_CouldNotCommit: "The database was unable to commit the Transaction." + Neo_DatabaseError_Transaction_CouldNotRollback: "The database was unable to roll back the Transaction." + Neo_DatabaseError_Transaction_CouldNotWriteToLog: "The database was unable to write transaction to log." + Neo_DatabaseError_Transaction_ReleaseLocksFailed: "The transaction was unable to release one or more of its locks." + Neo_TransientError_General_DatabaseUnavailable: "The database is not currently available to serve your request, refer to the database logs for more details. Retrying your request at a later time may succeed." + Neo_TransientError_Network_UnknownFailure: "An unknown network failure occurred, a retry may resolve the issue." + Neo_TransientError_Schema_ModifiedConcurrently: "The database schema was modified while this transaction was running, the transaction should be retried." + Neo_TransientError_Security_ModifiedConcurrently: "The user was modified concurrently to this Request." + Neo_TransientError_Statement_ExternalResourceFailure: "The external resource is not available" + Neo_TransientError_Transaction_AcquireLockTimeout: "The transaction was unable to acquire a lock, for instance due to a timeout or the transaction thread being interrupted." + Neo_TransientError_Transaction_DeadlockDetected: "This transaction, and at least one more transaction, has acquired locks in a way that it will wait indefinitely, and the database has aborted it. Retrying this transaction will most likely be successful." \ No newline at end of file diff --git a/test-apis-ci/src/test/resources/config/test-apis-ci/users-configuration.yaml b/test-apis-ci/src/test/resources/config/test-apis-ci/users-configuration.yaml new file mode 100644 index 0000000000..a6c23653f0 --- /dev/null +++ b/test-apis-ci/src/test/resources/config/test-apis-ci/users-configuration.yaml @@ -0,0 +1,2 @@ +userCredentials: + ci: 2a1f887d607d4515d4066fe0f5452a50:0a0dc557c3bf594b1a48030e3e99227580168b21f44e285c69740b8d5b13e33b \ No newline at end of file diff --git a/test-apis-ci/src/test/resources/cucumber/tenantIsolation.feature b/test-apis-ci/src/test/resources/cucumber/tenantIsolation.feature new file mode 100644 index 0000000000..f1a0f6f6e3 --- /dev/null +++ b/test-apis-ci/src/test/resources/cucumber/tenantIsolation.feature @@ -0,0 +1,38 @@ +Feature: Tenant Isolation Feature + + #Get individual external AT&T Certificate API + Scenario Outline: Create operational Envrionment + Given AAI returns and aai_body contains and + When The Number Of Operational Envrinoments that created is and Records are added with data + Then The Number Of Environment is with status + #Verify Succesfull A&AI Call + And Operational Environment record contains tenant field + And Operational Environment record contains workload field + #Verify Succesfull DME Call + And Operational Environment record contains UEB Address field + + Examples: + | retcode | tenant | workload | recordData | numberOfEnvs | recordStatus | isTenantExist | isWorkloadtExist | isUebAddressExist | + | 200 | Test | VNF_Development | {"status": "failed", "last_modified_delta": 0} | 1 | completed | true | true | true | + + Scenario Outline: Distribute To Operational Environment + Given ASDC Address is 127.0.0.1 + And The number of complete environments is + #Start SImulator for each envrionment + And The number of artifacts each Simulator downloads from a service is + #5 (3 days) - run jar + And MSO-WD Simulators Started with topic name MSHITRIT-D2D + And ASDC Contains the following services + # (1.5 days) + And MSO Final Distribution Simulator is UP + #4 (Sends 75 request )(2 days) + When Distribution Requests are Sent By MSO + Then All MSO-WD Simulators Sent The Distribution Complete Notifications + And All Artifacts were downloaded by Simulators + #6 + And MSO Final Distribution Recieved Correct Number Of Request + + Examples: + | numberOfEnvs | numberOfArtifactsDownloaded | ListOfServicesUUID | + #| 5 | 8 | 74e05aac-48d5-4642-8dc1-dc1ddeb5c0f5,fa86100a-409b-4310-835c-e401896181a5,8dbc41cc-2076-49c0-b95b-cb37b1539367,0c7eb2ac-06c0-41e1-b635-825037942e28,840123d1-b9d6-4036-8e94-471b268026bf,74331473-1eb0-4628-84b8-ab47948f7023, 3277af19-d152-4d94-a4d0-44ad6f226b52, e553c12b-b67b-4d66-a6a9-8676d5e0becf, f648052e-3207-4eb2-9336-29f2fe9df618, 535c6ad3-ad2b-429f-ab9b-b654cf647c86,611c764d-8862-4f09-a8e0-1622f8d97ce9, b5df0774-2445-4daf-b893-61c014652145, 01481626-b58a-49b5-ba1e-74eb8508ed15, 9e17345a-d11d-4219-b4e3-e86cfdb51d07, 5ff40fbc-f4e9-45f1-85de-0a04b8a5d60c | + | 2 | 2 | 74e05aac-48d5-4642-8dc1-dc1ddeb5c0f5,fa86100a-409b-4310-835c-e401896181a5 | diff --git a/test-apis-ci/src/test/resources/preferredRouter.txt b/test-apis-ci/src/test/resources/preferredRouter.txt new file mode 100644 index 0000000000..e69de29bb2 -- cgit 1.2.3-korg