From f0d4dd5c846f1c56d8b2641934c028b8151b31b3 Mon Sep 17 00:00:00 2001 From: vasraz Date: Mon, 15 Nov 2021 12:27:54 +0000 Subject: Fix test cases failing incorrectly https://gerrit.onap.org/r/c/sdc/+/124980 Change-Id: I9fbd8a0b5b83d04928feea7624e593b45441ac9b Signed-off-by: Vasyl Razinkov Issue-ID: SDC-3757 --- catalog-be/pom.xml | 2852 ++++++++++---------- .../be/tosca/utils/ForwardingPathToscaUtil.java | 12 +- .../ComponentInstanceForwardingPathMergeTest.java | 51 +- .../be/components/path/BaseForwardingPathTest.java | 72 +- .../path/BaseForwardingPathVersionChangeTest.java | 37 +- .../path/ForwardingPathBusinessLogicTest.java | 68 +- .../path/ForwardingPathChangeVersionTest.java | 2 +- .../path/ForwardingPathDeleteCITest.java | 6 +- .../path/ForwardingPathRenameNodeTest.java | 2 +- .../path/ForwardingPathToscaUtilTest.java | 210 -- .../path/ForwardingPathValidatorTest.java | 98 +- .../tosca/utils/ForwardingPathToscaUtilTest.java | 196 ++ .../src/test/resources/paths/path-context.xml | 112 +- 13 files changed, 1844 insertions(+), 1874 deletions(-) delete mode 100644 catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathToscaUtilTest.java create mode 100644 catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/ForwardingPathToscaUtilTest.java (limited to 'catalog-be') diff --git a/catalog-be/pom.xml b/catalog-be/pom.xml index e3988433a5..97cd8b6df0 100644 --- a/catalog-be/pom.xml +++ b/catalog-be/pom.xml @@ -1,1431 +1,1439 @@ - - 4.0.0 - - catalog-be - war - - - org.openecomp.sdc - sdc-main - 1.10.0-SNAPSHOT - - - - 2.0.0.0 - ${swagger-core-mvn-plugin.version} - 3.25.0 - 3.2.0 - 1.5.3 - - - - - org.openecomp.sdc - togglz-rest-services - ${project.version} - - - com.fasterxml.woodstox - woodstox-core - - - - - - - com.fasterxml.jackson.core - jackson-core - ${jackson.version} - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-core - - - - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-core - - - - - - org.onap.sdc.common - onap-generic-artifact-browser-service - ${project.version} - compile - - - - - io.swagger.core.v3 - swagger-jaxrs2 - ${swagger.version} - - - com.fasterxml.jackson.core - jackson-core - - - - - io.swagger.core.v3 - swagger-annotations - ${swagger.version} - - - - - org.hibernate.validator - hibernate-validator - ${hibernate.validator.version} - - - - org.openecomp.sdc - common-app-api - ${project.version} - - - com.fasterxml.jackson.core - jackson-core - - - - - - javax.ws.rs - javax.ws.rs-api - ${ws.rs.version} - - - - org.openecomp.sdc.be - common-be - ${project.version} - compile - - - org.springframework - spring-core - - - - - org.openecomp.sdc.be - common-be - ${project.version} - test-jar - test - - - org.springframework - spring-core - - - - - org.openecomp.sdc.be - catalog-dao - ${project.version} - - - com.fasterxml.jackson.core - jackson-core - - - - - - org.openecomp.sdc.be - catalog-model - ${project.version} - - - com.fasterxml.jackson.core - jackson-core - - - - - - ch.qos.logback - logback-classic - ${logback.version} - compile - - - - - org.yaml - snakeyaml - ${snakeyaml.version} - compile - - - - - org.apache.commons - commons-jci-core - ${commons-jci-core.version} - compile - - - commons-io - commons-io - - - - - - - com.google.code.gson - gson - ${gson.version} - compile - - - - - org.glassfish.jersey.media - jersey-media-json-jackson - ${jersey-bom.version} - - - com.fasterxml.jackson.core - jackson-core - - - - - - org.glassfish.jersey.containers - jersey-container-servlet-core - ${jersey-bom.version} - compile - - - - org.glassfish.jersey.media - jersey-media-multipart - ${jersey-bom.version} - compile - - - org.glassfish.jersey.ext - jersey-spring4 - ${jersey-bom.version} - - - org.springframework - spring-web - - - org.springframework - spring-beans - - - org.springframework - spring-core - - - org.springframework - spring-aop - - - - org.springframework - spring-context - - - org.hibernate - hibernate-validator - - - - - - - - org.glassfish.hk2.external - asm-all-repackaged - - - - org.glassfish.jersey.ext - jersey-bean-validation - - - org.hibernate - hibernate-validator - - - - - - - org.apache.httpcomponents - httpclient - ${httpclient.version} - compile - - - - org.apache.httpcomponents - httpcore - ${httpcore.version} - compile - - - - commons-logging - commons-logging - ${commons-logging} - compile - - - - commons-codec - commons-codec - ${commons-codec} - compile - - - - - javax.servlet - javax.servlet-api - ${servlet-api.version} - provided - - - - org.eclipse.jgit - org.eclipse.jgit - 3.4.1.201406201815-r - - - - - org.springframework - spring-core - ${spring.version} - compile - - - - org.springframework - spring-context - ${spring.version} - compile - - - org.springframework - spring-expression - - - org.springframework - spring-core - - - - - - org.springframework - spring-web - ${spring.version} - compile - - - org.springframework - spring-core - - - - - - org.springframework - spring-webmvc - ${spring.version} - compile - - - org.springframework - spring-expression - - - org.springframework - spring-core - - - org.springframework - spring-web - - - - - - org.springframework - spring-aop - ${spring.version} - compile - - - org.springframework - spring-core - - - - - - org.springframework - spring-beans - ${spring.version} - compile - - - - org.springframework - spring-expression - ${spring.version} - compile - - - - - org.togglz - togglz-spring-web - ${togglz.version} - - - - org.codehaus.janino - janino - ${janino.version} - compile - - - - org.codehaus.janino - commons-compiler - ${janino.version} - compile - - - - com.google.guava - guava - ${guava.version} - compile - - - - org.janusgraph - janusgraph-core - ${janusgraph.version} - compile - - - gremlin-groovy - org.apache.tinkerpop - - - org.json - json - - - slf4j-log4j12 - org.slf4j - - - commons-collections - commons-collections - - - org.apache.thrift - libthrift - - - commons-io - commons-io - - - commons-codec - commons-codec - - - dom4j - dom4j - - - - - - org.janusgraph - janusgraph-cql - ${janusgraph.version} - compile - - - org.slf4j - slf4j-log4j12 - - - org.json - json - - - commons-collections - commons-collections - - - groovy - org.codehaus.groovy - - - io.netty - netty-all - - - - - - org.apache.commons - commons-lang3 - ${lang3.version} - compile - - - - com.googlecode.json-simple - json-simple - ${json-simple.version} - compile - - - - - - org.functionaljava - functionaljava - ${functionaljava.version} - compile - - - - - com.jcabi - jcabi-aspects - ${jcabi.version} - compile - - - - org.aspectj - aspectjrt - ${aspectjrt.version} - compile - - - - - - com.att.nsa - cambriaClient - 1.2.1-oss - compile - - - com.att.nsa - saClientLibrary - - - - - - org.json - json - 20131018 - compile - - - - - com.datastax.cassandra - cassandra-driver-core - ${cassandra.driver.version} - compile - - - com.datastax.cassandra - cassandra-driver-mapping - ${cassandra.driver.version} - compile - - - - - - org.owasp.esapi - esapi - ${org.owasp.esapi.version} - - - xerces - xercesImpl - - - log4j - log4j - - - commons-fileupload - commons-fileupload - - - org.apache.xmlgraphics - xmlgraphics-commons - - - - - org.onap.portal.sdk - epsdk-fw - ${ecomp.version} - compile - - - com.att.nsa - cambriaClient - - - slf4j-log4j12 - org.slf4j - - - org.onap.aaf.authz - aaf-cadi-aaf - - - aaf-cadi-core - org.onap.aaf.authz - - - commons-codec - commons-codec - - - log4j - log4j - - - - - - - org.eclipse.jetty - jetty-http - ${jetty.version} - compile - - - - org.eclipse.jetty - jetty-proxy - ${jetty.version} - compile - - - org.eclipse.jetty - jetty-http - - - - - - org.eclipse.jetty - jetty-servlets - ${jetty.version} - compile - - - org.eclipse.jetty - jetty-http - - - org.eclipse.jetty - jetty-continuation - - - - - - org.fusesource - sigar - ${sigar.version} - compile - - - log4j - log4j - - - - - org.onap.dmaap.messagerouter.dmaapclient - dmaapClient - 1.1.3 - compile - - - com.att.aft - dme2 - - - com.fasterxml.jackson.core - jackson-core - - - log4j - log4j - - - apache-log4j-extras - log4j - - - - - com.att.aft - dme2 - 3.1.200-oss - - - javax.jms - jms - - - - - - - org.onap.aaf.authz - aaf-cadi-aaf - ${cadi.version} - - - com.datastax.cassandra - cassandra-driver-core - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - - - - - org.assertj - assertj-core - test - - - - org.glassfish.jersey.test-framework.providers - jersey-test-framework-provider-bundle - ${jersey-bom.version} - pom - test - - - org.eclipse.jetty - jetty-server - - - org.eclipse.jetty - jetty-continuation - - - - - - org.glassfish.jersey.core - jersey-client - ${jersey-bom.version} - - - - org.eclipse.jetty - jetty-webapp - ${jetty.version} - test - - - org.eclipse.jetty - jetty-servlet - - - - - - org.hamcrest - hamcrest - ${hamcrest.version} - test - - - - org.hamcrest - hamcrest-library - ${hamcrest.version} - test - - - - org.junit.jupiter - junit-jupiter-api - ${junitJupiter.version} - test - - - - org.junit.jupiter - junit-jupiter - ${junitJupiter.version} - test - - - - org.junit.platform - junit-platform-commons - ${junit.platform.version} - test - - - org.junit.platform - junit-platform-engine - ${junit.platform.version} - test - - - org.mockito - mockito-junit-jupiter - ${mockitoJupiter.version} - test - - - - org.springframework - spring-test - ${spring.version} - test - - - - org.springframework - spring-tx - ${spring.version} - - - org.springframework - spring-core - - - - - - io.cucumber - cucumber-java - ${cucumber.version} - test - - - - io.cucumber - cucumber-junit - ${cucumber.version} - test - - - - org.jmockit - jmockit - ${jmockit.version} - test - - - - com.google.code.bean-matchers - bean-matchers - 0.11 - test - - - - org.codehaus.groovy - groovy - ${groovy.version} - - - - io.netty - netty-handler - - - org.onap.sdc.common - onap-tosca-datatype - ${project.version} - - - com.fasterxml.jackson.core - jackson-core - - - - - org.apache.commons - commons-collections4 - ${commons.collections.version} - - - org.onap.sdc.sdc-be-common - security-util-lib - ${security.util.lib.version} - - - org.springframework.boot - spring-boot-starter-logging - - - - - org.openecomp.sdc.core - openecomp-tosca-lib - ${project.version} - - - com.fasterxml.jackson.core - jackson-core - - - org.springframework - spring-core - - - - - org.onap.vnfsdk.validation - validation-pmdictionary - ${onap.vnfsdk.validation.pmdictionary.version} - - - org.apache.logging.log4j - log4j-slf4j-impl - - - - - - com.googlecode.jmapper-framework - jmapper-core - ${jMapper.version} - - - com.thoughtworks.xstream - xstream - - - - - - - - catalog-be - - - org.apache.maven.plugins - maven-surefire-plugin - - 1C - false - - - - - maven-dependency-plugin - ${maven-dependency-plugin.version} - - - prepare-package - - unpack - - - - - org.webjars - swagger-ui - ${swagger-ui.version} - - - ${project.build.directory}/swagger-ui - - - - - - - com.google.code.maven-replacer-plugin - replacer - ${replacer.plugin.version} - - - prepare-package - - replace - - - - - - ${project.build.directory}/swagger-ui/META-INF/resources/webjars/swagger-ui/${swagger-ui.version}/index.html - - - - https://petstore.swagger.io/v2/swagger.json - /sdc/openapi.json - - - - - - org.apache.maven.plugins - maven-war-plugin - - WEB-INF\lib\slf4j-log4j*.jar, - WEB-INF/classes/elasticsearch.yml, - WEB-INF/classes/portal.properties - - - - ${project.version} - - - true - true - - - true - - - - ${project.build.directory}/swagger-ui/META-INF/resources/webjars/swagger-ui/${swagger-ui.version} - - - **/*.* - - swagger-ui - - - - - - com.github.sylvainlaurent.maven - yaml-json-validator-maven-plugin - - - validate - validate - - validate - - - - - - src/main/resources/**/*.y*ml - src/test/resources/**/*.y*ml - - - - src/test/resources/artifacts/pnfSoftwareInformation/** - - - - - - src/main/resources/**/*.json - src/test/resources/**/*.json - - - - ${skipYamlJsonValidator} - - - - - - com.jcabi - jcabi-maven-plugin - ${jcabi.maven.plugin.version} - - - org.aspectj - aspectjtools - ${aspectj.version} - - - org.aspectj - aspectjweaver - ${aspectj.version} - - - - - - ajc - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - normatives - prepare-package - - single - - - normatives - false - - src/main/assembly/normatives.xml - - - - - - - org.apache.maven.plugins - maven-clean-plugin - - - clean.sdc.backend.folder - clean - - clean - - - - - - sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/files/default - - false - - normatives.tar.gz - - - - - - - - - io.swagger.core.v3 - swagger-maven-plugin - ${swagger-core-mvn-plugin.version} - - - sdce-2-sdce-5 - compile - - resolve - - - sdce-2-sdce-5 - ${project.build.directory}/generated/swagger - swagger-sdce-2-sdce-5 - JSON - - ${project.basedir}/src/main/resources/swagger-config/sdce-2-sdce-5.yaml - - ${swagger.skip} - - - - sdce-4 - compile - - resolve - - - sdce-4 - ${project.build.directory}/generated/swagger - swagger-sdce-4 - JSON - - ${project.basedir}/src/main/resources/swagger-config/sdce-4.yaml - - ${swagger.skip} - - - - sdce-6 - compile - - resolve - - - sdce-6 - ${project.build.directory}/generated/swagger - swagger-sdce-6 - JSON - - ${project.basedir}/src/main/resources/swagger-config/sdce-6.yaml - - ${swagger.skip} - - - - sdce-7 - compile - - resolve - - - sdce-7 - ${project.build.directory}/generated/swagger - swagger-sdce-7 - JSON - - ${project.basedir}/src/main/resources/swagger-config/sdce-7.yaml - - ${swagger.skip} - - - - - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - com.googlecode.maven-download-plugin - download-maven-plugin - [1.2.1,) - - wget - - - - - - - com.jcabi - jcabi-maven-plugin - [0.0,) - - ajc - - - - - - - - - - - - - - - - - - - docker - - false - - + + catalog-be + + + catalog-be + + + + + lifecycle-mapping + + + + + + download-maven-plugin + + wget + + com.googlecode.maven-download-plugin + [1.2.1,) + + + + + + + + + jcabi-maven-plugin + + ajc + + com.jcabi + [0.0,) + + + + + + + org.eclipse.m2e + 1.0.0 + + + + - - org.apache.maven.plugins - maven-resources-plugin - - - copy-normatives - package - - copy-resources - + + maven-surefire-plugin - - sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/files/default - - - - ${project.build.directory} - - normatives.tar.gz - - - + 1C + false - - - copy-sdc-be-py - verify - - copy-resources - + org.apache.maven.plugins + + + + maven-dependency-plugin + + + + + + swagger-ui + org.webjars + ${swagger-ui.version} + + + ${project.build.directory}/swagger-ui + + + unpack + + prepare-package + + + ${maven-dependency-plugin.version} + + + + replacer - - sdc-backend-init/ - - - - - ${project.parent.basedir}/catalog-be/src/main/resources/ - - - scripts/sdcBePy/** - scripts/setup.py - - - + + ${project.build.directory}/swagger-ui/META-INF/resources/webjars/swagger-ui/${swagger-ui.version}/index.html + + + + https://petstore.swagger.io/v2/swagger.json + /sdc/openapi.json + + - - - - - io.fabric8 - docker-maven-plugin - - ${verbose} - ${docker.api.version} - nexus3.onap.org:10001 - - - docker - docker - - - - - - - onap/sdc-backend - sdc-backend - - try - backend - - latest - - ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest - - - ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-${maven.build.timestamp} - - - - backend/backend-files.xml - onap-sdc-backend - - - - - - onap/sdc-backend-init - sdc-backend-init - - try - ${project.basedir}/sdc-backend-init - - - latest - - ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest - - - ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-${maven.build.timestamp} - - - - - - - - - clean-images - pre-clean - - remove - + + + + replace + + prepare-package + + + com.google.code.maven-replacer-plugin + ${replacer.plugin.version} + + + maven-war-plugin - true - onap/sdc-backend,onap/sdc-backend-init + + + true + true + + + ${project.version} + + + true + WEB-INF\lib\slf4j-log4j*.jar, + WEB-INF/classes/elasticsearch.yml, + WEB-INF/classes/portal.properties + + + + + ${project.build.directory}/swagger-ui/META-INF/resources/webjars/swagger-ui/${swagger-ui.version} + + + **/*.* + + swagger-ui + + - - - - generate-images - install - - build - - - - - push-images - deploy - - push - - - onap/sdc-backend,onap/sdc-backend-init - - - - + org.apache.maven.plugins + + + yaml-json-validator-maven-plugin + + + + ${skipYamlJsonValidator} + + + + + src/test/resources/artifacts/pnfSoftwareInformation/** + + + + src/main/resources/**/*.y*ml + src/test/resources/**/*.y*ml + + + + + src/main/resources/**/*.json + src/test/resources/**/*.json + + + + + + validate + + validate + validate + + + com.github.sylvainlaurent.maven + + + jcabi-maven-plugin + + + aspectjtools + org.aspectj + ${aspectj.version} + + + aspectjweaver + org.aspectj + ${aspectj.version} + + + + + + ajc + + + + com.jcabi + ${jcabi.maven.plugin.version} + + + maven-assembly-plugin + + + + false + + src/main/assembly/normatives.xml + + normatives + + + single + + normatives + prepare-package + + + org.apache.maven.plugins + + + maven-clean-plugin + + + + + + + sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/files/default + + false + + normatives.tar.gz + + + + + + clean + + clean.sdc.backend.folder + clean + + + org.apache.maven.plugins + + + swagger-maven-plugin + + + + + ${project.basedir}/src/main/resources/swagger-config/sdce-2-sdce-5.yaml + + sdce-2-sdce-5 + swagger-sdce-2-sdce-5 + JSON + ${project.build.directory}/generated/swagger + ${swagger.skip} + + + resolve + + sdce-2-sdce-5 + compile + + + + + ${project.basedir}/src/main/resources/swagger-config/sdce-4.yaml + + sdce-4 + swagger-sdce-4 + JSON + ${project.build.directory}/generated/swagger + ${swagger.skip} + + + resolve + + sdce-4 + compile + + + + + ${project.basedir}/src/main/resources/swagger-config/sdce-6.yaml + + sdce-6 + swagger-sdce-6 + JSON + ${project.build.directory}/generated/swagger + ${swagger.skip} + + + resolve + + sdce-6 + compile + + + + + ${project.basedir}/src/main/resources/swagger-config/sdce-7.yaml + + sdce-7 + swagger-sdce-7 + JSON + ${project.build.directory}/generated/swagger + ${swagger.skip} + + + resolve + + sdce-7 + compile + + + io.swagger.core.v3 + ${swagger-core-mvn-plugin.version} + - - - + + + + + togglz-rest-services + + + woodstox-core + com.fasterxml.woodstox + + + org.openecomp.sdc + ${project.version} + + + + + jackson-core + com.fasterxml.jackson.core + ${jackson.version} + + + jackson-dataformat-yaml + + + jackson-core + com.fasterxml.jackson.core + + + com.fasterxml.jackson.dataformat + ${jackson.version} + + + + jackson-databind + + + jackson-core + com.fasterxml.jackson.core + + + com.fasterxml.jackson.core + ${jackson.version} + + + + onap-generic-artifact-browser-service + org.onap.sdc.common + compile + ${project.version} + + + + + swagger-jaxrs2 + + + jackson-core + com.fasterxml.jackson.core + + + io.swagger.core.v3 + ${swagger.version} + + + swagger-annotations + io.swagger.core.v3 + ${swagger.version} + + + + + hibernate-validator + org.hibernate.validator + ${hibernate.validator.version} + + + + common-app-api + + + jackson-core + com.fasterxml.jackson.core + + + org.openecomp.sdc + ${project.version} + + + + javax.ws.rs-api + javax.ws.rs + ${ws.rs.version} + + + + common-be + + + spring-core + org.springframework + + + org.openecomp.sdc.be + compile + ${project.version} + + + common-be + + + spring-core + org.springframework + + + org.openecomp.sdc.be + test + test-jar + ${project.version} + + + catalog-dao + + + jackson-core + com.fasterxml.jackson.core + + + org.openecomp.sdc.be + ${project.version} + + + + catalog-model + + + jackson-core + com.fasterxml.jackson.core + + + org.openecomp.sdc.be + ${project.version} + + + + logback-classic + ch.qos.logback + compile + ${logback.version} + + + + + snakeyaml + org.yaml + compile + ${snakeyaml.version} + + + + + commons-jci-core + + + commons-io + commons-io + + + org.apache.commons + compile + ${commons-jci-core.version} + + + + + gson + com.google.code.gson + compile + ${gson.version} + + + + + jersey-media-json-jackson + + + jackson-core + com.fasterxml.jackson.core + + + org.glassfish.jersey.media + ${jersey-bom.version} + + + + jersey-container-servlet-core + org.glassfish.jersey.containers + compile + ${jersey-bom.version} + + + + jersey-media-multipart + org.glassfish.jersey.media + compile + ${jersey-bom.version} + + + jersey-spring4 + + + spring-web + org.springframework + + + spring-beans + org.springframework + + + spring-core + org.springframework + + + spring-aop + org.springframework + + + + spring-context + org.springframework + + + hibernate-validator + org.hibernate + + + org.glassfish.jersey.ext + ${jersey-bom.version} + + + + + + asm-all-repackaged + org.glassfish.hk2.external + + + + jersey-bean-validation + + + hibernate-validator + org.hibernate + + + org.glassfish.jersey.ext + + + + + httpclient + org.apache.httpcomponents + compile + ${httpclient.version} + + + + httpcore + org.apache.httpcomponents + compile + ${httpcore.version} + + + + commons-logging + commons-logging + compile + ${commons-logging} + + + + commons-codec + commons-codec + compile + ${commons-codec} + + + + + javax.servlet-api + javax.servlet + provided + ${servlet-api.version} + + + + org.eclipse.jgit + org.eclipse.jgit + 3.4.1.201406201815-r + + + + + spring-core + org.springframework + compile + ${spring.version} + + + + spring-context + + + spring-expression + org.springframework + + + spring-core + org.springframework + + + org.springframework + compile + ${spring.version} + + + + spring-web + + + spring-core + org.springframework + + + org.springframework + compile + ${spring.version} + + + + spring-webmvc + + + spring-expression + org.springframework + + + spring-core + org.springframework + + + spring-web + org.springframework + + + org.springframework + compile + ${spring.version} + + + + spring-aop + + + spring-core + org.springframework + + + org.springframework + compile + ${spring.version} + + + + spring-beans + org.springframework + compile + ${spring.version} + + + + spring-expression + org.springframework + compile + ${spring.version} + + + + + togglz-spring-web + org.togglz + ${togglz.version} + + + + janino + org.codehaus.janino + compile + ${janino.version} + + + + commons-compiler + org.codehaus.janino + compile + ${janino.version} + + + + guava + com.google.guava + compile + ${guava.version} + + + + janusgraph-core + + + gremlin-groovy + org.apache.tinkerpop + + + json + org.json + + + slf4j-log4j12 + org.slf4j + + + commons-collections + commons-collections + + + libthrift + org.apache.thrift + + + commons-io + commons-io + + + commons-codec + commons-codec + + + dom4j + dom4j + + + org.janusgraph + compile + ${janusgraph.version} + + + + janusgraph-cql + + + slf4j-log4j12 + org.slf4j + + + json + org.json + + + commons-collections + commons-collections + + + groovy + org.codehaus.groovy + + + netty-all + io.netty + + + org.janusgraph + compile + ${janusgraph.version} + + + + commons-lang3 + org.apache.commons + compile + ${lang3.version} + + + + json-simple + com.googlecode.json-simple + compile + ${json-simple.version} + + + + + + functionaljava + org.functionaljava + compile + ${functionaljava.version} + + + + + jcabi-aspects + com.jcabi + compile + ${jcabi.version} + + + + aspectjrt + org.aspectj + compile + ${aspectjrt.version} + + + + + + cambriaClient + + + saClientLibrary + com.att.nsa + + + com.att.nsa + compile + 1.2.1-oss + + + + json + org.json + compile + 20131018 + + + + + cassandra-driver-core + com.datastax.cassandra + compile + ${cassandra.driver.version} + + + cassandra-driver-mapping + com.datastax.cassandra + compile + ${cassandra.driver.version} + + + + + + esapi + + + xercesImpl + xerces + + + log4j + log4j + + + commons-fileupload + commons-fileupload + + + xmlgraphics-commons + org.apache.xmlgraphics + + + xml-apis-ext + xml-apis + + + xml-apis + xml-apis + + + org.owasp.esapi + ${org.owasp.esapi.version} + + + epsdk-fw + + + cambriaClient + com.att.nsa + + + slf4j-log4j12 + org.slf4j + + + aaf-cadi-aaf + org.onap.aaf.authz + + + aaf-cadi-core + org.onap.aaf.authz + + + commons-codec + commons-codec + + + log4j + log4j + + + org.onap.portal.sdk + compile + ${ecomp.version} + + + + + jetty-http + org.eclipse.jetty + compile + ${jetty.version} + + + + jetty-proxy + + + jetty-http + org.eclipse.jetty + + + org.eclipse.jetty + compile + ${jetty.version} + + + + jetty-servlets + + + jetty-http + org.eclipse.jetty + + + jetty-continuation + org.eclipse.jetty + + + org.eclipse.jetty + compile + ${jetty.version} + + + + sigar + + + log4j + log4j + + + org.fusesource + compile + ${sigar.version} + + + dmaapClient + + + dme2 + com.att.aft + + + jackson-core + com.fasterxml.jackson.core + + + log4j + log4j + + + apache-log4j-extras + log4j + + + org.onap.dmaap.messagerouter.dmaapclient + compile + 1.1.3 + + + dme2 + + + jms + javax.jms + + + com.att.aft + 3.1.200-oss + + + + + aaf-cadi-aaf + + + cassandra-driver-core + com.datastax.cassandra + + + slf4j-log4j12 + org.slf4j + + + log4j + log4j + + + org.onap.aaf.authz + ${cadi.version} + + + + + assertj-core + org.assertj + test + + + + jersey-test-framework-provider-bundle + + + jetty-server + org.eclipse.jetty + + + jetty-continuation + org.eclipse.jetty + + + org.glassfish.jersey.test-framework.providers + test + pom + ${jersey-bom.version} + + + + jersey-client + org.glassfish.jersey.core + ${jersey-bom.version} + + + + jetty-webapp + + + jetty-servlet + org.eclipse.jetty + + + org.eclipse.jetty + test + ${jetty.version} + + + + hamcrest + org.hamcrest + test + ${hamcrest.version} + + + + hamcrest-library + org.hamcrest + test + ${hamcrest.version} + + + + junit-jupiter-api + org.junit.jupiter + test + ${junitJupiter.version} + + + + junit-jupiter + org.junit.jupiter + test + ${junitJupiter.version} + + + + junit-platform-commons + org.junit.platform + test + ${junit.platform.version} + + + junit-platform-engine + org.junit.platform + test + ${junit.platform.version} + + + mockito-junit-jupiter + org.mockito + test + ${mockitoJupiter.version} + + + + spring-test + org.springframework + test + ${spring.version} + + + + spring-tx + + + spring-core + org.springframework + + + org.springframework + ${spring.version} + + + + cucumber-java + io.cucumber + test + ${cucumber.version} + + + + cucumber-junit + io.cucumber + test + ${cucumber.version} + + + + jmockit + org.jmockit + test + ${jmockit.version} + + + + bean-matchers + com.google.code.bean-matchers + test + 0.11 + + + + groovy + org.codehaus.groovy + ${groovy.version} + + + + netty-handler + io.netty + + + onap-tosca-datatype + + + jackson-core + com.fasterxml.jackson.core + + + org.onap.sdc.common + ${project.version} + + + commons-collections4 + org.apache.commons + ${commons.collections.version} + + + security-util-lib + + + spring-boot-starter-logging + org.springframework.boot + + + org.onap.sdc.sdc-be-common + ${security.util.lib.version} + + + openecomp-tosca-lib + + + jackson-core + com.fasterxml.jackson.core + + + spring-core + org.springframework + + + org.openecomp.sdc.core + ${project.version} + + + validation-pmdictionary + + + log4j-slf4j-impl + org.apache.logging.log4j + + + org.onap.vnfsdk.validation + ${onap.vnfsdk.validation.pmdictionary.version} + + + + jmapper-core + + + xstream + com.thoughtworks.xstream + + + com.googlecode.jmapper-framework + ${jMapper.version} + + + + + 4.0.0 + + war + + + sdc-main + org.openecomp.sdc + 1.10.0-SNAPSHOT + + + + + + false + + + + + maven-resources-plugin + + + + + sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/files/default + + + + ${project.build.directory} + + normatives.tar.gz + + + + + + copy-resources + + copy-normatives + package + + + + + sdc-backend-init/ + + + + + ${project.parent.basedir}/catalog-be/src/main/resources/ + + + scripts/sdcBePy/** + scripts/setup.py + + + + + + copy-resources + + copy-sdc-be-py + verify + + + org.apache.maven.plugins + + + docker-maven-plugin + + ${docker.api.version} + + + docker + docker + + + + + + + sdc-backend + + + backend/backend-files.xml + onap-sdc-backend + + try + backend + + latest + + ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest + + + ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-${maven.build.timestamp} + + + + onap/sdc-backend + + + + sdc-backend-init + + try + ${project.basedir}/sdc-backend-init + + + latest + + ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest + + + ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-${maven.build.timestamp} + + + + onap/sdc-backend-init + + + nexus3.onap.org:10001 + ${verbose} + + + + + onap/sdc-backend,onap/sdc-backend-init + true + + + remove + + clean-images + pre-clean + + + + + build + + generate-images + install + + + + + onap/sdc-backend,onap/sdc-backend-init + + + push + + push-images + deploy + + + io.fabric8 + + + + docker + + + + + 2.0.0.0 + 3.2.0 + 1.5.3 + 3.25.0 + ${swagger-core-mvn-plugin.version} + diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/ForwardingPathToscaUtil.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/ForwardingPathToscaUtil.java index b668ae7efc..3531fe786b 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/ForwardingPathToscaUtil.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/ForwardingPathToscaUtil.java @@ -28,6 +28,8 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.apache.commons.collections.MapUtils; import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ForwardingPathElementDataDefinition; @@ -40,10 +42,7 @@ import org.openecomp.sdc.be.tosca.CapabilityRequirementConverter; import org.openecomp.sdc.be.tosca.model.ToscaNodeTemplate; import org.openecomp.sdc.be.tosca.model.ToscaTemplateRequirement; -/** - * @author KATYR - * @since November 19, 2017 - */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class ForwardingPathToscaUtil { public static final String FORWARDS_TO_TOSCA_NAME = "org.openecomp.relationships.ForwardsTo"; @@ -97,8 +96,9 @@ public class ForwardingPathToscaUtil { } private static String fetchNodeName(Service service, String nodeId) { - if (service.getComponentInstanceByName(nodeId).isPresent()) { - return service.getComponentInstanceByName(nodeId).get().getName(); + final Optional componentInstanceByName = service.getComponentInstanceByName(nodeId); + if (componentInstanceByName.isPresent()) { + return componentInstanceByName.get().getName(); } else { return ""; } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/path/ComponentInstanceForwardingPathMergeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/path/ComponentInstanceForwardingPathMergeTest.java index 8a575629af..50eaea9ad2 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/path/ComponentInstanceForwardingPathMergeTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/path/ComponentInstanceForwardingPathMergeTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,9 +20,16 @@ package org.openecomp.sdc.be.components.merge.path; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.Mockito.when; + import fj.data.Either; -import org.junit.Before; -import org.junit.Test; +import java.util.Set; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -36,15 +43,6 @@ import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; import org.openecomp.sdc.common.api.UserRoleEnum; -import java.util.Set; - -import static junit.framework.TestCase.assertTrue; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.Mockito.when; - public class ComponentInstanceForwardingPathMergeTest extends BaseForwardingPathVersionChangeTest { @InjectMocks @@ -57,7 +55,7 @@ public class ComponentInstanceForwardingPathMergeTest extends BaseForwardingPath private ToscaOperationFacade toscaOperationFacade; private User user; - @Before + @BeforeEach public void setUpData() { MockitoAnnotations.initMocks(this); user = new User(); @@ -73,7 +71,6 @@ public class ComponentInstanceForwardingPathMergeTest extends BaseForwardingPath Component componentResponseFormatEither = testInstance .mergeDataAfterCreate(user, dataHolder, newNodeAC, "3344"); assertNotNull(componentResponseFormatEither); - assertTrue(componentResponseFormatEither != null); assertEquals(newNodeAC, componentResponseFormatEither); } @@ -102,18 +99,18 @@ public class ComponentInstanceForwardingPathMergeTest extends BaseForwardingPath @Test public void mergeShouldUpdate() { - when(serviceBusinessLogic.updateForwardingPath(any(), any(), any(), anyBoolean())) - .then(invocationOnMock -> service); - when(toscaOperationFacade.getToscaFullElement(any())).thenReturn(Either.left(newNodeAC)); - testInstance.saveDataBeforeMerge(dataHolder, service, nodeACI, newNodeAC); - assertEquals(nodeACI.getName(), dataHolder.getOrigComponentInstId()); - - // Change internal ci, just like change version do - service.getComponentInstances().remove(nodeACI); - service.getComponentInstances().add(newNodeACI); - - Component component = testInstance.mergeDataAfterCreate(user, dataHolder, service, newNodeA); - assertNotNull(component); + when(serviceBusinessLogic.updateForwardingPath(any(), any(), any(), anyBoolean())) + .then(invocationOnMock -> service); + when(toscaOperationFacade.getToscaFullElement(any())).thenReturn(Either.left(newNodeAC)); + testInstance.saveDataBeforeMerge(dataHolder, service, nodeACI, newNodeAC); + assertEquals(nodeACI.getName(), dataHolder.getOrigComponentInstId()); + + // Change internal ci, just like change version do + service.getComponentInstances().remove(nodeACI); + service.getComponentInstances().add(newNodeACI); + + Component component = testInstance.mergeDataAfterCreate(user, dataHolder, service, newNodeA); + assertNotNull(component); } @Test diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathTest.java index 0fa7ca8cb6..e9c1d40121 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,8 +20,8 @@ package org.openecomp.sdc.be.components.path; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -33,13 +33,15 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; -import org.junit.Before; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; import org.openecomp.sdc.be.components.BeConfDependentTest; import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic; import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic; import org.openecomp.sdc.be.components.path.beans.JanusGraphTestSetup; import org.openecomp.sdc.be.components.path.utils.GraphTestUtils; import org.openecomp.sdc.be.components.validation.service.ServiceValidator; +import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao; @@ -63,6 +65,8 @@ import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder; import org.openecomp.sdc.be.tosca.CapabilityRequirementConverter; import org.openecomp.sdc.be.user.Role; import org.openecomp.sdc.common.datastructure.UserContext; +import org.openecomp.sdc.common.impl.ExternalConfiguration; +import org.openecomp.sdc.common.impl.FSConfigurationSource; import org.openecomp.sdc.common.util.ThreadLocalsHolder; import org.openecomp.sdc.common.util.ValidationUtils; import org.openecomp.sdc.exception.ResponseFormat; @@ -70,42 +74,44 @@ import org.springframework.beans.factory.annotation.Autowired; public abstract class BaseForwardingPathTest extends BeConfDependentTest implements ForwardingPathTestUtils { - + static final String FORWARDING_PATH_ID = "forwarding_pathId"; + static final String HTTP_PROTOCOL = "http"; + private static final String CATEGORY_NAME = "cat_name"; + private static final String INSTANTIATION_TYPE = "A-la-carte"; + private static final String CAPABILITY_NAME_1 = "CP1"; + private static final String CAPABILITY_NAME_2 = "CP2"; + private static final String CAPABILITY_NAME_3 = "CP3"; + private static final String CI_NAME_1 = "CI1"; + private static final String CI_NAME_2 = "CI2"; + private static final String CI_NAME_3 = "CI3"; protected User user; - private ForwardingPathDataDefinition forwardingPathDataDefinition; - @Autowired protected JanusGraphClient janusGraphClient; - @Autowired protected CapabilityRequirementConverter capabiltyRequirementConvertor; - @Autowired protected ToscaOperationFacade toscaOperationFacade; - @Autowired protected ServiceBusinessLogic bl; - - private CatalogOperation catalogOperation = mock(CatalogOperation.class); - - private ServiceValidator serviceValidator = mock(ServiceValidator.class); @Autowired protected IElementOperation elementDao; - @Autowired protected ComponentInstanceBusinessLogic componentInstanceBusinessLogic; - @javax.annotation.Resource protected JanusGraphDao janusGraphDao; + private ForwardingPathDataDefinition forwardingPathDataDefinition; + private CatalogOperation catalogOperation = mock(CatalogOperation.class); + private ServiceValidator serviceValidator = mock(ServiceValidator.class); + private CategoryDefinition categoryDefinition; - @Before + @BeforeEach public void initJanusGraph() { JanusGraphTestSetup.createGraph(janusGraphClient.getGraph().left().value()); categoryDefinition = new CategoryDefinition(); categoryDefinition.setName(CATEGORY_NAME); } - @Before + @BeforeEach public void initUser() { // User data and management user = new User(); @@ -115,25 +121,11 @@ public abstract class BaseForwardingPathTest extends BeConfDependentTest impleme user.setRole(Role.ADMIN.name()); Set userRole = new HashSet<>(); userRole.add(user.getRole()); - UserContext userContext = new UserContext(user.getUserId(), userRole, user.getFirstName() ,user.getLastName()); + UserContext userContext = new UserContext(user.getUserId(), userRole, user.getFirstName(), user.getLastName()); ThreadLocalsHolder.setUserContext(userContext); bl.setServiceValidator(serviceValidator); } - - private CategoryDefinition categoryDefinition; - private static final String CATEGORY_NAME = "cat_name"; - static final String FORWARDING_PATH_ID = "forwarding_pathId"; - static final String HTTP_PROTOCOL = "http"; - private static final String INSTANTIATION_TYPE = "A-la-carte"; - private static final String CAPABILITY_NAME_1 = "CP1"; - private static final String CAPABILITY_NAME_2 = "CP2"; - private static final String CAPABILITY_NAME_3 = "CP3"; - private static final String CI_NAME_1 = "CI1"; - private static final String CI_NAME_2 = "CI2"; - private static final String CI_NAME_3 = "CI3"; - - private void initGraph() { Map props = new HashMap<>(); props.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true); @@ -176,7 +168,7 @@ public abstract class BaseForwardingPathTest extends BeConfDependentTest impleme private void createCategory() { Either category = elementDao.createCategory(categoryDefinition, NodeTypeEnum.ServiceNewCategory); - assertTrue("Failed to create category", category.isLeft()); + assertTrue(category.isLeft(), "Failed to create category"); } private void createServiceCategory(String categoryName) { @@ -196,7 +188,7 @@ public abstract class BaseForwardingPathTest extends BeConfDependentTest impleme assertTrue(catRes.isLeft()); } - Service initForwardPath() { + public Service initForwardPath() { ForwardingPathDataDefinition forwardingPathDataDefinition = createMockPath(); Service service = new Service(); service.setUniqueId(FORWARDING_PATH_ID); @@ -213,8 +205,10 @@ public abstract class BaseForwardingPathTest extends BeConfDependentTest impleme forwardingPathDataDefinition.setDestinationPortNumber("414155"); forwardingPathDataDefinition.setProtocol(HTTP_PROTOCOL); org.openecomp.sdc.be.datatypes.elements.ListDataDefinition forwardingPathElementDataDefinitionListDataDefinition = new org.openecomp.sdc.be.datatypes.elements.ListDataDefinition<>(); - forwardingPathElementDataDefinitionListDataDefinition.add(new ForwardingPathElementDataDefinition(CI_NAME_1, CI_NAME_2, CAPABILITY_NAME_1, CAPABILITY_NAME_2, "2222", "5555")); - forwardingPathElementDataDefinitionListDataDefinition.add(new ForwardingPathElementDataDefinition(CI_NAME_2, CI_NAME_3, CAPABILITY_NAME_2, CAPABILITY_NAME_3, "4", "44")); + forwardingPathElementDataDefinitionListDataDefinition.add( + new ForwardingPathElementDataDefinition(CI_NAME_1, CI_NAME_2, CAPABILITY_NAME_1, CAPABILITY_NAME_2, "2222", "5555")); + forwardingPathElementDataDefinitionListDataDefinition.add( + new ForwardingPathElementDataDefinition(CI_NAME_2, CI_NAME_3, CAPABILITY_NAME_2, CAPABILITY_NAME_3, "4", "44")); forwardingPathDataDefinition.setPathElements(forwardingPathElementDataDefinitionListDataDefinition); return forwardingPathDataDefinition; } @@ -222,7 +216,7 @@ public abstract class BaseForwardingPathTest extends BeConfDependentTest impleme Service createService() { Either serviceCreateResult; serviceCreateResult = bl.createService(createTestService(), user); - assertTrue("Failed to create service", serviceCreateResult.isLeft()); + assertTrue(serviceCreateResult.isLeft(), "Failed to create service"); return serviceCreateResult.left().value(); } } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathVersionChangeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathVersionChangeTest.java index 5eca2b35a4..d4d0b9150c 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathVersionChangeTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathVersionChangeTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,7 +21,11 @@ package org.openecomp.sdc.be.components.path; import com.google.common.collect.Lists; -import org.junit.Before; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.junit.jupiter.api.BeforeEach; import org.openecomp.sdc.be.components.merge.instance.DataForMergeHolder; import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ForwardingPathElementDataDefinition; @@ -33,27 +37,22 @@ import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - public abstract class BaseForwardingPathVersionChangeTest { - protected Service service; - protected ComponentInstance nodeACI; - protected ComponentInstance newNodeACI; - protected Component newNodeAC; - protected Component newNodeWithoutCapability; - protected DataForMergeHolder dataHolder; + protected static final String nodeA = "nodeA"; protected static final String NODE_A_FORWARDER_CAPABILITY = "nodeA_FORWARDER_CAPABILITY"; protected static final String nodeB = "nodeB"; protected static final String newNodeA = "newNodeA"; protected static final String fpName = "fpName"; protected static final String FPId = "1122"; + protected Service service; + protected ComponentInstance nodeACI; + protected ComponentInstance newNodeACI; + protected Component newNodeAC; + protected Component newNodeWithoutCapability; + protected DataForMergeHolder dataHolder; - - @Before + @BeforeEach public void initService() { service = new Service(); ForwardingPathDataDefinition forwardingPath = new ForwardingPathDataDefinition(fpName); @@ -64,7 +63,7 @@ public abstract class BaseForwardingPathVersionChangeTest { = new ListDataDefinition<>(); forwardingPathElementListDataDefinition.add( - new ForwardingPathElementDataDefinition(nodeA, nodeB, NODE_A_FORWARDER_CAPABILITY, "nodeBcpType" , "nodeDcpName", + new ForwardingPathElementDataDefinition(nodeA, nodeB, NODE_A_FORWARDER_CAPABILITY, "nodeBcpType", "nodeDcpName", "nodeBcpName")); forwardingPath.setPathElements(forwardingPathElementListDataDefinition); Map forwardingPaths = new HashMap<>(); @@ -75,10 +74,10 @@ public abstract class BaseForwardingPathVersionChangeTest { newNodeACI = new ComponentInstance(); initComponentInstance(newNodeACI, newNodeA); newNodeAC = new Resource(); - newNodeWithoutCapability=new Resource(); + newNodeWithoutCapability = new Resource(); initComponent(newNodeAC, newNodeA); service.setComponentInstances(Lists.newArrayList(newNodeACI)); - initComponentWithoutForwarder(newNodeWithoutCapability,"newNodeC"); + initComponentWithoutForwarder(newNodeWithoutCapability, "newNodeC"); service.setComponentInstances(Lists.newArrayList(nodeACI)); dataHolder = new DataForMergeHolder(); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathBusinessLogicTest.java index 49c25832cc..5f0282b7d6 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathBusinessLogicTest.java @@ -16,49 +16,58 @@ package org.openecomp.sdc.be.components.path; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import com.google.common.collect.Lists; import com.google.common.collect.Sets; import fj.data.Either; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.openecomp.sdc.be.components.impl.exceptions.ComponentException; +import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentFieldsEnum; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.ui.model.UiComponentDataTransfer; import org.openecomp.sdc.be.ui.model.UiServiceDataTransfer; +import org.openecomp.sdc.common.impl.ExternalConfiguration; +import org.openecomp.sdc.common.impl.FSConfigurationSource; import org.openecomp.sdc.exception.ResponseFormat; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = "/paths/path-context.xml") -@Ignore +@SpringJUnitConfig(locations = "classpath:paths/path-context.xml") public class ForwardingPathBusinessLogicTest extends BaseForwardingPathTest { - @Test(expected = ComponentException.class) + @BeforeAll + private static void setup() { + configurationManager = + new ConfigurationManager(new FSConfigurationSource(ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be")); + } + + @Test public void shouldFailToUpdateForwardingPathSincePathDoesNotExist() { - Service service = initForwardPath(); - bl.updateForwardingPath(FORWARDING_PATH_ID, service, user, true); + Assertions.assertThrows(ComponentException.class, () -> { + Service service = initForwardPath(); + bl.updateForwardingPath(FORWARDING_PATH_ID, service, user, true); + }); } - @Test(expected = ComponentException.class) + @Test public void shouldFailToDeleteForwardingPathSincePathDoesNotExist() { - initForwardPath(); - bl.deleteForwardingPaths("delete_forward_test", Sets.newHashSet(FORWARDING_PATH_ID), user, true); + Assertions.assertThrows(ComponentException.class, () -> { + initForwardPath(); + bl.deleteForwardingPaths("delete_forward_test", Sets.newHashSet(FORWARDING_PATH_ID), user, true); + }); } - @Test + @Test public void shouldSucceedCreateAndDeleteForwardingPath() { Service createdService = createService(); Service service = initForwardPath(); @@ -71,7 +80,8 @@ public class ForwardingPathBusinessLogicTest extends BaseForwardingPathTest { String toscaResourceName = forwardingPathsMap.values().iterator().next().getToscaResourceName(); // should return the created path - Either uiResaponse = bl.getComponentDataFilteredByParams(createdService.getUniqueId(), user, Lists.newArrayList(ComponentFieldsEnum.FORWARDING_PATHS.getValue())); + Either uiResaponse = bl.getComponentDataFilteredByParams(createdService.getUniqueId(), user, + Lists.newArrayList(ComponentFieldsEnum.FORWARDING_PATHS.getValue())); assertTrue(uiResaponse.isLeft()); UiServiceDataTransfer uiServiceDataTransfer = (UiServiceDataTransfer) uiResaponse.left().value(); Map forwardingPaths = uiServiceDataTransfer.getForwardingPaths(); @@ -93,7 +103,8 @@ public class ForwardingPathBusinessLogicTest extends BaseForwardingPathTest { assertTrue(serviceResponseFormatEither != null); // make sure changes were applied - uiResaponse = bl.getComponentDataFilteredByParams(createdService.getUniqueId(), user, Lists.newArrayList(ComponentFieldsEnum.FORWARDING_PATHS.getValue())); + uiResaponse = bl.getComponentDataFilteredByParams(createdService.getUniqueId(), user, + Lists.newArrayList(ComponentFieldsEnum.FORWARDING_PATHS.getValue())); assertTrue(uiResaponse.isLeft()); uiServiceDataTransfer = (UiServiceDataTransfer) uiResaponse.left().value(); Map forwardingPathsUpdated = uiServiceDataTransfer.getForwardingPaths(); @@ -107,7 +118,8 @@ public class ForwardingPathBusinessLogicTest extends BaseForwardingPathTest { assertTrue(setResponseFormatEither != null); // nothing to return now - uiResaponse = bl.getComponentDataFilteredByParams(createdService.getUniqueId(), user, Lists.newArrayList(ComponentFieldsEnum.COMPONENT_INSTANCES.getValue(),ComponentFieldsEnum.FORWARDING_PATHS.getValue())); + uiResaponse = bl.getComponentDataFilteredByParams(createdService.getUniqueId(), user, + Lists.newArrayList(ComponentFieldsEnum.COMPONENT_INSTANCES.getValue(), ComponentFieldsEnum.FORWARDING_PATHS.getValue())); assertTrue(uiResaponse.isLeft()); uiServiceDataTransfer = (UiServiceDataTransfer) uiResaponse.left().value(); forwardingPaths = uiServiceDataTransfer.getForwardingPaths(); @@ -115,8 +127,4 @@ public class ForwardingPathBusinessLogicTest extends BaseForwardingPathTest { } - - - } - diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathChangeVersionTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathChangeVersionTest.java index fd305b5f22..deab6ee161 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathChangeVersionTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathChangeVersionTest.java @@ -21,7 +21,7 @@ package org.openecomp.sdc.be.components.path; import org.javatuples.Pair; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; import org.openecomp.sdc.be.impl.ForwardingPathUtils; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathDeleteCITest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathDeleteCITest.java index efef9bd799..55c123f9aa 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathDeleteCITest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathDeleteCITest.java @@ -20,8 +20,8 @@ package org.openecomp.sdc.be.components.path; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ForwardingPathElementDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition; @@ -44,7 +44,7 @@ public class ForwardingPathDeleteCITest { private static final String nodeB = "nodeB"; private static final String fpName = "fpName"; - @Before + @BeforeEach public void initService() { service = new Service(); ForwardingPathDataDefinition forwardingPath = new ForwardingPathDataDefinition(fpName); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathRenameNodeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathRenameNodeTest.java index 886cda05da..1af5c80cd2 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathRenameNodeTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathRenameNodeTest.java @@ -17,7 +17,7 @@ package org.openecomp.sdc.be.components.path; import com.google.common.collect.Sets; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; import org.openecomp.sdc.be.impl.ForwardingPathUtils; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathToscaUtilTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathToscaUtilTest.java deleted file mode 100644 index 1b680fae50..0000000000 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathToscaUtilTest.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright © 2016-2018 European Support Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openecomp.sdc.be.components.path; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; -import org.openecomp.sdc.be.datatypes.elements.ForwardingPathElementDataDefinition; -import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition; -import org.openecomp.sdc.be.model.CapabilityDefinition; -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.tosca.model.ToscaNodeTemplate; -import org.openecomp.sdc.be.tosca.model.ToscaTemplateRequirement; -import org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil.FORWARDER; -import static org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil.FORWARDS_TO_TOSCA_NAME; -import static org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil.PORTS_RANGE; -import static org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil.PROTOCOL; -import static org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil.addForwardingPaths; - -/** - * @author KATYR, ORENK - * @since November 19, 2017 - */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = "/paths/path-context.xml") -@Ignore -public class ForwardingPathToscaUtilTest extends BaseForwardingPathTest { - - private static final String NODE_NAME_1 = "nodeA-name"; - private static final String NODE_NAME_2 = "nodeB-name"; - private static final String PATH_1_PROTOCOL = "protocol-path1"; - private static final String PATH_1_DESC = "path1-desc"; - private static final String PATH_1_PORTS = "8585"; - private static final String PATH_1_NAME = "pathName1"; - private Service service; - private Map originComponents = new HashMap<>(); - private static final String NODE_ID_1 = "nodeA-id"; - private static final String NODE_ID_2 = "nodeB-id"; - private static final String FORWARDING_PATH_TOSCA_TYPE = "org.openecomp.nodes.ForwardingPath"; - - - @Before - public void setUpForwardingPath() { - service = initForwardPath(); - List componentInstances = new ArrayList<>(); - componentInstances.add(generateComponentInstance(NODE_NAME_1, NODE_ID_1)); - componentInstances.add(generateComponentInstance(NODE_NAME_2, NODE_ID_2)); - service.setComponentInstances(componentInstances); - } - - private ComponentInstance generateComponentInstance(String name, String uuid) { - ComponentInstance componentInstance = new ComponentInstance(); - componentInstance.setName(name); - componentInstance.setUniqueId(uuid); - componentInstance.setComponentUid(uuid); - Map> capabiltiesMap = new HashMap<>(); - CapabilityDefinition capabilityDefinition = new CapabilityDefinition(); - capabilityDefinition.setMinOccurrences(Integer.toString(1)); - capabilityDefinition.setMaxOccurrences(Integer.toString(100)); - capabilityDefinition.setType(ForwardingPathToscaUtil.FORWARDS_TO_TOSCA_NAME); - capabilityDefinition.setName(name); - capabilityDefinition.setUniqueId(name); - capabilityDefinition.setPath(Arrays.asList("Just", "something", "to", "read")); - capabiltiesMap.put(capabilityDefinition.getName(), - Collections.singletonList(capabilityDefinition)); - componentInstance.setCapabilities(capabiltiesMap); - Resource resource = new Resource(); - resource.setToscaResourceName("test"); - originComponents.put(uuid, resource); - return componentInstance; - } - - - @Test - public void singleElementPath() { - try { - createPathSingleElement(); - Map nodeTemplatesRes = new HashMap<>(); - - Map expectedNodeTemplatesRes = new HashMap<>(); - ToscaNodeTemplate pathEntry = new ToscaNodeTemplate(); - pathEntry.setType(FORWARDING_PATH_TOSCA_TYPE); - Map expectedProps = new HashMap<>(); - expectedProps.put(PORTS_RANGE, Collections.singletonList(PATH_1_PORTS)); - expectedProps.put(PROTOCOL, PATH_1_PROTOCOL); - pathEntry.setProperties(expectedProps); - List> requirements = new ArrayList<>(); - ToscaTemplateRequirement firstEntryReq = new ToscaTemplateRequirement(); - ToscaTemplateRequirement secondEntryReq = new ToscaTemplateRequirement(); - - firstEntryReq.setCapability("null." + NODE_NAME_1); - secondEntryReq.setCapability("null." + NODE_NAME_2); - - firstEntryReq.setNode(NODE_NAME_1); - secondEntryReq.setNode(NODE_NAME_2); - - firstEntryReq.setRelationship(FORWARDS_TO_TOSCA_NAME); - secondEntryReq.setRelationship(FORWARDS_TO_TOSCA_NAME); - - Map entryMap1 = new HashMap<>(); - Map entryMap2 = new HashMap<>(); - - entryMap1.put(FORWARDER, firstEntryReq); - entryMap2.put(FORWARDER, secondEntryReq); - - requirements.add(entryMap1); - requirements.add(entryMap2); - - pathEntry.setRequirements(requirements); - expectedNodeTemplatesRes.put(PATH_1_NAME, pathEntry); - addForwardingPaths(service, nodeTemplatesRes, capabiltyRequirementConvertor, originComponents, - toscaOperationFacade); - - assertEquals(2, nodeTemplatesRes.get(PATH_1_NAME).getRequirements().size()); - compareToscaPathEntry(expectedNodeTemplatesRes, nodeTemplatesRes); - } catch (Exception e){ - e.printStackTrace(); - Assert.fail(e.getMessage()); - } - } - - private void compareToscaPathEntry(Map expectedNodeTemplatesRes, - Map nodeTemplatesRes) { - final ToscaNodeTemplate expectedTemplate = expectedNodeTemplatesRes.get(PATH_1_NAME); - final ToscaNodeTemplate actualTemplate = nodeTemplatesRes.get(PATH_1_NAME); - assertEquals(expectedTemplate.getProperties(), actualTemplate.getProperties()); - final int size = expectedTemplate.getRequirements().size(); - assertEquals(size, - actualTemplate.getRequirements().size()); - for (int i = 0; i < size; i++) { - compareToscaRequirement(expectedTemplate, actualTemplate, i); - } - } - - private void compareToscaRequirement(ToscaNodeTemplate expectedTemplate, - ToscaNodeTemplate actualTemplate, - int i) { - final ToscaTemplateRequirement actualRequirement = - actualTemplate.getRequirements().get(i).get(FORWARDER); - final ToscaTemplateRequirement expectedToscaRequirement = expectedTemplate - .getRequirements() - .get(i).get(FORWARDER); - assertEquals(actualRequirement.getCapability(), expectedToscaRequirement.getCapability()); - assertEquals(actualRequirement.getNode(), expectedToscaRequirement.getNode()); - } - - private void createPathSingleElement() { - ForwardingPathElementDataDefinition element1 = initElement(NODE_NAME_1, NODE_NAME_2, NODE_NAME_1, - NODE_NAME_2); - - ListDataDefinition list = new ListDataDefinition<>(); - list.add(element1); - - - ForwardingPathDataDefinition path = new ForwardingPathDataDefinition(); - path.setDescription(PATH_1_DESC); - path.setProtocol(PATH_1_PROTOCOL); - path.setDestinationPortNumber(PATH_1_PORTS); - path.setToscaResourceName(FORWARDING_PATH_TOSCA_TYPE); - path.setPathElements(list); - path.setName(PATH_1_NAME); - - Map paths = new HashMap<>(); - paths.put(PATH_1_NAME, path); - - service.setForwardingPaths(paths); - } - - private ForwardingPathElementDataDefinition initElement(String fromId, String toId, String - fromCP, String toCP) { - ForwardingPathElementDataDefinition element = new ForwardingPathElementDataDefinition(); - element.setFromCP(fromCP); - element.setFromNode(fromId); - element.setToCP(toCP); - element.setToNode(toId); - return element; - } -} \ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathValidatorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathValidatorTest.java index 6123561d45..ae44ceac90 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathValidatorTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathValidatorTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,10 +21,16 @@ package org.openecomp.sdc.be.components.path; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + import com.google.common.collect.Sets; import fj.data.Either; -import org.junit.Before; -import org.junit.Test; +import java.util.Collection; +import java.util.Set; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; @@ -42,30 +48,17 @@ import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; import org.openecomp.sdc.exception.ResponseFormat; -import java.util.Collection; -import java.util.Set; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; - public class ForwardingPathValidatorTest implements ForwardingPathTestUtils { + private static final String SERVICE_ID = "serviceid1"; ResponseFormatManager mock; - - private Service service = (Service) getToscaFullElement().left().value(); - - @Mock ToscaOperationFacade toscaOperationFacade; @InjectMocks ForwardingPathValidationUtilTest test = new ForwardingPathValidationUtilTest(); + private Service service = (Service) getToscaFullElement().left().value(); - private static final String SERVICE_ID = "serviceid1"; - - - - - @Before + @BeforeEach public void init() { MockitoAnnotations.initMocks(this); mock = Mockito.mock(ResponseFormatManager.class); @@ -78,60 +71,65 @@ public class ForwardingPathValidatorTest implements ForwardingPathTestUtils { } @Test - public void testValidForwardingPathName(){ + public void testValidForwardingPathName() { Collection paths = createData("pathName", "http", "8285", "pathName"); test.validateForwardingPaths(paths, SERVICE_ID, false); } - @Test(expected = ComponentException.class) - public void testEmptyForwardingPathName(){ - Collection paths = createData("", "protocol", "8285", "name1"); - test.validateForwardingPaths(paths, SERVICE_ID, false); + @Test + public void testEmptyForwardingPathName() { + Assertions.assertThrows(ComponentException.class, () -> { + Collection paths = createData("", "protocol", "8285", "name1"); + test.validateForwardingPaths(paths, SERVICE_ID, false); + }); } - @Test(expected = ComponentException.class) - public void testLongForwardingPathName(){ - String pathName = "Failed to execute goal on project catalog-be: Could not resolve dependencies for project \n" + + @Test + public void testLongForwardingPathName() { + Assertions.assertThrows(ComponentException.class, () -> { + String pathName = "Failed to execute goal on project catalog-be: Could not resolve dependencies for project \n" + "org.openecomp.sdc:catalog-be:war:1.1.0-SNAPSHOT: Failed to collect dependencies at \n" + "org.openecomp.sdc.common:openecomp-sdc-artifact-generator-api:jar:1802.0.1.167: "; - Collection paths = createData(pathName, + Collection paths = createData(pathName, "http", "port", "name1"); - test.validateForwardingPaths(paths, SERVICE_ID, false); - + test.validateForwardingPaths(paths, SERVICE_ID, false); + }); } @Test - public void testUniqueForwardingPathNameUpdateName(){ + public void testUniqueForwardingPathNameUpdateName() { Collection paths = createData("pathName4", "httpfd", "82df85", "name1"); test.validateForwardingPaths(paths, SERVICE_ID, true); } @Test - public void testUniqueForwardingPathNameUpdatePort(){ + public void testUniqueForwardingPathNameUpdatePort() { Collection paths = createData("pathName3", "httpfd", "82df85", "name1"); test.validateForwardingPaths(paths, SERVICE_ID, true); } - @Test(expected = ComponentException.class) - public void testLongForwardingPathPortNumber(){ - String port = "Failed to execute goal on project catalog-be: Could not resolve dependencies for project \n" + + @Test + public void testLongForwardingPathPortNumber() { + Assertions.assertThrows(ComponentException.class, () -> { + String port = "Failed to execute goal on project catalog-be: Could not resolve dependencies for project \n" + "org.openecomp.sdc:catalog-be:war:1.1.0-SNAPSHOT: Failed to collect dependencies at \n" + "org.openecomp.sdc.common:openecomp-sdc-artifact-generator-api:jar:1802.0.1.167: "; - Collection paths = createData("pathName", + Collection paths = createData("pathName", "http", port, "name1"); - test.validateForwardingPaths(paths, SERVICE_ID, false); - + test.validateForwardingPaths(paths, SERVICE_ID, false); + }); } - @Test(expected = ComponentException.class) - public void testLongForwardingPathProtocol(){ - String protocol = "Failed to execute goal on project catalog-be: Could not resolve dependencies for project \n" + + @Test + public void testLongForwardingPathProtocol() { + Assertions.assertThrows(ComponentException.class, () -> { + String protocol = "Failed to execute goal on project catalog-be: Could not resolve dependencies for project \n" + "org.openecomp.sdc:catalog-be:war:1.1.0-SNAPSHOT: Failed to collect dependencies at \n" + "org.openecomp.sdc.common:openecomp-sdc-artifact-generator-api:jar:1802.0.1.167: "; - Collection paths = createData("pathName", + Collection paths = createData("pathName", protocol, "port", "name1"); - test.validateForwardingPaths(paths, SERVICE_ID, false); - + test.validateForwardingPaths(paths, SERVICE_ID, false); + }); } private Set createData(String pathName, String protocol, String ports, String uniqueId) { @@ -140,15 +138,15 @@ public class ForwardingPathValidatorTest implements ForwardingPathTestUtils { } - private Either getToscaFullElement() { + private Either getToscaFullElement() { return Either.left((T) setUpServiceMcok()); } - private Service setUpServiceMcok(){ - Service service = new Service(); - service.addForwardingPath(createPath("pathName3", "http", "8285", "name1")); - return service; + private Service setUpServiceMcok() { + Service service = new Service(); + service.addForwardingPath(createPath("pathName3", "http", "8285", "name1")); + return service; } private class ForwardingPathValidationUtilTest extends ForwardingPathValidator { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/ForwardingPathToscaUtilTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/ForwardingPathToscaUtilTest.java new file mode 100644 index 0000000000..3b8089e858 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/ForwardingPathToscaUtilTest.java @@ -0,0 +1,196 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.sdc.be.tosca.utils; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil.FORWARDER; +import static org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil.FORWARDS_TO_TOSCA_NAME; +import static org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil.PORTS_RANGE; +import static org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil.PROTOCOL; +import static org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil.addForwardingPaths; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.openecomp.sdc.be.components.path.BaseForwardingPathTest; +import org.openecomp.sdc.be.config.ConfigurationManager; +import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.ForwardingPathElementDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition; +import org.openecomp.sdc.be.model.CapabilityDefinition; +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.tosca.model.ToscaNodeTemplate; +import org.openecomp.sdc.be.tosca.model.ToscaTemplateRequirement; +import org.openecomp.sdc.common.impl.ExternalConfiguration; +import org.openecomp.sdc.common.impl.FSConfigurationSource; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; + +@SpringJUnitConfig(locations = "classpath:paths/path-context.xml") +public class ForwardingPathToscaUtilTest extends BaseForwardingPathTest { + + private static final String NODE_NAME_1 = "nodeA-name"; + private static final String NODE_NAME_2 = "nodeB-name"; + private static final String PATH_1_PROTOCOL = "protocol-path1"; + private static final String PATH_1_DESC = "path1-desc"; + private static final String PATH_1_PORTS = "8585"; + private static final String PATH_1_NAME = "pathName1"; + private static final String NODE_ID_1 = "nodeA-id"; + private static final String NODE_ID_2 = "nodeB-id"; + private static final String FORWARDING_PATH_TOSCA_TYPE = "org.openecomp.nodes.ForwardingPath"; + private Service service; + private Map originComponents = new HashMap<>(); + + @BeforeAll + private static void setup() { + configurationManager = + new ConfigurationManager(new FSConfigurationSource(ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be")); + } + + @BeforeEach + public void setUpForwardingPath() { + service = initForwardPath(); + List componentInstances = new ArrayList<>(); + componentInstances.add(generateComponentInstance(NODE_NAME_1, NODE_ID_1)); + componentInstances.add(generateComponentInstance(NODE_NAME_2, NODE_ID_2)); + service.setComponentInstances(componentInstances); + } + + private ComponentInstance generateComponentInstance(String name, String uuid) { + ComponentInstance componentInstance = new ComponentInstance(); + componentInstance.setName(name); + componentInstance.setUniqueId(uuid); + componentInstance.setComponentUid(uuid); + Map> capabiltiesMap = new HashMap<>(); + CapabilityDefinition capabilityDefinition = new CapabilityDefinition(); + capabilityDefinition.setMinOccurrences(Integer.toString(1)); + capabilityDefinition.setMaxOccurrences(Integer.toString(100)); + capabilityDefinition.setType(ForwardingPathToscaUtil.FORWARDS_TO_TOSCA_NAME); + capabilityDefinition.setName(name); + capabilityDefinition.setUniqueId(name); + capabilityDefinition.setPath(Arrays.asList("Just", "something", "to", "read")); + capabiltiesMap.put(capabilityDefinition.getName(), Collections.singletonList(capabilityDefinition)); + componentInstance.setCapabilities(capabiltiesMap); + Resource resource = new Resource(); + resource.setToscaResourceName("test"); + originComponents.put(uuid, resource); + return componentInstance; + } + + @Test + public void singleElementPath() { + Assertions.assertDoesNotThrow(() -> { + createPathSingleElement(); + Map nodeTemplatesRes = new HashMap<>(); + + Map expectedNodeTemplatesRes = new HashMap<>(); + ToscaNodeTemplate pathEntry = new ToscaNodeTemplate(); + pathEntry.setType(FORWARDING_PATH_TOSCA_TYPE); + Map expectedProps = new HashMap<>(); + expectedProps.put(PORTS_RANGE, Collections.singletonList(PATH_1_PORTS)); + expectedProps.put(PROTOCOL, PATH_1_PROTOCOL); + pathEntry.setProperties(expectedProps); + List> requirements = new ArrayList<>(); + ToscaTemplateRequirement firstEntryReq = new ToscaTemplateRequirement(); + ToscaTemplateRequirement secondEntryReq = new ToscaTemplateRequirement(); + + firstEntryReq.setCapability("null." + NODE_NAME_1); + secondEntryReq.setCapability("null." + NODE_NAME_2); + + firstEntryReq.setNode(NODE_NAME_1); + secondEntryReq.setNode(NODE_NAME_2); + + firstEntryReq.setRelationship(FORWARDS_TO_TOSCA_NAME); + secondEntryReq.setRelationship(FORWARDS_TO_TOSCA_NAME); + + Map entryMap1 = new HashMap<>(); + Map entryMap2 = new HashMap<>(); + + entryMap1.put(FORWARDER, firstEntryReq); + entryMap2.put(FORWARDER, secondEntryReq); + + requirements.add(entryMap1); + requirements.add(entryMap2); + + pathEntry.setRequirements(requirements); + expectedNodeTemplatesRes.put(PATH_1_NAME, pathEntry); + addForwardingPaths(service, nodeTemplatesRes, capabiltyRequirementConvertor, originComponents, toscaOperationFacade); + + assertEquals(2, nodeTemplatesRes.get(PATH_1_NAME).getRequirements().size()); + compareToscaPathEntry(expectedNodeTemplatesRes, nodeTemplatesRes); + }); + } + + private void compareToscaPathEntry(Map expectedNodeTemplatesRes, + Map nodeTemplatesRes) { + final ToscaNodeTemplate expectedTemplate = expectedNodeTemplatesRes.get(PATH_1_NAME); + final ToscaNodeTemplate actualTemplate = nodeTemplatesRes.get(PATH_1_NAME); + assertEquals(expectedTemplate.getProperties(), actualTemplate.getProperties()); + final int size = expectedTemplate.getRequirements().size(); + assertEquals(size, actualTemplate.getRequirements().size()); + for (int i = 0; i < size; i++) { + compareToscaRequirement(expectedTemplate, actualTemplate, i); + } + } + + private void compareToscaRequirement(ToscaNodeTemplate expectedTemplate, + ToscaNodeTemplate actualTemplate, + int i) { + final ToscaTemplateRequirement actualRequirement = actualTemplate.getRequirements().get(i).get(FORWARDER); + final ToscaTemplateRequirement expectedToscaRequirement = expectedTemplate.getRequirements().get(i).get(FORWARDER); + assertEquals(actualRequirement.getCapability(), expectedToscaRequirement.getCapability()); + assertEquals(actualRequirement.getNode(), expectedToscaRequirement.getNode()); + } + + private void createPathSingleElement() { + ForwardingPathElementDataDefinition element1 = initElement(NODE_NAME_1, NODE_NAME_2, NODE_NAME_1, NODE_NAME_2); + + ListDataDefinition list = new ListDataDefinition<>(); + list.add(element1); + + ForwardingPathDataDefinition path = new ForwardingPathDataDefinition(); + path.setDescription(PATH_1_DESC); + path.setProtocol(PATH_1_PROTOCOL); + path.setDestinationPortNumber(PATH_1_PORTS); + path.setToscaResourceName(FORWARDING_PATH_TOSCA_TYPE); + path.setPathElements(list); + path.setName(PATH_1_NAME); + + Map paths = new HashMap<>(); + paths.put(PATH_1_NAME, path); + + service.setForwardingPaths(paths); + } + + private ForwardingPathElementDataDefinition initElement(String fromId, String toId, String fromCP, String toCP) { + ForwardingPathElementDataDefinition element = new ForwardingPathElementDataDefinition(); + element.setFromCP(fromCP); + element.setFromNode(fromId); + element.setToCP(toCP); + element.setToNode(toId); + return element; + } +} diff --git a/catalog-be/src/test/resources/paths/path-context.xml b/catalog-be/src/test/resources/paths/path-context.xml index 752e4ecf13..53e8b8c74b 100644 --- a/catalog-be/src/test/resources/paths/path-context.xml +++ b/catalog-be/src/test/resources/paths/path-context.xml @@ -20,87 +20,67 @@ limitations under the License. Modifications copyright (c) 2018 Nokia ================================================================================ --> - - - + + + + + + + + + + + + + + + + + + + - + org.openecomp.sdc.be.impl, + org.openecomp.sdc.be.tosca, + org.openecomp.sdc.be.dao.impl"> - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit 1.2.3-korg