From: vasraz Date: Mon, 15 Nov 2021 12:27:54 +0000 (+0000) Subject: Fix test cases failing incorrectly X-Git-Tag: 1.10.0~31 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=f0d4dd5c846f1c56d8b2641934c028b8151b31b3;p=sdc.git 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 --- 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"> - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/JanusGraphGenericDaoTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/JanusGraphGenericDaoTest.java index 09ab6a1745..549841c6cb 100644 --- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/JanusGraphGenericDaoTest.java +++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/JanusGraphGenericDaoTest.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,23 +20,30 @@ package org.openecomp.sdc.be.resources; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import com.google.gson.Gson; -import org.janusgraph.core.PropertyKey; -import org.janusgraph.core.JanusGraphEdge; -import org.janusgraph.core.JanusGraphFactory; -import org.janusgraph.core.JanusGraph; -import org.janusgraph.core.JanusGraphVertex; -import org.janusgraph.core.attribute.Text; -import org.janusgraph.core.schema.JanusGraphManagement; import fj.data.Either; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import javax.annotation.Resource; import org.apache.commons.configuration.BaseConfiguration; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.Edge; import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.janusgraph.core.JanusGraph; +import org.janusgraph.core.JanusGraphEdge; +import org.janusgraph.core.JanusGraphFactory; +import org.janusgraph.core.JanusGraphVertex; +import org.janusgraph.core.PropertyKey; +import org.janusgraph.core.attribute.Text; +import org.janusgraph.core.schema.JanusGraphManagement; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; @@ -45,586 +52,580 @@ import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; import org.openecomp.sdc.be.dao.utils.UserStatusEnum; import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; -import org.openecomp.sdc.be.resources.data.*; +import org.openecomp.sdc.be.resources.data.AdditionalInfoParameterData; +import org.openecomp.sdc.be.resources.data.ArtifactData; +import org.openecomp.sdc.be.resources.data.ComponentInstanceData; +import org.openecomp.sdc.be.resources.data.GraphNodeLock; +import org.openecomp.sdc.be.resources.data.ResourceMetadataData; +import org.openecomp.sdc.be.resources.data.UserData; import org.openecomp.sdc.common.api.ConfigurationSource; import org.openecomp.sdc.common.api.UserRoleEnum; import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.test.context.support.DirtiesContextTestExecutionListener; import org.springframework.test.context.transaction.TransactionalTestExecutionListener; -import javax.annotation.Resource; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration("classpath:application-context-test.xml") -@TestExecutionListeners(listeners = { DependencyInjectionTestExecutionListener.class, - DirtiesContextTestExecutionListener.class, TransactionalTestExecutionListener.class }) +@SpringJUnitConfig(locations = "classpath:application-context-test.xml") +@TestExecutionListeners(listeners = {DependencyInjectionTestExecutionListener.class, + DirtiesContextTestExecutionListener.class, TransactionalTestExecutionListener.class}) public class JanusGraphGenericDaoTest { - private static Logger log = LoggerFactory.getLogger(JanusGraphGenericDaoTest.class.getName()); - private static ConfigurationManager configurationManager; - - @Resource(name = "janusgraph-generic-dao") - private JanusGraphGenericDao janusGraphDao; - - @BeforeClass - public static void setupBeforeClass() { - ExternalConfiguration.setAppName("catalog-dao"); - String appConfigDir = "src/test/resources/config/catalog-dao"; - ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), - appConfigDir); - configurationManager = new ConfigurationManager(configurationSource); - configurationManager.getConfiguration().setJanusGraphCfgFile("../catalog-be/src/main/resources/config/janusgraph.properties"); - configurationManager.getConfiguration().setJanusGraphInMemoryGraph(true); - } - - // @Test - public void testcheckEdgeProps() { - JanusGraph graph = janusGraphDao.getGraph().left().value(); - JanusGraphVertex v1 = graph.addVertex(); - v1.property("prop1", 123); - JanusGraphVertex v2 = graph.addVertex(); - v2.property("prop1", 456); - JanusGraphEdge addEdge = v1.addEdge("label11", v2); - addEdge.property("edgeProp", "my prop edge"); - graph.tx().commit(); - - Either v11 = janusGraphDao.getVertexByProperty("prop1", 123); - Iterator edges = v11.left().value().edges(Direction.OUT, "label11"); - Edge edge = edges.next(); - // String value = (String)edge.value("edgeProp"); - String value = (String) janusGraphDao.getProperty(edge, "edgeProp"); - log.debug(value); - - } - - @Test - public void testCrudNode() { - - String id = "userId12345abc"; - UserData userData = new UserData("Myname123", "Mylastname", id, "email123", "Tester", - UserStatusEnum.ACTIVE.name(), null); - - Either newNode = janusGraphDao.createNode(userData, UserData.class); - - assertTrue(newNode.isLeft()); - - log.debug("{}", newNode.left().value()); - - janusGraphDao.commit(); - - ImmutablePair keyValueId = userData.getKeyValueId(); - Either node = janusGraphDao.getNode(keyValueId.getKey(), keyValueId.getValue(), - UserData.class); - janusGraphDao.commit(); - assertTrue(node.isLeft()); - log.debug("{}", node.left().value()); - - userData.setRole("Designer"); - node = janusGraphDao.updateNode(userData, UserData.class); - assertTrue(node.isLeft()); - log.debug("{}", node.left().value()); - assertEquals(null, "Designer", node.left().value().getRole()); - janusGraphDao.commit(); - - node = janusGraphDao.deleteNode(userData, UserData.class); - assertTrue(node.isLeft()); - log.debug("{}", node.left().value()); - janusGraphDao.commit(); - - node = janusGraphDao.getNode(keyValueId.getKey(), keyValueId.getValue(), UserData.class); - assertTrue(node.isRight()); - log.debug("{}", node.right().value()); - - } - - @Test - public void testGetByCategoryAndAll() { - - // create 2 nodes - String id = "userId12345abc"; - UserData userData1 = new UserData("Myname123", "Mylastname", id, "email123", "Tester", - UserStatusEnum.ACTIVE.name(), null); - - Either node1 = janusGraphDao.createNode(userData1, UserData.class); - assertTrue(node1.isLeft()); - log.debug("{}", node1.left().value()); - - id = "userIddfkoer45abc"; - UserData userData2 = new UserData("Mynadyhme123", "Mylasghtname", id, "emaighdl123", "Designer", - UserStatusEnum.ACTIVE.name(), null); - Either node2 = janusGraphDao.createNode(userData2, UserData.class); - assertTrue(node2.isLeft()); - log.debug("{}", node2.left().value()); - - janusGraphDao.commit(); - - ImmutablePair keyValueId1 = userData1.getKeyValueId(); - // get first node - Either node = janusGraphDao.getNode(keyValueId1.getKey(), keyValueId1.getValue(), - UserData.class); - assertTrue(node.isLeft()); - log.debug("{}", node.left().value()); - janusGraphDao.commit(); - - // get all must be 2 + 1 default user = 3 - Either, JanusGraphOperationStatus> all = janusGraphDao.getAll(NodeTypeEnum.User, UserData.class); - assertTrue(all.isLeft()); - assertTrue(all.left().value().size() > 0); - - log.debug("{}", all.left().value()); - - Map props = new HashMap<>(); - - props.put(keyValueId1.getKey(), keyValueId1.getValue()); - - // get by criteria. must be 1 - Either, JanusGraphOperationStatus> byCriteria = janusGraphDao.getByCriteria(NodeTypeEnum.User, props, - UserData.class); - assertTrue(byCriteria.isLeft()); - assertEquals(1, byCriteria.left().value().size()); - - log.debug("{}", byCriteria.left().value()); - - // delete all nodes - node = janusGraphDao.deleteNode(userData1, UserData.class); - assertTrue(node.isLeft()); - node = janusGraphDao.deleteNode(userData2, UserData.class); - assertTrue(node.isLeft()); - } - - @Test - public void testGetEdgesForNode() { - String id = "userId12345abc"; - UserData userData = new UserData("Myname123", "Mylastname", id, "email123", UserRoleEnum.ADMIN.name(), - UserStatusEnum.ACTIVE.name(), null); - janusGraphDao.createNode(userData, UserData.class); - ResourceMetadataData resourceData = new ResourceMetadataData(); - resourceData.getMetadataDataDefinition().setName("resourceForLock"); - resourceData.getMetadataDataDefinition().setVersion("0.1"); - resourceData.getMetadataDataDefinition().setState("newState"); - resourceData.getMetadataDataDefinition().setUniqueId(resourceData.getMetadataDataDefinition().getName() + "." - + resourceData.getMetadataDataDefinition().getVersion()); - - janusGraphDao.createNode(resourceData, ResourceMetadataData.class); - janusGraphDao.createRelation(userData, resourceData, GraphEdgeLabels.LAST_MODIFIER, null); - janusGraphDao.commit(); - - Either, JanusGraphOperationStatus> eitherEdges = janusGraphDao.getEdgesForNode(userData, Direction.OUT); - assertTrue(eitherEdges.isLeft()); + + private static Logger log = LoggerFactory.getLogger(JanusGraphGenericDaoTest.class.getName()); + private static ConfigurationManager configurationManager; + + @Resource(name = "janusgraph-generic-dao") + private JanusGraphGenericDao janusGraphDao; + + @BeforeAll + public static void setupBeforeClass() { + ExternalConfiguration.setAppName("catalog-dao"); + String appConfigDir = "src/test/resources/config/catalog-dao"; + ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), + appConfigDir); + configurationManager = new ConfigurationManager(configurationSource); + configurationManager.getConfiguration().setJanusGraphCfgFile("../catalog-be/src/main/resources/config/janusgraph.properties"); + configurationManager.getConfiguration().setJanusGraphInMemoryGraph(true); + } + + @Test + public void testcheckEdgeProps() { + JanusGraph graph = janusGraphDao.getGraph().left().value(); + JanusGraphVertex v1 = graph.addVertex(); + v1.property("prop1", 123); + JanusGraphVertex v2 = graph.addVertex(); + v2.property("prop1", 456); + JanusGraphEdge addEdge = v1.addEdge("label11", v2); + addEdge.property("edgeProp", "my prop edge"); + graph.tx().commit(); + + Either v11 = janusGraphDao.getVertexByProperty("prop1", 123); + Iterator edges = v11.left().value().edges(Direction.OUT, "label11"); + Edge edge = edges.next(); + // String value = (String)edge.value("edgeProp"); + String value = (String) janusGraphDao.getProperty(edge, "edgeProp"); + log.debug(value); + + } + + @Test + public void testCrudNode() { + + String id = "userId12345abc"; + UserData userData = new UserData("Myname123", "Mylastname", id, "email123", "Tester", + UserStatusEnum.ACTIVE.name(), null); + + Either newNode = janusGraphDao.createNode(userData, UserData.class); + + assertTrue(newNode.isLeft()); + + log.debug("{}", newNode.left().value()); + + janusGraphDao.commit(); + + ImmutablePair keyValueId = userData.getKeyValueId(); + Either node = janusGraphDao.getNode(keyValueId.getKey(), keyValueId.getValue(), + UserData.class); + janusGraphDao.commit(); + assertTrue(node.isLeft()); + log.debug("{}", node.left().value()); + + userData.setRole("Designer"); + node = janusGraphDao.updateNode(userData, UserData.class); + assertTrue(node.isLeft()); + log.debug("{}", node.left().value()); + assertEquals(null, "Designer", node.left().value().getRole()); + janusGraphDao.commit(); + + node = janusGraphDao.deleteNode(userData, UserData.class); + assertTrue(node.isLeft()); + log.debug("{}", node.left().value()); + janusGraphDao.commit(); + + node = janusGraphDao.getNode(keyValueId.getKey(), keyValueId.getValue(), UserData.class); + assertTrue(node.isRight()); + log.debug("{}", node.right().value()); + + } + + @Test + public void testGetByCategoryAndAll() { + + // create 2 nodes + String id = "userId12345abc"; + UserData userData1 = new UserData("Myname123", "Mylastname", id, "email123", "Tester", + UserStatusEnum.ACTIVE.name(), null); + + Either node1 = janusGraphDao.createNode(userData1, UserData.class); + assertTrue(node1.isLeft()); + log.debug("{}", node1.left().value()); + + id = "userIddfkoer45abc"; + UserData userData2 = new UserData("Mynadyhme123", "Mylasghtname", id, "emaighdl123", "Designer", + UserStatusEnum.ACTIVE.name(), null); + Either node2 = janusGraphDao.createNode(userData2, UserData.class); + assertTrue(node2.isLeft()); + log.debug("{}", node2.left().value()); + + janusGraphDao.commit(); + + ImmutablePair keyValueId1 = userData1.getKeyValueId(); + // get first node + Either node = janusGraphDao.getNode(keyValueId1.getKey(), keyValueId1.getValue(), + UserData.class); + assertTrue(node.isLeft()); + log.debug("{}", node.left().value()); + janusGraphDao.commit(); + + // get all must be 2 + 1 default user = 3 + Either, JanusGraphOperationStatus> all = janusGraphDao.getAll(NodeTypeEnum.User, UserData.class); + assertTrue(all.isLeft()); + assertTrue(all.left().value().size() > 0); + + log.debug("{}", all.left().value()); + + Map props = new HashMap<>(); + + props.put(keyValueId1.getKey(), keyValueId1.getValue()); + + // get by criteria. must be 1 + Either, JanusGraphOperationStatus> byCriteria = janusGraphDao.getByCriteria(NodeTypeEnum.User, props, + UserData.class); + assertTrue(byCriteria.isLeft()); + assertEquals(1, byCriteria.left().value().size()); + + log.debug("{}", byCriteria.left().value()); + + // delete all nodes + node = janusGraphDao.deleteNode(userData1, UserData.class); + assertTrue(node.isLeft()); + node = janusGraphDao.deleteNode(userData2, UserData.class); + assertTrue(node.isLeft()); + } + + @Test + public void testGetEdgesForNode() { + String id = "userId12345abc"; + UserData userData = new UserData("Myname123", "Mylastname", id, "email123", UserRoleEnum.ADMIN.name(), + UserStatusEnum.ACTIVE.name(), null); + janusGraphDao.createNode(userData, UserData.class); + ResourceMetadataData resourceData = new ResourceMetadataData(); + resourceData.getMetadataDataDefinition().setName("resourceForLock"); + resourceData.getMetadataDataDefinition().setVersion("0.1"); + resourceData.getMetadataDataDefinition().setState("newState"); + resourceData.getMetadataDataDefinition().setUniqueId(resourceData.getMetadataDataDefinition().getName() + "." + + resourceData.getMetadataDataDefinition().getVersion()); + + janusGraphDao.createNode(resourceData, ResourceMetadataData.class); + janusGraphDao.createRelation(userData, resourceData, GraphEdgeLabels.LAST_MODIFIER, null); + janusGraphDao.commit(); + + Either, JanusGraphOperationStatus> eitherEdges = janusGraphDao.getEdgesForNode(userData, Direction.OUT); + assertTrue(eitherEdges.isLeft()); assertEquals(1, eitherEdges.left().value().size()); - eitherEdges = janusGraphDao.getEdgesForNode(userData, Direction.IN); - assertTrue(eitherEdges.isLeft()); + eitherEdges = janusGraphDao.getEdgesForNode(userData, Direction.IN); + assertTrue(eitherEdges.isLeft()); assertEquals(0, eitherEdges.left().value().size()); - eitherEdges = janusGraphDao.getEdgesForNode(resourceData, Direction.OUT); - assertTrue(eitherEdges.isLeft()); + eitherEdges = janusGraphDao.getEdgesForNode(resourceData, Direction.OUT); + assertTrue(eitherEdges.isLeft()); assertEquals(0, eitherEdges.left().value().size()); - eitherEdges = janusGraphDao.getEdgesForNode(resourceData, Direction.IN); - assertTrue(eitherEdges.isLeft()); + eitherEdges = janusGraphDao.getEdgesForNode(resourceData, Direction.IN); + assertTrue(eitherEdges.isLeft()); assertEquals(1, eitherEdges.left().value().size()); - eitherEdges = janusGraphDao.getEdgesForNode(resourceData, Direction.BOTH); - assertTrue(eitherEdges.isLeft()); + eitherEdges = janusGraphDao.getEdgesForNode(resourceData, Direction.BOTH); + assertTrue(eitherEdges.isLeft()); assertEquals(1, eitherEdges.left().value().size()); - eitherEdges = janusGraphDao.getEdgesForNode(userData, Direction.BOTH); - assertTrue(eitherEdges.isLeft()); + eitherEdges = janusGraphDao.getEdgesForNode(userData, Direction.BOTH); + assertTrue(eitherEdges.isLeft()); assertEquals(1, eitherEdges.left().value().size()); - janusGraphDao.deleteNode(userData, UserData.class); - janusGraphDao.deleteNode(resourceData, ResourceMetadataData.class); - janusGraphDao.commit(); - } + janusGraphDao.deleteNode(userData, UserData.class); + janusGraphDao.deleteNode(resourceData, ResourceMetadataData.class); + janusGraphDao.commit(); + } + + @Test + public void testLockElement() { + + ResourceMetadataData resourceData = new ResourceMetadataData(); + + resourceData.getMetadataDataDefinition().setName("resourceForLock"); + resourceData.getMetadataDataDefinition().setVersion("0.1"); + resourceData.getMetadataDataDefinition().setState("newState"); + resourceData.getMetadataDataDefinition().setUniqueId(resourceData.getMetadataDataDefinition().getName() + "." + + resourceData.getMetadataDataDefinition().getVersion()); + + Either resource1 = janusGraphDao.createNode(resourceData, + ResourceMetadataData.class); + assertTrue(resource1.isLeft()); + janusGraphDao.commit(); + String lockId = "lock_" + resourceData.getLabel() + "_" + resource1.left().value().getUniqueId(); + + Either nodeLock = janusGraphDao + .getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class); + assertTrue(nodeLock.isRight()); + assertEquals(JanusGraphOperationStatus.NOT_FOUND, nodeLock.right().value()); + + JanusGraphOperationStatus status = janusGraphDao.lockElement(resourceData); + assertEquals(JanusGraphOperationStatus.OK, status); - @Test - public void testLockElement() { - - ResourceMetadataData resourceData = new ResourceMetadataData(); + nodeLock = janusGraphDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class); + assertTrue(nodeLock.isLeft()); + assertEquals(lockId, nodeLock.left().value().getUniqueId()); - resourceData.getMetadataDataDefinition().setName("resourceForLock"); - resourceData.getMetadataDataDefinition().setVersion("0.1"); - resourceData.getMetadataDataDefinition().setState("newState"); - resourceData.getMetadataDataDefinition().setUniqueId(resourceData.getMetadataDataDefinition().getName() + "." - + resourceData.getMetadataDataDefinition().getVersion()); + janusGraphDao.commit(); - Either resource1 = janusGraphDao.createNode(resourceData, - ResourceMetadataData.class); - assertTrue(resource1.isLeft()); - janusGraphDao.commit(); - String lockId = "lock_" + resourceData.getLabel() + "_" + resource1.left().value().getUniqueId(); + status = janusGraphDao.lockElement(resourceData); + assertEquals(JanusGraphOperationStatus.ALREADY_LOCKED, status); - Either nodeLock = janusGraphDao - .getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class); - assertTrue(nodeLock.isRight()); - assertEquals(JanusGraphOperationStatus.NOT_FOUND, nodeLock.right().value()); + status = janusGraphDao.releaseElement(resourceData); + assertEquals(JanusGraphOperationStatus.OK, status); - JanusGraphOperationStatus status = janusGraphDao.lockElement(resourceData); - assertEquals(JanusGraphOperationStatus.OK, status); + nodeLock = janusGraphDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class); + assertTrue(nodeLock.isRight()); + assertEquals(JanusGraphOperationStatus.NOT_FOUND, nodeLock.right().value()); + janusGraphDao.deleteNode(resourceData, ResourceMetadataData.class); + janusGraphDao.commit(); - nodeLock = janusGraphDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class); - assertTrue(nodeLock.isLeft()); - assertEquals(lockId, nodeLock.left().value().getUniqueId()); + } - janusGraphDao.commit(); + @Test + public void testReLockElement() throws InterruptedException { - status = janusGraphDao.lockElement(resourceData); - assertEquals(JanusGraphOperationStatus.ALREADY_LOCKED, status); + ResourceMetadataData resourceData = new ResourceMetadataData(); - status = janusGraphDao.releaseElement(resourceData); - assertEquals(JanusGraphOperationStatus.OK, status); + resourceData.getMetadataDataDefinition().setName("resourceForReLock"); + resourceData.getMetadataDataDefinition().setVersion("0.1"); + resourceData.getMetadataDataDefinition().setState("newState"); + resourceData.getMetadataDataDefinition().setUniqueId(resourceData.getMetadataDataDefinition().getName() + "." + + resourceData.getMetadataDataDefinition().getVersion()); - nodeLock = janusGraphDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class); - assertTrue(nodeLock.isRight()); - assertEquals(JanusGraphOperationStatus.NOT_FOUND, nodeLock.right().value()); - janusGraphDao.deleteNode(resourceData, ResourceMetadataData.class); - janusGraphDao.commit(); + Either resource1 = janusGraphDao.createNode(resourceData, + ResourceMetadataData.class); + assertTrue(resource1.isLeft()); + janusGraphDao.commit(); + String lockId = "lock_" + resourceData.getLabel() + "_" + resource1.left().value().getUniqueId(); - } + Either nodeLock = janusGraphDao + .getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class); + assertTrue(nodeLock.isRight()); + assertEquals(JanusGraphOperationStatus.NOT_FOUND, nodeLock.right().value()); - @Test - public void testReLockElement() throws InterruptedException { - - ResourceMetadataData resourceData = new ResourceMetadataData(); + // lock + JanusGraphOperationStatus status = janusGraphDao.lockElement(resourceData); + assertEquals(JanusGraphOperationStatus.OK, status); - resourceData.getMetadataDataDefinition().setName("resourceForReLock"); - resourceData.getMetadataDataDefinition().setVersion("0.1"); - resourceData.getMetadataDataDefinition().setState("newState"); - resourceData.getMetadataDataDefinition().setUniqueId(resourceData.getMetadataDataDefinition().getName() + "." - + resourceData.getMetadataDataDefinition().getVersion()); + nodeLock = janusGraphDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class); + assertTrue(nodeLock.isLeft()); + assertEquals(lockId, nodeLock.left().value().getUniqueId()); + long time1 = nodeLock.left().value().getTime(); - Either resource1 = janusGraphDao.createNode(resourceData, - ResourceMetadataData.class); - assertTrue(resource1.isLeft()); - janusGraphDao.commit(); - String lockId = "lock_" + resourceData.getLabel() + "_" + resource1.left().value().getUniqueId(); + janusGraphDao.commit(); - Either nodeLock = janusGraphDao - .getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class); - assertTrue(nodeLock.isRight()); - assertEquals(JanusGraphOperationStatus.NOT_FOUND, nodeLock.right().value()); + // timeout + configurationManager.getConfiguration().setJanusGraphLockTimeout(2L); + Thread.sleep(5001); - // lock - JanusGraphOperationStatus status = janusGraphDao.lockElement(resourceData); - assertEquals(JanusGraphOperationStatus.OK, status); + // relock + status = janusGraphDao.lockElement(resourceData); + assertEquals(JanusGraphOperationStatus.OK, status); - nodeLock = janusGraphDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class); - assertTrue(nodeLock.isLeft()); - assertEquals(lockId, nodeLock.left().value().getUniqueId()); - long time1 = nodeLock.left().value().getTime(); + nodeLock = janusGraphDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class); + assertTrue(nodeLock.isLeft()); + assertEquals(lockId, nodeLock.left().value().getUniqueId()); - janusGraphDao.commit(); + long time2 = nodeLock.left().value().getTime(); - // timeout - configurationManager.getConfiguration().setJanusGraphLockTimeout(2L); - Thread.sleep(5001); + assertTrue(time2 > time1); - // relock - status = janusGraphDao.lockElement(resourceData); - assertEquals(JanusGraphOperationStatus.OK, status); + status = janusGraphDao.releaseElement(resourceData); + assertEquals(JanusGraphOperationStatus.OK, status); - nodeLock = janusGraphDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class); - assertTrue(nodeLock.isLeft()); - assertEquals(lockId, nodeLock.left().value().getUniqueId()); + nodeLock = janusGraphDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class); + assertTrue(nodeLock.isRight()); + assertEquals(JanusGraphOperationStatus.NOT_FOUND, nodeLock.right().value()); - long time2 = nodeLock.left().value().getTime(); + janusGraphDao.deleteNode(resourceData, ResourceMetadataData.class); + janusGraphDao.commit(); - assertTrue(time2 > time1); + } + + @Test + public void testBoolean() { + ResourceMetadataData resourceData = new ResourceMetadataData(); - status = janusGraphDao.releaseElement(resourceData); - assertEquals(JanusGraphOperationStatus.OK, status); + resourceData.getMetadataDataDefinition().setName("resourceForLock"); + resourceData.getMetadataDataDefinition().setVersion("0.1"); + resourceData.getMetadataDataDefinition().setState("NOT_CERTIFIED_CHECKOUT"); + resourceData.getMetadataDataDefinition().setHighestVersion(true); + resourceData.getMetadataDataDefinition().setUniqueId(resourceData.getMetadataDataDefinition().getName() + "." + + resourceData.getMetadataDataDefinition().getVersion()); - nodeLock = janusGraphDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), lockId, GraphNodeLock.class); - assertTrue(nodeLock.isRight()); - assertEquals(JanusGraphOperationStatus.NOT_FOUND, nodeLock.right().value()); - - janusGraphDao.deleteNode(resourceData, ResourceMetadataData.class); - janusGraphDao.commit(); + Either resource1 = janusGraphDao.createNode(resourceData, + ResourceMetadataData.class); + assertTrue(resource1.isLeft()); - } - - @Test - public void testBoolean() { - ResourceMetadataData resourceData = new ResourceMetadataData(); - - resourceData.getMetadataDataDefinition().setName("resourceForLock"); - resourceData.getMetadataDataDefinition().setVersion("0.1"); - resourceData.getMetadataDataDefinition().setState("NOT_CERTIFIED_CHECKOUT"); - resourceData.getMetadataDataDefinition().setHighestVersion(true); - resourceData.getMetadataDataDefinition().setUniqueId(resourceData.getMetadataDataDefinition().getName() + "." - + resourceData.getMetadataDataDefinition().getVersion()); + resourceData = new ResourceMetadataData(); + + resourceData.getMetadataDataDefinition().setName("resourceForLock"); + resourceData.getMetadataDataDefinition().setVersion("0.2"); + resourceData.getMetadataDataDefinition().setState("NOT_CERTIFIED_CHECKOUT"); + resourceData.getMetadataDataDefinition().setHighestVersion(false); + resourceData.getMetadataDataDefinition().setUniqueId(resourceData.getMetadataDataDefinition().getName() + "." + + resourceData.getMetadataDataDefinition().getVersion()); + + Either resource2 = janusGraphDao.createNode(resourceData, + ResourceMetadataData.class); + janusGraphDao.commit(); + + Map props = new HashMap<>(); + + props.put(GraphPropertiesDictionary.STATE.getProperty(), "NOT_CERTIFIED_CHECKOUT"); + props.put("name", "resourceForLock"); + props.put(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty(), false); + + // get by criteria. must be 1 + Either, JanusGraphOperationStatus> byCriteria = janusGraphDao + .getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class); + assertTrue(byCriteria.isLeft()); + + janusGraphDao.deleteNode(resource1.left().value(), ResourceMetadataData.class); + + janusGraphDao.deleteNode(resource2.left().value(), ResourceMetadataData.class); + janusGraphDao.commit(); + } + + @Test + public void testStringSearch() { + JanusGraph graph; + + BaseConfiguration conf = new BaseConfiguration(); + conf.setProperty("storage.backend", "inmemory"); + graph = JanusGraphFactory.open(conf); + + // JanusGraphManagement graphMgt = graph.getManagementSystem(); + JanusGraphManagement graphMgt = graph.openManagement(); + PropertyKey propKey = graphMgt.makePropertyKey("string1").dataType(String.class).make(); + graphMgt.buildIndex("string1", Vertex.class).addKey(propKey).unique().buildCompositeIndex(); + + propKey = graphMgt.makePropertyKey("string2").dataType(String.class).make(); + + graphMgt.buildIndex("string2", Vertex.class).addKey(propKey).unique().buildCompositeIndex(); + graphMgt.commit(); + + log.debug("**** predicat index search non case"); + Iterable vertices = graph.query().has("string1", Text.REGEX, "my new string 1").vertices(); + Iterator iter = vertices.iterator(); + while (iter.hasNext()) { + Vertex ver = iter.next(); + // System.out.println(com.tinkerpop.blueprints.util.ElementHelper.getProperties(ver)); + log.debug("{}", janusGraphDao.getProperties(ver)); + } + + } + + @Test + public void testDuplicateResultDueToJanusGraphBug() { + + ResourceMetadataData resourceData1 = new ResourceMetadataData(); + resourceData1.getMetadataDataDefinition().setUniqueId("A"); + ((ResourceMetadataDataDefinition) resourceData1.getMetadataDataDefinition()).setAbstract(true); + resourceData1.getMetadataDataDefinition().setName("aaaa"); + + Either newNode1 = janusGraphDao.createNode(resourceData1, + ResourceMetadataData.class); + assertTrue(newNode1.isLeft()); + log.debug("{}", newNode1.left().value()); + // janusGraphDao.commit(); + + Map props = new HashMap<>(); + props.put(GraphPropertiesDictionary.IS_ABSTRACT.getProperty(), true); + Either, JanusGraphOperationStatus> byCriteria = janusGraphDao + .getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class); + assertTrue(byCriteria.isLeft()); + assertEquals("check one result returned", 1, byCriteria.left().value().size()); + // janusGraphDao.commit(); + + ResourceMetadataData resourceToUpdate = new ResourceMetadataData(); + ((ResourceMetadataDataDefinition) resourceToUpdate.getMetadataDataDefinition()).setAbstract(false); + resourceToUpdate.getMetadataDataDefinition().setUniqueId("A"); + Either updateNode = janusGraphDao.updateNode(resourceToUpdate, + ResourceMetadataData.class); + assertTrue(updateNode.isLeft()); + // janusGraphDao.commit(); + + byCriteria = janusGraphDao.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class); + assertTrue(byCriteria.isRight()); + assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND, + byCriteria.right().value()); + + AdditionalInfoParameterData infoParameterData = new AdditionalInfoParameterData(); + infoParameterData.getAdditionalInfoParameterDataDefinition().setUniqueId("123"); + Map idToKey = new HashMap<>(); + idToKey.put("key1", "value1"); + infoParameterData.setIdToKey(idToKey); + + Either newNode2 = janusGraphDao.createNode(infoParameterData, + AdditionalInfoParameterData.class); + assertTrue(newNode2.isLeft()); + log.debug("{}", newNode2.left().value()); + // janusGraphDao.commit(); + + Map idToKey2 = new HashMap<>(); + idToKey2.put("key1", "value2"); + + Map props2 = new HashMap<>(); + props2.put(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), "123"); + Gson gson = new Gson(); + props2.put(GraphPropertiesDictionary.ADDITIONAL_INFO_ID_TO_KEY.getProperty(), gson.toJson(idToKey2)); + // props2.put(GraphPropertiesDictionary.ADDITIONAL_INFO_ID_TO_KEY.getProperty(), + // idToKey2); + + Either, JanusGraphOperationStatus> byCriteria2 = janusGraphDao + .getByCriteria(NodeTypeEnum.AdditionalInfoParameters, props2, AdditionalInfoParameterData.class); + assertTrue(byCriteria2.isRight()); + assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND, + byCriteria2.right().value()); + + infoParameterData.setIdToKey(idToKey2); + + Either updateNode2 = janusGraphDao.updateNode(infoParameterData, + AdditionalInfoParameterData.class); + assertTrue(updateNode2.isLeft()); + // janusGraphDao.commit(); + + props2.put(GraphPropertiesDictionary.ADDITIONAL_INFO_ID_TO_KEY.getProperty(), idToKey); + byCriteria2 = janusGraphDao.getByCriteria(NodeTypeEnum.AdditionalInfoParameters, props2, + AdditionalInfoParameterData.class); + assertTrue(byCriteria2.isRight()); + assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND, + byCriteria2.right().value()); + + ComponentInstanceData resourceInstanceData = new ComponentInstanceData(); + resourceInstanceData.getComponentInstDataDefinition().setUniqueId("ri123"); + resourceInstanceData.getComponentInstDataDefinition().setPosX("22"); + resourceInstanceData.getComponentInstDataDefinition().setName("myresource_1"); + + Either newNode3 = janusGraphDao.createNode(resourceInstanceData, + ComponentInstanceData.class); + assertTrue(newNode3.isLeft()); + log.debug("{}", newNode3.left().value()); + // janusGraphDao.commit(); + + resourceInstanceData.getComponentInstDataDefinition().setPosX("50"); + Either updateNode3 = janusGraphDao.updateNode(resourceInstanceData, + ComponentInstanceData.class); + assertTrue(updateNode3.isLeft()); + // janusGraphDao.commit(); + + resourceInstanceData.getComponentInstDataDefinition().setName("myresource_2"); + updateNode3 = janusGraphDao.updateNode(resourceInstanceData, ComponentInstanceData.class); + assertTrue(updateNode3.isLeft()); + // janusGraphDao.commit(); + + Map props3 = new HashMap<>(); + props3.put("positionX", "22"); + Either, JanusGraphOperationStatus> byCriteria3 = janusGraphDao + .getByCriteria(NodeTypeEnum.ResourceInstance, props3, ComponentInstanceData.class); + assertTrue(byCriteria3.isRight()); + assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND, + byCriteria3.right().value()); + + props3.put("positionX", "50"); + byCriteria3 = janusGraphDao.getByCriteria(NodeTypeEnum.ResourceInstance, props3, ComponentInstanceData.class); + assertTrue(byCriteria3.isLeft()); + + /////////////////////////// check integer //////////////////////// + + ArtifactData artifactData = new ArtifactData(); + artifactData.getArtifactDataDefinition().setUniqueId("ad234"); + artifactData.getArtifactDataDefinition().setTimeout(100); + + Either newNode4 = janusGraphDao.createNode(artifactData, ArtifactData.class); + assertTrue(newNode4.isLeft()); + log.debug("{}", newNode4.left().value()); + // janusGraphDao.commit(); + + artifactData.getArtifactDataDefinition().setTimeout(50); + Either updateNode4 = janusGraphDao.updateNode(artifactData, ArtifactData.class); + assertTrue(updateNode4.isLeft()); + // janusGraphDao.commit(); + + Map props4 = new HashMap<>(); + props4.put("timeout", 100); + Either, JanusGraphOperationStatus> byCriteria4 = janusGraphDao.getByCriteria(NodeTypeEnum.ArtifactRef, + props4, ArtifactData.class); + assertTrue(byCriteria4.isRight()); + assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND, + byCriteria4.right().value()); + + props4.put("timeout", 50); + byCriteria4 = janusGraphDao.getByCriteria(NodeTypeEnum.ArtifactRef, props4, ArtifactData.class); + assertTrue(byCriteria4.isLeft()); + + janusGraphDao.rollback(); + } + + @Test + public void testDuplicateResultUSeHasNotQueryDueToJanusGraphBug() { + + String name = "bbbb"; + + ResourceMetadataData resourceData1 = new ResourceMetadataData(); + resourceData1.getMetadataDataDefinition().setUniqueId("A"); + ((ResourceMetadataDataDefinition) resourceData1.getMetadataDataDefinition()).setAbstract(true); + resourceData1.getMetadataDataDefinition().setName(name); + + Either newNode1 = janusGraphDao.createNode(resourceData1, + ResourceMetadataData.class); + assertTrue(newNode1.isLeft()); + log.debug("{}", newNode1.left().value()); + // janusGraphDao.commit(); + + Map props = new HashMap<>(); + props.put(GraphPropertiesDictionary.IS_ABSTRACT.getProperty(), true); + Either, JanusGraphOperationStatus> byCriteria = janusGraphDao + .getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class); + assertTrue(byCriteria.isLeft()); + assertEquals("check one result returned", 1, byCriteria.left().value().size()); + // janusGraphDao.commit(); + + ResourceMetadataData resourceToUpdate = new ResourceMetadataData(); + ((ResourceMetadataDataDefinition) resourceToUpdate.getMetadataDataDefinition()).setAbstract(false); + resourceToUpdate.getMetadataDataDefinition().setUniqueId("A"); + Either updateNode = janusGraphDao.updateNode(resourceToUpdate, + ResourceMetadataData.class); + assertTrue(updateNode.isLeft()); + // janusGraphDao.commit(); + + // no result where isAbstract = true + byCriteria = janusGraphDao.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class); + assertTrue(byCriteria.isRight()); + assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND, + byCriteria.right().value()); + + // one result where isAbstract != true + byCriteria = janusGraphDao.getByCriteria(NodeTypeEnum.Resource, null, props, ResourceMetadataData.class); + assertTrue(byCriteria.isLeft()); + assertEquals("check one result returned", 1, byCriteria.left().value().size()); + + props.put(GraphPropertiesDictionary.IS_ABSTRACT.getProperty(), false); + byCriteria = janusGraphDao.getByCriteria(NodeTypeEnum.Resource, null, props, ResourceMetadataData.class); + assertTrue(byCriteria.isRight()); + assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND, + byCriteria.right().value()); + + janusGraphDao.rollback(); + + } - Either resource1 = janusGraphDao.createNode(resourceData, - ResourceMetadataData.class); - assertTrue(resource1.isLeft()); - - resourceData = new ResourceMetadataData(); - - resourceData.getMetadataDataDefinition().setName("resourceForLock"); - resourceData.getMetadataDataDefinition().setVersion("0.2"); - resourceData.getMetadataDataDefinition().setState("NOT_CERTIFIED_CHECKOUT"); - resourceData.getMetadataDataDefinition().setHighestVersion(false); - resourceData.getMetadataDataDefinition().setUniqueId(resourceData.getMetadataDataDefinition().getName() + "." - + resourceData.getMetadataDataDefinition().getVersion()); - - Either resource2 = janusGraphDao.createNode(resourceData, - ResourceMetadataData.class); - janusGraphDao.commit(); - - Map props = new HashMap<>(); - - props.put(GraphPropertiesDictionary.STATE.getProperty(), "NOT_CERTIFIED_CHECKOUT"); - props.put("name", "resourceForLock"); - props.put(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty(), false); - - // get by criteria. must be 1 - Either, JanusGraphOperationStatus> byCriteria = janusGraphDao - .getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class); - assertTrue(byCriteria.isLeft()); - - janusGraphDao.deleteNode(resource1.left().value(), ResourceMetadataData.class); - - janusGraphDao.deleteNode(resource2.left().value(), ResourceMetadataData.class); - janusGraphDao.commit(); - } - - // @Test - public void testStringSearch() { - JanusGraph graph; - - BaseConfiguration conf = new BaseConfiguration(); - conf.setProperty("storage.backend", "inmemory"); - graph = JanusGraphFactory.open(conf); - - // JanusGraphManagement graphMgt = graph.getManagementSystem(); - JanusGraphManagement graphMgt = graph.openManagement(); - PropertyKey propKey = graphMgt.makePropertyKey("string1").dataType(String.class).make(); - graphMgt.buildIndex("string1", Vertex.class).addKey(propKey).unique().buildCompositeIndex(); - - propKey = graphMgt.makePropertyKey("string2").dataType(String.class).make(); - - graphMgt.buildIndex("string2", Vertex.class).addKey(propKey).unique().buildCompositeIndex(); - graphMgt.commit(); - - - log.debug("**** predicat index search non case"); - Iterable vertices = graph.query().has("string1", Text.REGEX, "my new string 1").vertices(); - Iterator iter = vertices.iterator(); - while (iter.hasNext()) { - Vertex ver = iter.next(); - // System.out.println(com.tinkerpop.blueprints.util.ElementHelper.getProperties(ver)); - log.debug("{}", janusGraphDao.getProperties(ver)); - } - - } - - @Test - public void testDuplicateResultDueToJanusGraphBug() { - - ResourceMetadataData resourceData1 = new ResourceMetadataData(); - resourceData1.getMetadataDataDefinition().setUniqueId("A"); - ((ResourceMetadataDataDefinition) resourceData1.getMetadataDataDefinition()).setAbstract(true); - resourceData1.getMetadataDataDefinition().setName("aaaa"); - - Either newNode1 = janusGraphDao.createNode(resourceData1, - ResourceMetadataData.class); - assertTrue(newNode1.isLeft()); - log.debug("{}", newNode1.left().value()); - // janusGraphDao.commit(); - - Map props = new HashMap<>(); - props.put(GraphPropertiesDictionary.IS_ABSTRACT.getProperty(), true); - Either, JanusGraphOperationStatus> byCriteria = janusGraphDao - .getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class); - assertTrue(byCriteria.isLeft()); - assertEquals("check one result returned", 1, byCriteria.left().value().size()); - // janusGraphDao.commit(); - - ResourceMetadataData resourceToUpdate = new ResourceMetadataData(); - ((ResourceMetadataDataDefinition) resourceToUpdate.getMetadataDataDefinition()).setAbstract(false); - resourceToUpdate.getMetadataDataDefinition().setUniqueId("A"); - Either updateNode = janusGraphDao.updateNode(resourceToUpdate, - ResourceMetadataData.class); - assertTrue(updateNode.isLeft()); - // janusGraphDao.commit(); - - byCriteria = janusGraphDao.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class); - assertTrue(byCriteria.isRight()); - assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND, - byCriteria.right().value()); - - AdditionalInfoParameterData infoParameterData = new AdditionalInfoParameterData(); - infoParameterData.getAdditionalInfoParameterDataDefinition().setUniqueId("123"); - Map idToKey = new HashMap<>(); - idToKey.put("key1", "value1"); - infoParameterData.setIdToKey(idToKey); - - Either newNode2 = janusGraphDao.createNode(infoParameterData, - AdditionalInfoParameterData.class); - assertTrue(newNode2.isLeft()); - log.debug("{}", newNode2.left().value()); - // janusGraphDao.commit(); - - Map idToKey2 = new HashMap<>(); - idToKey2.put("key1", "value2"); - - Map props2 = new HashMap<>(); - props2.put(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), "123"); - Gson gson = new Gson(); - props2.put(GraphPropertiesDictionary.ADDITIONAL_INFO_ID_TO_KEY.getProperty(), gson.toJson(idToKey2)); - // props2.put(GraphPropertiesDictionary.ADDITIONAL_INFO_ID_TO_KEY.getProperty(), - // idToKey2); - - Either, JanusGraphOperationStatus> byCriteria2 = janusGraphDao - .getByCriteria(NodeTypeEnum.AdditionalInfoParameters, props2, AdditionalInfoParameterData.class); - assertTrue(byCriteria2.isRight()); - assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND, - byCriteria2.right().value()); - - infoParameterData.setIdToKey(idToKey2); - - Either updateNode2 = janusGraphDao.updateNode(infoParameterData, - AdditionalInfoParameterData.class); - assertTrue(updateNode2.isLeft()); - // janusGraphDao.commit(); - - props2.put(GraphPropertiesDictionary.ADDITIONAL_INFO_ID_TO_KEY.getProperty(), idToKey); - byCriteria2 = janusGraphDao.getByCriteria(NodeTypeEnum.AdditionalInfoParameters, props2, - AdditionalInfoParameterData.class); - assertTrue(byCriteria2.isRight()); - assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND, - byCriteria2.right().value()); - - ComponentInstanceData resourceInstanceData = new ComponentInstanceData(); - resourceInstanceData.getComponentInstDataDefinition().setUniqueId("ri123"); - resourceInstanceData.getComponentInstDataDefinition().setPosX("22"); - resourceInstanceData.getComponentInstDataDefinition().setName("myresource_1"); - - Either newNode3 = janusGraphDao.createNode(resourceInstanceData, - ComponentInstanceData.class); - assertTrue(newNode3.isLeft()); - log.debug("{}", newNode3.left().value()); - // janusGraphDao.commit(); - - resourceInstanceData.getComponentInstDataDefinition().setPosX("50"); - Either updateNode3 = janusGraphDao.updateNode(resourceInstanceData, - ComponentInstanceData.class); - assertTrue(updateNode3.isLeft()); - // janusGraphDao.commit(); - - resourceInstanceData.getComponentInstDataDefinition().setName("myresource_2"); - updateNode3 = janusGraphDao.updateNode(resourceInstanceData, ComponentInstanceData.class); - assertTrue(updateNode3.isLeft()); - // janusGraphDao.commit(); - - Map props3 = new HashMap<>(); - props3.put("positionX", "22"); - Either, JanusGraphOperationStatus> byCriteria3 = janusGraphDao - .getByCriteria(NodeTypeEnum.ResourceInstance, props3, ComponentInstanceData.class); - assertTrue(byCriteria3.isRight()); - assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND, - byCriteria3.right().value()); - - props3.put("positionX", "50"); - byCriteria3 = janusGraphDao.getByCriteria(NodeTypeEnum.ResourceInstance, props3, ComponentInstanceData.class); - assertTrue(byCriteria3.isLeft()); - - /////////////////////////// check integer //////////////////////// - - ArtifactData artifactData = new ArtifactData(); - artifactData.getArtifactDataDefinition().setUniqueId("ad234"); - artifactData.getArtifactDataDefinition().setTimeout(100); - - Either newNode4 = janusGraphDao.createNode(artifactData, ArtifactData.class); - assertTrue(newNode4.isLeft()); - log.debug("{}", newNode4.left().value()); - // janusGraphDao.commit(); - - artifactData.getArtifactDataDefinition().setTimeout(50); - Either updateNode4 = janusGraphDao.updateNode(artifactData, ArtifactData.class); - assertTrue(updateNode4.isLeft()); - // janusGraphDao.commit(); - - Map props4 = new HashMap<>(); - props4.put("timeout", 100); - Either, JanusGraphOperationStatus> byCriteria4 = janusGraphDao.getByCriteria(NodeTypeEnum.ArtifactRef, - props4, ArtifactData.class); - assertTrue(byCriteria4.isRight()); - assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND, - byCriteria4.right().value()); - - props4.put("timeout", 50); - byCriteria4 = janusGraphDao.getByCriteria(NodeTypeEnum.ArtifactRef, props4, ArtifactData.class); - assertTrue(byCriteria4.isLeft()); - - janusGraphDao.rollback(); - } - - @Test - public void testDuplicateResultUSeHasNotQueryDueToJanusGraphBug() { - - String name = "bbbb"; - - ResourceMetadataData resourceData1 = new ResourceMetadataData(); - resourceData1.getMetadataDataDefinition().setUniqueId("A"); - ((ResourceMetadataDataDefinition) resourceData1.getMetadataDataDefinition()).setAbstract(true); - resourceData1.getMetadataDataDefinition().setName(name); - - Either newNode1 = janusGraphDao.createNode(resourceData1, - ResourceMetadataData.class); - assertTrue(newNode1.isLeft()); - log.debug("{}", newNode1.left().value()); - // janusGraphDao.commit(); - - Map props = new HashMap<>(); - props.put(GraphPropertiesDictionary.IS_ABSTRACT.getProperty(), true); - Either, JanusGraphOperationStatus> byCriteria = janusGraphDao - .getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class); - assertTrue(byCriteria.isLeft()); - assertEquals("check one result returned", 1, byCriteria.left().value().size()); - // janusGraphDao.commit(); - - ResourceMetadataData resourceToUpdate = new ResourceMetadataData(); - ((ResourceMetadataDataDefinition) resourceToUpdate.getMetadataDataDefinition()).setAbstract(false); - resourceToUpdate.getMetadataDataDefinition().setUniqueId("A"); - Either updateNode = janusGraphDao.updateNode(resourceToUpdate, - ResourceMetadataData.class); - assertTrue(updateNode.isLeft()); - // janusGraphDao.commit(); - - // no result where isAbstract = true - byCriteria = janusGraphDao.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class); - assertTrue(byCriteria.isRight()); - assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND, - byCriteria.right().value()); - - // one result where isAbstract != true - byCriteria = janusGraphDao.getByCriteria(NodeTypeEnum.Resource, null, props, ResourceMetadataData.class); - assertTrue(byCriteria.isLeft()); - assertEquals("check one result returned", 1, byCriteria.left().value().size()); - - props.put(GraphPropertiesDictionary.IS_ABSTRACT.getProperty(), false); - byCriteria = janusGraphDao.getByCriteria(NodeTypeEnum.Resource, null, props, ResourceMetadataData.class); - assertTrue(byCriteria.isRight()); - assertEquals("check one result returned due to janusgraph bug", JanusGraphOperationStatus.NOT_FOUND, - byCriteria.right().value()); - - janusGraphDao.rollback(); - - } - } diff --git a/catalog-fe/pom.xml b/catalog-fe/pom.xml index e3883b75d8..170c39d426 100644 --- a/catalog-fe/pom.xml +++ b/catalog-fe/pom.xml @@ -1,689 +1,703 @@ - - - 4.0.0 - catalog-fe - war - - - org.openecomp.sdc - sdc-main - 1.10.0-SNAPSHOT - - - - - - org.projectlombok - lombok - ${lombok.version} - - - - org.functionaljava - functionaljava - ${functionaljava.version} - compile - - - org.onap.sdc.common - onap-configuration-management-api - ${project.version} - - - org.openecomp.sdc - common-app-api - ${project.version} - - - - - ch.qos.logback - logback-classic - ${logback.version} - compile - - - - org.codehaus.groovy - groovy - compile - - - - org.codehaus.janino - janino - ${janino.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.containers - jersey-container-servlet - ${jersey-bom.version} - compile - - - - org.glassfish.jersey.media - jersey-media-multipart - ${jersey-bom.version} - compile - - - - org.glassfish.jersey.media - jersey-media-moxy - ${jersey-bom.version} - compile - - - - - org.glassfish.jersey.media - jersey-media-json-jackson - ${jersey-bom.version} - compile - - - - org.glassfish.jersey.inject - jersey-hk2 - ${jersey-bom.version} - - - - com.fasterxml.jackson.core - jackson-core - ${jackson.version} - compile - - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-core - - - - - - com.fasterxml.jackson.core - jackson-annotations - ${jackson-annotations.version} - compile - - - - - org.apache.httpcomponents - httpclient - ${httpclient.version} - compile - - - - org.apache.httpcomponents - httpcore - ${httpcore.version} - compile - - - - org.apache.httpcomponents - httpmime - ${httpclient.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 - - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - ${jackson.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 - - - - - - - com.google.guava - guava - ${guava.version} - compile - - - - - com.jcabi - jcabi-aspects - ${jcabi.version} - compile - - - org.aspectj - aspectjrt - ${aspectjrt.version} - compile - - - - org.apache.commons - commons-lang3 - ${lang3.version} - compile - - - - javax.xml.bind - jaxb-api - ${jaxb-api.version} - compile - - - org.hibernate.validator - hibernate-validator - ${hibernate.validator.version} - - - - - org.owasp.esapi - esapi - ${org.owasp.esapi.version} - - - log4j - log4j - - - commons-io - commons-io - - - 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 - - - log4j - log4j - - - - - - org.fusesource - sigar - ${sigar.version} - compile - - - log4j - log4j - - - - - - - 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 - - - - - - com.google.code.bean-matchers - bean-matchers - ${bean-matchers.version} - test - - - - org.eclipse.jetty - jetty-servlet - ${jetty.version} - test - - - org.eclipse.jetty - jetty-server - - - org.eclipse.jetty - jetty-security - - - - - - org.eclipse.jetty - jetty-webapp - ${jetty.version} - test - - - org.eclipse.jetty - jetty-servlet - - - - - org.eclipse.jetty - jetty-http - ${jetty.version} - - - javax.ws.rs - javax.ws.rs-api - ${ws.rs.version} - compile - - - - javax.validation - validation-api - ${javax.validation.version} - - - - - - ${project.artifactId}-${project.version} - - - - org.apache.maven.plugins - maven-war-plugin - - - - true - - - - - - src/main/resources - - - - - - - org.eclipse.jetty - jetty-maven-plugin - ${jetty.version} - - - / - .*/.*jersey-[^/]\.jar$ - - ${project.build.directory}/${project.build.finalName}.war - - - - - org.apache.maven.plugins - maven-deploy-plugin - - true - - - - - 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-clean-plugin - - - clean.catalog.fe.folder - clean - - clean - - - - - - ${project.parent.basedir}/catalog-fe/sdc-frontend/ - false - - *.war - - - - - - - - - com.github.sylvainlaurent.maven - yaml-json-validator-maven-plugin - - - validate - validate - - validate - - - - - - src/main/resources/**/*.y*ml - src/test/resources/**/*.y*ml - - - - - src/main/resources/**/*.json - src/test/resources/**/*.json - - - - ${skipYamlJsonValidator} - - - - - - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - - com.jcabi - jcabi-maven-plugin - [0.0,) - - ajc - - - - - - - - - - - - - - - - - - - - - - catalog - - false - - - + + + catalog-fe + + ${project.artifactId}-${project.version} - - - - docker - - false - - - docker - docker - - + + + + + + lifecycle-mapping + + + + + + + + + + jcabi-maven-plugin + + ajc + + com.jcabi + [0.0,) + + + + + + + org.eclipse.m2e + 1.0.0 + + + + + + + - - org.apache.maven.plugins - maven-resources-plugin - - - copy-resources-fe - verify - - copy-resources - + + maven-war-plugin - ${basedir}/sdc-frontend - - - ${project.parent.basedir}/catalog-fe/target - - catalog-fe-${project.version}.war - - - - ${project.parent.basedir}/openecomp-ui/target - - onboarding-fe-${project.version}.war - - - + + + true + + + + + + src/main/resources + + - - - - - io.fabric8 - docker-maven-plugin - - ${verbose} - ${docker.api.version} - nexus3.onap.org:10001 - - - ${docker.username} - ${docker.password} - - - - - - - onap/sdc-frontend - sdc-frontend - - try - ${project.basedir}/sdc-frontend - - latest - - ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest - - - ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-${maven.build.timestamp} - - - - - - - - - clean-images - pre-clean - - remove - + org.apache.maven.plugins + + + + jetty-maven-plugin - true - onap/sdc-frontend + ${project.build.directory}/${project.build.finalName}.war + + / + .*/.*jersey-[^/]\.jar$ + - - - - generate-images - install - - build - - - - - push-images - deploy - - push - + org.eclipse.jetty + ${jetty.version} + + + + maven-deploy-plugin - onap/sdc-frontend + true - - - + org.apache.maven.plugins + + + + jcabi-maven-plugin + + + aspectjtools + org.aspectj + ${aspectj.version} + + + aspectjweaver + org.aspectj + ${aspectj.version} + + + + + + ajc + + + + com.jcabi + ${jcabi.maven.plugin.version} + + + maven-clean-plugin + + + + + + + ${project.parent.basedir}/catalog-fe/sdc-frontend/ + + false + + *.war + + + + + + clean + + clean.catalog.fe.folder + clean + + + org.apache.maven.plugins + + + yaml-json-validator-maven-plugin + + + + ${skipYamlJsonValidator} + + + + 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 + + - - - + + + + + + lombok + org.projectlombok + ${lombok.version} + + + + functionaljava + org.functionaljava + compile + ${functionaljava.version} + + + onap-configuration-management-api + org.onap.sdc.common + ${project.version} + + + common-app-api + org.openecomp.sdc + ${project.version} + + + + + logback-classic + ch.qos.logback + compile + ${logback.version} + + + + groovy + org.codehaus.groovy + compile + + + + janino + org.codehaus.janino + compile + ${janino.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-container-servlet + org.glassfish.jersey.containers + compile + ${jersey-bom.version} + + + + jersey-media-multipart + org.glassfish.jersey.media + compile + ${jersey-bom.version} + + + + jersey-media-moxy + org.glassfish.jersey.media + compile + ${jersey-bom.version} + + + + + jersey-media-json-jackson + org.glassfish.jersey.media + compile + ${jersey-bom.version} + + + + jersey-hk2 + org.glassfish.jersey.inject + ${jersey-bom.version} + + + + jackson-core + com.fasterxml.jackson.core + compile + ${jackson.version} + + + + jackson-databind + + + jackson-core + com.fasterxml.jackson.core + + + com.fasterxml.jackson.core + ${jackson.version} + + + + jackson-annotations + com.fasterxml.jackson.core + compile + ${jackson-annotations.version} + + + + + httpclient + org.apache.httpcomponents + compile + ${httpclient.version} + + + + httpcore + org.apache.httpcomponents + compile + ${httpcore.version} + + + + httpmime + org.apache.httpcomponents + compile + ${httpclient.version} + + + + commons-logging + commons-logging + compile + ${commons-logging} + + + + commons-codec + commons-codec + compile + ${commons-codec} + + + + + javax.servlet-api + javax.servlet + provided + ${servlet-api.version} + + + + + jackson-dataformat-yaml + com.fasterxml.jackson.dataformat + compile + ${jackson.version} + + + + + jetty-proxy + + + jetty-http + org.eclipse.jetty + + + org.eclipse.jetty + compile + ${jetty.version} + + + + jetty-servlets + + + jetty-http + org.eclipse.jetty + + + org.eclipse.jetty + compile + ${jetty.version} + + + + + guava + com.google.guava + compile + ${guava.version} + + + + + jcabi-aspects + com.jcabi + compile + ${jcabi.version} + + + aspectjrt + org.aspectj + compile + ${aspectjrt.version} + + + + commons-lang3 + org.apache.commons + compile + ${lang3.version} + + + + jaxb-api + javax.xml.bind + compile + ${jaxb-api.version} + + + hibernate-validator + org.hibernate.validator + ${hibernate.validator.version} + + + + + esapi + + + log4j + log4j + + + commons-io + commons-io + + + 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 + + + log4j + log4j + + + org.onap.portal.sdk + compile + ${ecomp.version} + + + + sigar + + + log4j + log4j + + + org.fusesource + compile + ${sigar.version} + + + + + 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} + + + + bean-matchers + com.google.code.bean-matchers + test + ${bean-matchers.version} + + + + jetty-servlet + + + jetty-server + org.eclipse.jetty + + + jetty-security + org.eclipse.jetty + + + org.eclipse.jetty + test + ${jetty.version} + + + + jetty-webapp + + + jetty-servlet + org.eclipse.jetty + + + org.eclipse.jetty + test + ${jetty.version} + + + jetty-http + org.eclipse.jetty + ${jetty.version} + + + javax.ws.rs-api + javax.ws.rs + compile + ${ws.rs.version} + + + + validation-api + javax.validation + ${javax.validation.version} + + + + 4.0.0 + + war + + + sdc-main + org.openecomp.sdc + 1.10.0-SNAPSHOT + + + + + + false + + + ${project.artifactId}-${project.version} + + + catalog + + + + false + + + + + maven-resources-plugin + + + + ${basedir}/sdc-frontend + + + ${project.parent.basedir}/catalog-fe/target + + + catalog-fe-${project.version}.war + + + + + ${project.parent.basedir}/openecomp-ui/target + + + onboarding-fe-${project.version}.war + + + + + + + copy-resources + + copy-resources-fe + verify + + + org.apache.maven.plugins + + + docker-maven-plugin + + ${docker.api.version} + + + ${docker.password} + ${docker.username} + + + + + + + sdc-frontend + + try + ${project.basedir}/sdc-frontend + + + latest + + ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest + + + ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-${maven.build.timestamp} + + + + onap/sdc-frontend + + + nexus3.onap.org:10001 + ${verbose} + + + + + onap/sdc-frontend + true + + + remove + + clean-images + pre-clean + + + + + build + + generate-images + install + + + + + onap/sdc-frontend + + + push + + push-images + deploy + + + io.fabric8 + + + + docker + + docker + docker + + + diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArchiveOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArchiveOperationTest.java index 1bc067e0f4..761e61fe38 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArchiveOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArchiveOperationTest.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,15 +20,20 @@ package org.openecomp.sdc.be.model.jsonjanusgraph.operations; +import static org.assertj.core.api.Assertions.assertThat; + import fj.data.Either; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.annotation.Resource; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openecomp.sdc.be.dao.api.ActionStatus; +import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; -import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao; import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum; import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum; import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition; @@ -40,41 +45,26 @@ import org.openecomp.sdc.be.model.LifecycleStateEnum; import org.openecomp.sdc.be.model.ModelTestBase; import org.openecomp.sdc.be.model.jsonjanusgraph.enums.JsonConstantKeysEnum; import org.openecomp.sdc.be.model.jsonjanusgraph.utils.GraphTestUtils; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import javax.annotation.Resource; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.assertj.core.api.Assertions.assertThat; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; /** * Created by yavivi on 21/03/2018. */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(value = {"classpath:application-context-test.xml", "classpath:healing-context-test.xml"}) +@SpringJUnitConfig(locations = {"classpath:application-context-test.xml", "classpath:healing-context-test.xml"}) public class ArchiveOperationTest extends ModelTestBase { private static final String CI_UID_RES1_CP = "cp_uid"; private static final String CI_UID_RES2_VL = "vl_uid"; private static final String CI_UID_SVC_PROXY = "svc_proxy_uid"; - + GraphVertex archiveVertex; + GraphVertex catalogVertex; @Resource private ArchiveOperation archiveOperation; - @Resource private JanusGraphDao janusGraphDao; - private boolean isInitialized; - private GraphVertex serviceVertex1; private GraphVertex archivedVertex1; - - GraphVertex archiveVertex; - GraphVertex catalogVertex; - private GraphVertex serviceVertex1_0; private GraphVertex serviceVertex1_1; private GraphVertex serviceVertex2_0; @@ -98,14 +88,14 @@ public class ArchiveOperationTest extends ModelTestBase { private GraphVertex vfResource0_1; private GraphVertex vfResource0_2; private GraphVertex vfResource1_0; - private String csarUuid = "123456789";; + private String csarUuid = "123456789"; - @BeforeClass - public static void initTest(){ + @BeforeAll + public static void initTest() { ModelTestBase.init(); } - @Before + @BeforeEach public void beforeTest() { if (!isInitialized) { GraphTestUtils.clearGraph(janusGraphDao); @@ -115,7 +105,7 @@ public class ArchiveOperationTest extends ModelTestBase { } @Test - public void testArchiveComponentSingleVersion(){ + public void testArchiveComponentSingleVersion() { String componentId = serviceVertex1.getUniqueId(); Either, ActionStatus> actionStatus = this.archiveOperation.archiveComponent(componentId); assertThat(actionStatus.isLeft()).isTrue(); @@ -123,7 +113,7 @@ public class ArchiveOperationTest extends ModelTestBase { } @Test - public void testArchiveComponentFailsWhenInCheckoutSingleVersion(){ + public void testArchiveComponentFailsWhenInCheckoutSingleVersion() { checkoutComponent(serviceVertex1); String componentId = serviceVertex1.getUniqueId(); Either, ActionStatus> actionStatus = this.archiveOperation.archiveComponent(componentId); @@ -146,7 +136,7 @@ public class ArchiveOperationTest extends ModelTestBase { } @Test - public void testScenario2_archive_1_0(){ + public void testScenario2_archive_1_0() { Either, ActionStatus> actionStatus = this.archiveOperation.archiveComponent(serviceVertex1_0.getUniqueId()); assertThat(actionStatus.isLeft()).isTrue(); assertThat(actionStatus.left().value()).containsExactlyInAnyOrder(serviceVertex1_0.getUniqueId(), serviceVertex1_1.getUniqueId()); @@ -155,7 +145,7 @@ public class ArchiveOperationTest extends ModelTestBase { } @Test - public void testScenario2_archive_1_1(){ + public void testScenario2_archive_1_1() { Either, ActionStatus> actionStatus = this.archiveOperation.archiveComponent(serviceVertex1_1.getUniqueId()); assertThat(actionStatus.left().value()).containsExactlyInAnyOrder(serviceVertex1_0.getUniqueId(), serviceVertex1_1.getUniqueId()); assertArchived(serviceVertex1_0.getUniqueId()); @@ -163,9 +153,10 @@ public class ArchiveOperationTest extends ModelTestBase { } @Test - public void testScenario4_oneLowOneHighestVersion(){ + public void testScenario4_oneLowOneHighestVersion() { Either, ActionStatus> actionStatus = this.archiveOperation.archiveComponent(serviceVertex0_2.getUniqueId()); - assertThat(actionStatus.left().value()).containsExactlyInAnyOrder(serviceVertex0_2.getUniqueId(), serviceVertex0_1.getUniqueId(), serviceVertex0_3.getUniqueId(), serviceVertex0_4.getUniqueId(), serviceVertex0_5.getUniqueId()); + assertThat(actionStatus.left().value()).containsExactlyInAnyOrder(serviceVertex0_2.getUniqueId(), serviceVertex0_1.getUniqueId(), + serviceVertex0_3.getUniqueId(), serviceVertex0_4.getUniqueId(), serviceVertex0_5.getUniqueId()); assertArchived(serviceVertex0_1.getUniqueId()); assertArchived(serviceVertex0_2.getUniqueId()); assertArchived(serviceVertex0_3.getUniqueId()); @@ -174,13 +165,14 @@ public class ArchiveOperationTest extends ModelTestBase { actionStatus = this.archiveOperation.restoreComponent(serviceVertex0_2.getUniqueId()); assertThat(actionStatus.isLeft()).isTrue(); - assertThat(actionStatus.left().value()).containsExactlyInAnyOrder(serviceVertex0_2.getUniqueId(), serviceVertex0_1.getUniqueId(), serviceVertex0_3.getUniqueId(), serviceVertex0_4.getUniqueId(), serviceVertex0_5.getUniqueId()); + assertThat(actionStatus.left().value()).containsExactlyInAnyOrder(serviceVertex0_2.getUniqueId(), serviceVertex0_1.getUniqueId(), + serviceVertex0_3.getUniqueId(), serviceVertex0_4.getUniqueId(), serviceVertex0_5.getUniqueId()); } /////////////// Continue Here ////////////////// @Test - public void testScenario4_archiveFromNonHighest(){ + public void testScenario4_archiveFromNonHighest() { Either, ActionStatus> actionStatus = this.archiveOperation.archiveComponent(serviceVertex0_2.getUniqueId()); assertArchived(serviceVertex0_1.getUniqueId()); assertArchived(serviceVertex0_2.getUniqueId()); @@ -197,14 +189,14 @@ public class ArchiveOperationTest extends ModelTestBase { } @Test - public void testArchiveFailsWhenHighestVersionIsInCheckoutState(){ + public void testArchiveFailsWhenHighestVersionIsInCheckoutState() { checkoutComponent(serviceVertex0_5); Either, ActionStatus> actionStatus = this.archiveOperation.archiveComponent(serviceVertex0_2.getUniqueId()); assertThat(actionStatus.right().value()).isEqualTo(ActionStatus.INVALID_SERVICE_STATE); } @Test - public void testScenario3_archive_3_0(){ + public void testScenario3_archive_3_0() { Either, ActionStatus> actionStatus = this.archiveOperation.archiveComponent(serviceVertex3_0.getUniqueId()); assertArchived(serviceVertex3_0.getUniqueId()); assertArchived(serviceVertex3_1.getUniqueId()); @@ -212,7 +204,7 @@ public class ArchiveOperationTest extends ModelTestBase { } @Test - public void testArchivedOriginsCalculation(){ + public void testArchivedOriginsCalculation() { //Archive the CP resource this.archiveOperation.archiveComponent(this.compositionResource1.getUniqueId()); @@ -242,7 +234,7 @@ public class ArchiveOperationTest extends ModelTestBase { } @Test - public void testNoArchivedOriginsCalculation(){ + public void testNoArchivedOriginsCalculation() { List ciWithArchivedOrigins = this.archiveOperation.setArchivedOriginsFlagInComponentInstances(this.compositionService); //Validate that method returns the CI of CP @@ -250,7 +242,7 @@ public class ArchiveOperationTest extends ModelTestBase { } @Test - public void testOnVspArchivedAndRestored(){ + public void testOnVspArchivedAndRestored() { this.archiveOperation.onVspArchived(csarUuid); //assertOnCommit(); @@ -290,7 +282,7 @@ public class ArchiveOperationTest extends ModelTestBase { assertOnCommit(); } - private void assertOnCommit(){ + private void assertOnCommit() { final JanusGraphOperationStatus commit = this.janusGraphDao.commit(); assertThat(commit).isEqualTo(JanusGraphOperationStatus.OK); } @@ -303,7 +295,7 @@ public class ArchiveOperationTest extends ModelTestBase { assertArchivedOrRestored(ArchiveOperation.Action.RESTORE, componentUniqueId); } - private void assertArchivedOrRestored(ArchiveOperation.Action action, String componentUniqueId) { + private void assertArchivedOrRestored(ArchiveOperation.Action action, String componentUniqueId) { GraphVertex v = janusGraphDao.getVertexById(componentUniqueId).left().value(); EdgeLabelEnum requiredEdge = action == ArchiveOperation.Action.ARCHIVE ? EdgeLabelEnum.ARCHIVE_ELEMENT : EdgeLabelEnum.CATALOG_ELEMENT; @@ -317,7 +309,8 @@ public class ArchiveOperationTest extends ModelTestBase { parent = janusGraphDao.getParentVertex(v, requiredEdge, JsonParseFlagEnum.NoParse).left().value(); otherLookup = janusGraphDao.getParentVertex(v, otherEdge, JsonParseFlagEnum.NoParse); assertThat(otherLookup.isRight()).isTrue(); //Verify that component is not linked to Catalog/Archive Root - assertThat(parent.getUniqueId()).isEqualTo(action == ArchiveOperation.Action.ARCHIVE ? this.archiveVertex.getUniqueId() : this.catalogVertex.getUniqueId()); //Verify that parent is indeed Archive Root + assertThat(parent.getUniqueId()).isEqualTo(action == ArchiveOperation.Action.ARCHIVE ? this.archiveVertex.getUniqueId() + : this.catalogVertex.getUniqueId()); //Verify that parent is indeed Archive Root } assertArchivedOrRestoredProps(action, v); @@ -325,13 +318,13 @@ public class ArchiveOperationTest extends ModelTestBase { private void assertArchivedProps(String uniqueId) { GraphVertex v = - janusGraphDao.getVertexById(uniqueId).left().value(); + janusGraphDao.getVertexById(uniqueId).left().value(); assertArchivedOrRestoredProps(ArchiveOperation.Action.ARCHIVE, v); } private void assertRestoredProps(String uniqueId) { GraphVertex v = - janusGraphDao.getVertexById(uniqueId).left().value(); + janusGraphDao.getVertexById(uniqueId).left().value(); assertArchivedOrRestoredProps(ArchiveOperation.Action.RESTORE, v); } @@ -418,7 +411,7 @@ public class ArchiveOperationTest extends ModelTestBase { .createEdge(catalogVertex, serviceVertex0_5, EdgeLabelEnum.CATALOG_ELEMENT, null); } - private void createResourcesForArchivedVsp(){ + private void createResourcesForArchivedVsp() { Map vfPropsNonHighest = propsForNonHighestVersion(); Map vfPropsHighest = propsForNonHighestVersion(); @@ -443,7 +436,7 @@ public class ArchiveOperationTest extends ModelTestBase { janusGraphDao.createEdge(archiveVertex, archivedVertex1, EdgeLabelEnum.ARCHIVE_ELEMENT, null); } - private void createServiceCompositionForCalculatingArchivedOrigins(){ + private void createServiceCompositionForCalculatingArchivedOrigins() { //Service that point to another service in composition this.compositionService = GraphTestUtils.createServiceVertex(janusGraphDao, propsForHighestVersion()); this.compositionAnotherService = GraphTestUtils.createServiceVertex(janusGraphDao, propsForHighestVersion()); @@ -487,7 +480,7 @@ public class ArchiveOperationTest extends ModelTestBase { instance.setUniqueId(CI_UID_SVC_PROXY); instance.setComponentUid(compositionServiceProxy.getUniqueId()); instances.put(CI_UID_SVC_PROXY, instance); - + //Add Instances to Composition composition.setComponentInstances(instances); //Add to full composition @@ -498,14 +491,14 @@ public class ArchiveOperationTest extends ModelTestBase { janusGraphDao.updateVertex(compositionService); } - private Map propsForHighestVersion(){ + private Map propsForHighestVersion() { Map props = new HashMap(); props.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true); props.put(GraphPropertyEnum.STATE, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); return props; } - private Map propsForNonHighestVersion(){ + private Map propsForNonHighestVersion() { Map props = new HashMap(); props.put(GraphPropertyEnum.IS_HIGHEST_VERSION, false); props.put(GraphPropertyEnum.STATE, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ExternalReferencesOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ExternalReferencesOperationTest.java index 2febef610f..505c13f2b6 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ExternalReferencesOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ExternalReferencesOperationTest.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,16 +20,25 @@ package org.openecomp.sdc.be.model.jsonjanusgraph.operations; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; + import fj.data.Either; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.annotation.Resource; +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.mockito.Mockito; import org.openecomp.sdc.be.dao.api.ActionStatus; +import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; -import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao; import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum; import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum; import org.openecomp.sdc.be.datatypes.elements.MapComponentInstanceExternalRefs; @@ -37,20 +46,12 @@ import org.openecomp.sdc.be.model.ModelTestBase; import org.openecomp.sdc.be.model.jsonjanusgraph.utils.GraphTestUtils; import org.openecomp.sdc.be.model.jsonjanusgraph.utils.IdMapper; import org.openecomp.sdc.be.model.operations.StorageException; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import javax.annotation.Resource; -import java.util.*; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.when; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; /** * Created by yavivi on 26/01/2018. */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration("classpath:application-context-test.xml") +@SpringJUnitConfig(locations = "classpath:application-context-test.xml") public class ExternalReferencesOperationTest extends ModelTestBase { private static final String COMPONENT_ID = "ci-MyComponentName"; @@ -83,12 +84,12 @@ public class ExternalReferencesOperationTest extends ModelTestBase { private IdMapper idMapper; - @BeforeClass - public static void initTest(){ + @BeforeAll + public static void initTest() { ModelTestBase.init(); } - @Before + @BeforeEach public void beforeTest() { idMapper = Mockito.mock(IdMapper.class); this.externalReferenceOperation.setIdMapper(idMapper); @@ -101,8 +102,9 @@ public class ExternalReferencesOperationTest extends ModelTestBase { } @Test - public void testAddComponentInstanceExternalRef(){ - Either addResult = externalReferenceOperation.addExternalReference(this.serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_4); + public void testAddComponentInstanceExternalRef() { + Either addResult = externalReferenceOperation.addExternalReference(this.serviceVertexUuid, COMPONENT_ID, + MONITORING_OBJECT_TYPE, REF_4); assertThat(addResult.isLeft()).isEqualTo(true); //commit changes to janusgraph @@ -145,31 +147,38 @@ public class ExternalReferencesOperationTest extends ModelTestBase { assertThat(allExternalReferences.size()).isZero(); } - @Test(expected=StorageException.class) + @Test public void testGetAllCIExternalRefs_nonExitingService_throwsException() { - externalReferenceOperation.getAllExternalReferences("FAKE", COMPONENT_ID); + Assertions.assertThrows(StorageException.class, () -> externalReferenceOperation.getAllExternalReferences("FAKE", COMPONENT_ID)); } @Test - public void testGetComponentInstanceExternalRef(){ - assertThat(externalReferenceOperation.getExternalReferences(this.serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE).left().value()).contains(REF_1, REF_2, REF_3, REF_5); - assertThat(externalReferenceOperation.getExternalReferences(this.serviceVertexUuid, COMPONENT_ID, WORKFLOW_OBJECT_TYPE).left().value()).containsExactly(REF_6); + public void testGetComponentInstanceExternalRef() { + assertThat( + externalReferenceOperation.getExternalReferences(this.serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE).left().value()).contains( + REF_1, REF_2, REF_3, REF_5); + assertThat(externalReferenceOperation.getExternalReferences(this.serviceVertexUuid, COMPONENT_ID, WORKFLOW_OBJECT_TYPE).left() + .value()).containsExactly(REF_6); } @Test - public void testGetComponentInstanceExternalRefForNonExistingObjectId(){ - assertThat(externalReferenceOperation.getExternalReferences(this.serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE).left().value()).contains(REF_1, REF_2, REF_3, REF_5); - Either, ActionStatus> getResult = externalReferenceOperation.getExternalReferences(this.serviceVertexUuid, COMPONENT_ID, "FAKE_OBJECT_TYPE"); + public void testGetComponentInstanceExternalRefForNonExistingObjectId() { + assertThat( + externalReferenceOperation.getExternalReferences(this.serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE).left().value()).contains( + REF_1, REF_2, REF_3, REF_5); + Either, ActionStatus> getResult = externalReferenceOperation.getExternalReferences(this.serviceVertexUuid, COMPONENT_ID, + "FAKE_OBJECT_TYPE"); assertThat(getResult.left().value()).isEmpty(); } @Test - public void testDeleteComponentInstanceExternalRef(){ + public void testDeleteComponentInstanceExternalRef() { //Test the precondition assertThat(getServiceExternalRefs()).contains(REF_5); //Remove REF 5 - Either deleteStatus = externalReferenceOperation.deleteExternalReference(this.serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_5); + Either deleteStatus = externalReferenceOperation.deleteExternalReference(this.serviceVertexUuid, COMPONENT_ID, + MONITORING_OBJECT_TYPE, REF_5); assertThat(deleteStatus.isLeft()).isEqualTo(true); //commit changes to janusgraph @@ -181,12 +190,13 @@ public class ExternalReferencesOperationTest extends ModelTestBase { } @Test - public void testUpdateComponentInstanceExternalRef(){ + public void testUpdateComponentInstanceExternalRef() { //Test the precondition assertThat(getServiceExternalRefs()).contains(REF_5).doesNotContain(REF_4); //Update REF 5 with REF_4 - Either updateResult = externalReferenceOperation.updateExternalReference(this.serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_5, REF_4); + Either updateResult = externalReferenceOperation.updateExternalReference(this.serviceVertexUuid, COMPONENT_ID, + MONITORING_OBJECT_TYPE, REF_5, REF_4); assertThat(updateResult.isLeft()).isEqualTo(true); @@ -198,7 +208,7 @@ public class ExternalReferencesOperationTest extends ModelTestBase { assertThat(getServiceExternalRefs()).doesNotContain(REF_5).contains(REF_1, REF_2, REF_3, REF_4); } - private List getServiceExternalRefs(){ + private List getServiceExternalRefs() { //Get service vertex final Either externalRefsVertexResult = this.janusGraphDao .getChildVertex(this.serviceVertex, EdgeLabelEnum.EXTERNAL_REFS, JsonParseFlagEnum.ParseJson); diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/GroupsOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/GroupsOperationTest.java index bad361562b..ab4e991b7f 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/GroupsOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/GroupsOperationTest.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. @@ -25,15 +25,14 @@ import static org.assertj.core.api.Assertions.assertThat; import fj.data.Either; import java.util.List; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openecomp.sdc.be.dao.config.JanusGraphSpringConfig; -import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphDao; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; +import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentParametersView; import org.openecomp.sdc.be.model.GroupDefinition; @@ -42,30 +41,26 @@ import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.config.ModelOperationsSpringConfig; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {JanusGraphSpringConfig.class, ModelOperationsSpringConfig.class}) +@SpringJUnitConfig(classes = {JanusGraphSpringConfig.class, ModelOperationsSpringConfig.class}) public class GroupsOperationTest extends ModelTestBase { @Autowired - private GroupsOperation groupsOperation; - + private HealingJanusGraphDao janusGraphDao; @Autowired - HealingJanusGraphDao janusGraphDao; - + private GroupsOperation groupsOperation; @Autowired private ToscaOperationFacade toscaOperationFacade; private Component container; - @BeforeClass + @BeforeAll public static void initClass() { ModelTestBase.init(); } - @Before + @BeforeEach public void setUp() throws Exception { container = new Resource(); container.setUniqueId(CONTAINER_ID); @@ -74,7 +69,7 @@ public class GroupsOperationTest extends ModelTestBase { } - @After + @AfterEach public void tearDown() throws Exception { janusGraphDao.rollback(); } @@ -90,8 +85,8 @@ public class GroupsOperationTest extends ModelTestBase { getGroupsFilter.setIgnoreGroups(false); Component cmptWithGroups = toscaOperationFacade.getToscaElement(CONTAINER_ID, getGroupsFilter).left().value(); assertThat(cmptWithGroups.getGroups()) - .usingElementComparatorOnFields("name", "uniqueId") - .containsExactlyInAnyOrder(g1, g2); + .usingElementComparatorOnFields("name", "uniqueId") + .containsExactlyInAnyOrder(g1, g2); } @Test @@ -109,8 +104,8 @@ public class GroupsOperationTest extends ModelTestBase { getGroupsFilter.setIgnoreGroups(false); Component cmptWithGroups = toscaOperationFacade.getToscaElement(CONTAINER_ID, getGroupsFilter).left().value(); assertThat(cmptWithGroups.getGroups()) - .usingElementComparatorOnFields("name", "uniqueId") - .containsExactlyInAnyOrder(g1, g2, g3, g4); + .usingElementComparatorOnFields("name", "uniqueId") + .containsExactlyInAnyOrder(g1, g2, g3, g4); } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/InterfaceOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/InterfaceOperationTest.java index 4925c87ce4..7353c511db 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/InterfaceOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/InterfaceOperationTest.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. @@ -31,15 +31,14 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Resource; -import org.junit.After; import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; -import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao; import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum; import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; import org.openecomp.sdc.be.datatypes.elements.MapDataDefinition; @@ -64,11 +63,9 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.utils.GraphTestUtils; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder; import org.openecomp.sdc.common.util.ValidationUtils; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration("classpath:application-context-test.xml") +@SpringJUnitConfig(locations = "classpath:application-context-test.xml") public class InterfaceOperationTest extends ModelTestBase { private static final String RESOURCE_NAME = "Resource Name"; @@ -91,12 +88,12 @@ public class InterfaceOperationTest extends ModelTestBase { private ToscaElementLifecycleOperation lifecycleOperation; private GraphVertex ownerVertex; - @BeforeClass + @BeforeAll public static void initInterfacesOperation() { init(); } - @Before + @BeforeEach public void setupBefore() { GraphTestUtils.clearGraph(janusGraphDao); createUsers(); @@ -149,7 +146,7 @@ public class InterfaceOperationTest extends ModelTestBase { metadataProperties.put(GraphPropertyEnum.LABEL, VertexTypeEnum.RESOURCE_CATEGORY.getName()); metadataProperties.put(GraphPropertyEnum.NAME, categoryName); metadataProperties - .put(GraphPropertyEnum.NORMALIZED_NAME, ValidationUtils.normalizeCategoryName4Uniqueness(categoryName)); + .put(GraphPropertyEnum.NORMALIZED_NAME, ValidationUtils.normalizeCategoryName4Uniqueness(categoryName)); cat.setMetadataProperties(metadataProperties); cat.updateMetadataJsonWithCurrentMetadataProperties(); @@ -161,14 +158,14 @@ public class InterfaceOperationTest extends ModelTestBase { metadataProperties.put(GraphPropertyEnum.LABEL, VertexTypeEnum.RESOURCE_SUBCATEGORY.getName()); metadataProperties.put(GraphPropertyEnum.NAME, subcategory); metadataProperties - .put(GraphPropertyEnum.NORMALIZED_NAME, ValidationUtils.normalizeCategoryName4Uniqueness(subcategory)); + .put(GraphPropertyEnum.NORMALIZED_NAME, ValidationUtils.normalizeCategoryName4Uniqueness(subcategory)); subCat.setMetadataProperties(metadataProperties); subCat.updateMetadataJsonWithCurrentMetadataProperties(); Either catRes = janusGraphDao.createVertex(cat); Either subCatRes = janusGraphDao.createVertex(subCat); janusGraphDao.createEdge(catRes.left().value().getVertex(), subCatRes.left().value().getVertex(), - EdgeLabelEnum.SUB_CATEGORY, new HashMap<>()); + EdgeLabelEnum.SUB_CATEGORY, new HashMap<>()); } private void createServiceCategory() { @@ -180,7 +177,7 @@ public class InterfaceOperationTest extends ModelTestBase { metadataProperties.put(GraphPropertyEnum.LABEL, VertexTypeEnum.SERVICE_CATEGORY.getName()); metadataProperties.put(GraphPropertyEnum.NAME, categoryName); metadataProperties - .put(GraphPropertyEnum.NORMALIZED_NAME, ValidationUtils.normalizeCategoryName4Uniqueness(categoryName)); + .put(GraphPropertyEnum.NORMALIZED_NAME, ValidationUtils.normalizeCategoryName4Uniqueness(categoryName)); cat.setMetadataProperties(metadataProperties); cat.updateMetadataJsonWithCurrentMetadataProperties(); janusGraphDao.createVertex(cat); @@ -197,7 +194,7 @@ public class InterfaceOperationTest extends ModelTestBase { vf.getMetadata().put(JsonPresentationFields.VERSION.getPresentation(), "1.0"); vf.getMetadata().put(JsonPresentationFields.TYPE.getPresentation(), ResourceTypeEnum.VFC.name()); vf.getMetadata() - .put(JsonPresentationFields.LIFECYCLE_STATE.getPresentation(), LifecycleStateEnum.CERTIFIED.name()); + .put(JsonPresentationFields.LIFECYCLE_STATE.getPresentation(), LifecycleStateEnum.CERTIFIED.name()); vf.getMetadata().put(JsonPresentationFields.TOSCA_RESOURCE_NAME.getPresentation(), "root"); vf.getMetadata().put(JsonPresentationFields.HIGHEST_VERSION.getPresentation(), true); @@ -236,7 +233,7 @@ public class InterfaceOperationTest extends ModelTestBase { Either createVFRes = nodeTypeOperation.createNodeType(vf); Either getNodeTyeRes = - janusGraphDao.getVertexById(createVFRes.left().value().getUniqueId()); + janusGraphDao.getVertexById(createVFRes.left().value().getUniqueId()); getNodeTyeRes.left().value(); } @@ -280,10 +277,10 @@ public class InterfaceOperationTest extends ModelTestBase { Either createVFRes = nodeTypeOperation.createNodeType(vf); Either getNodeTyeRes = - janusGraphDao.getVertexById(createVFRes.left().value().getUniqueId()); + janusGraphDao.getVertexById(createVFRes.left().value().getUniqueId()); GraphVertex vfVertex = getNodeTyeRes.left().value(); StorageOperationStatus status = nodeTypeOperation.addToscaDataToToscaElement(vfVertex, EdgeLabelEnum.PROPERTIES, - VertexTypeEnum.PROPERTIES, addProperties, JsonPresentationFields.NAME); + VertexTypeEnum.PROPERTIES, addProperties, JsonPresentationFields.NAME); assertSame(StorageOperationStatus.OK, status); PropertyDataDefinition prop33 = new PropertyDataDefinition(); @@ -291,8 +288,8 @@ public class InterfaceOperationTest extends ModelTestBase { prop33.setDefaultValue("def33"); status = nodeTypeOperation - .addToscaDataToToscaElement(vfVertex, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, - prop33, JsonPresentationFields.NAME); + .addToscaDataToToscaElement(vfVertex, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, + prop33, JsonPresentationFields.NAME); assertSame(StorageOperationStatus.OK, status); PropertyDataDefinition prop44 = new PropertyDataDefinition(); @@ -300,7 +297,7 @@ public class InterfaceOperationTest extends ModelTestBase { prop44.setDefaultValue("def44"); status = nodeTypeOperation.addToscaDataToToscaElement(vfVertex.getUniqueId(), EdgeLabelEnum.PROPERTIES, - VertexTypeEnum.PROPERTIES, prop44, JsonPresentationFields.NAME); + VertexTypeEnum.PROPERTIES, prop44, JsonPresentationFields.NAME); assertSame(StorageOperationStatus.OK, status); PropertyDataDefinition capProp = new PropertyDataDefinition(); @@ -314,13 +311,13 @@ public class InterfaceOperationTest extends ModelTestBase { capProps.put("capName", dataToCreate); nodeTypeOperation.associateElementToData(vfVertex, VertexTypeEnum.CAPABILITIES_PROPERTIES, - EdgeLabelEnum.CAPABILITIES_PROPERTIES, capProps); + EdgeLabelEnum.CAPABILITIES_PROPERTIES, capProps); List pathKeys = new ArrayList<>(); pathKeys.add("capName"); capProp.setDefaultValue("BBBB"); nodeTypeOperation.updateToscaDataDeepElementOfToscaElement(vfVertex, EdgeLabelEnum.CAPABILITIES_PROPERTIES, - VertexTypeEnum.CAPABILITIES_PROPERTIES, capProp, pathKeys, JsonPresentationFields.NAME); + VertexTypeEnum.CAPABILITIES_PROPERTIES, capProp, pathKeys, JsonPresentationFields.NAME); } private void createTopologyTemplate(String name) { @@ -341,14 +338,14 @@ public class InterfaceOperationTest extends ModelTestBase { service.setComponentType(ComponentTypeEnum.SERVICE); Either createRes = - topologyTemplateOperation.createTopologyTemplate(service); + topologyTemplateOperation.createTopologyTemplate(service); Either getNodeTyeRes = - janusGraphDao.getVertexById(createRes.left().value().getUniqueId()); + janusGraphDao.getVertexById(createRes.left().value().getUniqueId()); getNodeTyeRes.left().value(); } - @After + @AfterEach public void cleanAfter() { GraphTestUtils.clearGraph(janusGraphDao); } @@ -361,9 +358,9 @@ public class InterfaceOperationTest extends ModelTestBase { private void testAddSingleInterface(Component component) { InterfaceDefinition interfaceDefinition = buildInterfaceDefinition("1"); Either, StorageOperationStatus> res = interfaceOperation - .addInterfaces(component.getUniqueId(), - Collections.singletonList( - interfaceDefinition)); + .addInterfaces(component.getUniqueId(), + Collections.singletonList( + interfaceDefinition)); Assert.assertTrue(res.isLeft()); Assert.assertEquals("1", res.left().value().get(0).getUniqueId()); } @@ -402,7 +399,7 @@ public class InterfaceOperationTest extends ModelTestBase { interfaceDefinitions.add(interfaceDefinition1); interfaceDefinitions.add(interfaceDefinition2); Either, StorageOperationStatus> res = - interfaceOperation.addInterfaces(component.getUniqueId(), interfaceDefinitions); + interfaceOperation.addInterfaces(component.getUniqueId(), interfaceDefinitions); Assert.assertTrue(res.isLeft()); Assert.assertEquals(2, res.left().value().size()); } @@ -415,16 +412,16 @@ public class InterfaceOperationTest extends ModelTestBase { private void testUpdateInterface(Component component) { InterfaceDefinition interfaceDefinition = buildInterfaceDefinition("1"); Either, StorageOperationStatus> res = interfaceOperation - .addInterfaces(component.getUniqueId(), - Collections.singletonList( - interfaceDefinition)); + .addInterfaces(component.getUniqueId(), + Collections.singletonList( + interfaceDefinition)); Assert.assertTrue(res.isLeft()); List value = res.left().value(); InterfaceDefinition createdInterfaceDef = value.get(0); String newDescription = "New Description"; createdInterfaceDef.setDescription(newDescription); res = interfaceOperation - .updateInterfaces(component.getUniqueId(), Collections.singletonList(createdInterfaceDef)); + .updateInterfaces(component.getUniqueId(), Collections.singletonList(createdInterfaceDef)); assertTrue(res.isLeft()); assertEquals(newDescription, res.left().value().get(0).getDescription()); } @@ -442,13 +439,13 @@ public class InterfaceOperationTest extends ModelTestBase { private void testDeleteInterface(Component component) { InterfaceDefinition interfaceDefinition = buildInterfaceDefinition("1"); Either, StorageOperationStatus> res = interfaceOperation - .addInterfaces(component.getUniqueId(), - Collections.singletonList( - interfaceDefinition)); + .addInterfaces(component.getUniqueId(), + Collections.singletonList( + interfaceDefinition)); Assert.assertTrue(res.isLeft()); List value = res.left().value(); Either deleteInterfaceOperationRes = - interfaceOperation.deleteInterface(component.getUniqueId(), value.get(0).getUniqueId()); + interfaceOperation.deleteInterface(component.getUniqueId(), value.get(0).getUniqueId()); assertTrue(deleteInterfaceOperationRes.isLeft()); } @@ -463,7 +460,7 @@ public class InterfaceOperationTest extends ModelTestBase { InterfaceDefinition interfaceDefinition = buildInterfaceDefinitionWithoutOperation(); interfaceDefinition.setOperationsMap(createMockOperationMap()); Either, StorageOperationStatus> res = interfaceOperation.updateInterfaces( - component.getUniqueId(), Collections.singletonList(interfaceDefinition)); + component.getUniqueId(), Collections.singletonList(interfaceDefinition)); Assert.assertTrue(res.isRight()); } @@ -499,7 +496,7 @@ public class InterfaceOperationTest extends ModelTestBase { } private InterfaceDefinition createInterface(String uniqueId, String description, String type, - String toscaResourceName, Map op) { + String toscaResourceName, Map op) { InterfaceDefinition id = new InterfaceDefinition(); id.setType(type); id.setDescription(description); @@ -509,7 +506,7 @@ public class InterfaceOperationTest extends ModelTestBase { return id; } - @After + @AfterEach public void teardown() { GraphTestUtils.clearGraph(janusGraphDao); } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperationGraphTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperationGraphTest.java index 576aa8a680..b2db75933a 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperationGraphTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperationGraphTest.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. @@ -25,8 +25,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import org.janusgraph.core.JanusGraph; -import org.janusgraph.core.JanusGraphVertex; import fj.data.Either; import java.io.BufferedOutputStream; import java.io.File; @@ -42,15 +40,16 @@ import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.Edge; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.apache.tinkerpop.gremlin.structure.io.IoCore; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.janusgraph.core.JanusGraph; +import org.janusgraph.core.JanusGraphVertex; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openecomp.sdc.be.dao.config.JanusGraphSpringConfig; +import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphDao; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; -import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphDao; import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum; import org.openecomp.sdc.be.dao.jsongraph.types.EdgePropertyEnum; import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; @@ -59,100 +58,99 @@ import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum; import org.openecomp.sdc.be.model.ModelTestBase; import org.openecomp.sdc.be.model.config.ModelOperationsSpringConfig; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {JanusGraphSpringConfig.class, ModelOperationsSpringConfig.class}) -public class NodeTemplateOperationGraphTest extends ModelTestBase{ +@SpringJUnitConfig(classes = {JanusGraphSpringConfig.class, ModelOperationsSpringConfig.class}) +public class NodeTemplateOperationGraphTest extends ModelTestBase { + + String outputDirectory = "C:\\Output"; @Resource private HealingJanusGraphDao janusGraphDao; @Resource private NodeTemplateOperation nodeTemplateOperation; - private JanusGraph graphT; - private GraphVertex containerVertex; + private GraphVertex containerVertex; private String containeId; - - @BeforeClass + + @BeforeAll public static void setupBeforeClass() { ModelTestBase.init(); } - @Before - public void before(){ - + + @BeforeEach + public void before() { + Either graph = janusGraphDao.getGraph(); graphT = graph.left().value(); - + containerVertex = new GraphVertex(VertexTypeEnum.TOPOLOGY_TEMPLATE); containeId = "containerId"; containerVertex.setUniqueId(containeId); Either createVertex = janusGraphDao.createVertex(containerVertex); assertTrue(createVertex.isLeft()); } - - @After - public void after(){ + + @AfterEach + public void after() { janusGraphDao.rollback(); - + } - - - String outputDirectory = "C:\\Output"; - + @Test - public void testCreateInstanceEdge(){ - + public void testCreateInstanceEdge() { + Map> mapOriginToInstId = new HashMap<>(); createIntancesFromSameResource(mapOriginToInstId, 1, 3); createIntancesFromSameResource(mapOriginToInstId, 2, 4); createIntancesFromSameResource(mapOriginToInstId, 3, 1); - + // exportGraphMl(graphT); - + validateOnGraph(mapOriginToInstId, 3); } - + @Test - public void testRemoveInstanceEdge(){ + public void testRemoveInstanceEdge() { //create 3 instances from same resource orig1 Map> mapOriginToInstId = new HashMap<>(); String originId = createIntancesFromSameResource(mapOriginToInstId, 1, 3); validateOnGraph(mapOriginToInstId, 1); - + //remove instance 2 - String instanceId = removeInstanceEdge(containerVertex, originId, 1, 1); + String instanceId = removeInstanceEdge(containerVertex, originId, 1, 1); mapOriginToInstId.get(originId).remove(instanceId); validateOnGraph(mapOriginToInstId, 1); - + //create new instance from orig1 - instanceId = createInstanceEdge(containerVertex, originId, 1, 4, false, null); + instanceId = createInstanceEdge(containerVertex, originId, 1, 4, false, null); mapOriginToInstId.get(originId).add(instanceId); validateOnGraph(mapOriginToInstId, 1); - + //create 1 instance from same resource orig2 originId = createIntancesFromSameResource(mapOriginToInstId, 2, 1); validateOnGraph(mapOriginToInstId, 2); - + //remove instance of orig 2 - instanceId = removeInstanceEdge(containerVertex, originId, 2, 1); + instanceId = removeInstanceEdge(containerVertex, originId, 2, 1); mapOriginToInstId.get(originId).remove(instanceId); validateOnGraph(mapOriginToInstId, 1); - + } - + @Test - public void testProxyInstanceEdge(){ + public void testProxyInstanceEdge() { Map> mapOriginToInstId = new HashMap<>(); - String proxyId = createOrigin(2); + String proxyId = createOrigin(2); createIntancesFromSameResource(mapOriginToInstId, 1, 1, true, proxyId); - - validateOnGraph(mapOriginToInstId, 1); + + validateOnGraph(mapOriginToInstId, 1); } + private void validateOnGraph(Map> mapOriginToInstId, int expectedEdgeCount) { validateOnGraph(mapOriginToInstId, expectedEdgeCount, false); } + private void validateOnGraph(Map> mapOriginToInstId, int expectedEdgeCount, boolean validateProxy) { Iterable vertices = graphT.query().has(GraphPropertyEnum.UNIQUE_ID.getProperty(), containeId).vertices(); assertNotNull(vertices); @@ -160,44 +158,46 @@ public class NodeTemplateOperationGraphTest extends ModelTestBase{ assertTrue(iterator.hasNext()); Vertex containerV = iterator.next(); validatePerEdgeType(mapOriginToInstId, expectedEdgeCount, containerV, EdgeLabelEnum.INSTANCE_OF); - if ( validateProxy ){ + if (validateProxy) { validatePerEdgeType(mapOriginToInstId, expectedEdgeCount, containerV, EdgeLabelEnum.PROXY_OF); } } + private void validatePerEdgeType(Map> mapOriginToInstId, int expectedEdgeCount, Vertex containerV, EdgeLabelEnum edgeLabel) { Iterator edges = containerV.edges(Direction.OUT, edgeLabel.name()); assertNotNull(edges); - + int counter = 0; - while (edges.hasNext()){ + while (edges.hasNext()) { Edge edge = edges.next(); counter++; validateEdge(edge, mapOriginToInstId); } assertEquals("check edge size", expectedEdgeCount, counter); } - - + + private String createIntancesFromSameResource(Map> mapOriginToInstId, int originIndex, int countInstances) { - return createIntancesFromSameResource(mapOriginToInstId, originIndex, countInstances, false, null); + return createIntancesFromSameResource(mapOriginToInstId, originIndex, countInstances, false, null); } - - private String createIntancesFromSameResource(Map> mapOriginToInstId, int originIndex, int countInstances, boolean isProxy, String proxyId) { - + + private String createIntancesFromSameResource(Map> mapOriginToInstId, int originIndex, int countInstances, boolean isProxy, + String proxyId) { + List exp = new ArrayList(); String originId = createOrigin(originIndex); - - for ( int i = 0; i < countInstances; i++){ - String instanceId = createInstanceEdge(containerVertex, originId, originIndex, i+1, isProxy, proxyId); + + for (int i = 0; i < countInstances; i++) { + String instanceId = createInstanceEdge(containerVertex, originId, originIndex, i + 1, isProxy, proxyId); exp.add(instanceId); } mapOriginToInstId.put(originId, exp); - if ( isProxy ){ - mapOriginToInstId.put(proxyId, exp); + if (isProxy) { + mapOriginToInstId.put(proxyId, exp); } return originId; } - + private String createInstanceEdge(GraphVertex containerVertex, String originId, int originIndex, int insIndex, boolean isProxy, String proxyId) { ComponentInstanceDataDefinition componentInstance = new ComponentInstanceDataDefinition(); componentInstance.setComponentUid(originId); @@ -209,12 +209,13 @@ public class NodeTemplateOperationGraphTest extends ModelTestBase{ assertEquals("assertion createInstanceEdge", StorageOperationStatus.OK, edgeStatus); return instanceId; } - + private String buildInstanceId(int originIndex, int insIndex) { StringBuilder sb = new StringBuilder("instanceId_"); sb.append(originIndex).append("-").append(insIndex); - return sb.toString(); + return sb.toString(); } + private String removeInstanceEdge(GraphVertex containerVertex, String originId, int originIndex, int insIndex) { ComponentInstanceDataDefinition componentInstance = new ComponentInstanceDataDefinition(); componentInstance.setComponentUid(originId); @@ -224,8 +225,8 @@ public class NodeTemplateOperationGraphTest extends ModelTestBase{ assertEquals("assertion removeInstanceEdge", StorageOperationStatus.OK, edgeStatus); return instanceId; } - - + + private String createOrigin(int index) { Either createVertex; GraphVertex originVertex = new GraphVertex(VertexTypeEnum.NODE_TYPE); @@ -235,18 +236,19 @@ public class NodeTemplateOperationGraphTest extends ModelTestBase{ assertTrue(createVertex.isLeft()); return originId; } + private void validateEdge(Edge edge, Map> mapOriginToInstId) { List expextedInList; - + Vertex originV = edge.inVertex(); - String id = (String) janusGraphDao.getProperty((JanusGraphVertex)originV, GraphPropertyEnum.UNIQUE_ID.getProperty()); + String id = (String) janusGraphDao.getProperty((JanusGraphVertex) originV, GraphPropertyEnum.UNIQUE_ID.getProperty()); expextedInList = mapOriginToInstId.get(id); - + List list = (List) janusGraphDao.getProperty(edge, EdgePropertyEnum.INSTANCES); assertThat(list).hasSameSizeAs(expextedInList); assertThat(list).containsOnlyElementsOf(expextedInList); } - + private String exportGraphMl(JanusGraph graph) { String result = null; String outputFile = outputDirectory + File.separator + "exportGraph." + System.currentTimeMillis() + ".graphml"; diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/PolicyOperationIntegrationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/PolicyOperationIntegrationTest.java index 37e360c5c2..64cad65301 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/PolicyOperationIntegrationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/PolicyOperationIntegrationTest.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,15 +20,22 @@ package org.openecomp.sdc.be.model.jsonjanusgraph.operations; +import static org.apache.commons.collections.ListUtils.union; +import static org.assertj.core.api.Assertions.assertThat; + import fj.data.Either; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import javax.annotation.Resource; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openecomp.sdc.be.dao.config.JanusGraphSpringConfig; -import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphDao; +import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum; import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; import org.openecomp.sdc.be.datatypes.elements.PolicyDataDefinition; @@ -43,24 +50,13 @@ import org.openecomp.sdc.be.model.config.ModelOperationsSpringConfig; import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.TopologyTemplate; import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElement; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -import javax.annotation.Resource; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static org.apache.commons.collections.ListUtils.union; -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {JanusGraphSpringConfig.class, ModelOperationsSpringConfig.class}) +@SpringJUnitConfig(classes = {JanusGraphSpringConfig.class, ModelOperationsSpringConfig.class}) public class PolicyOperationIntegrationTest extends ModelTestBase { - private static final String CONTAINER_ID = "container"; public static final String POLICY_ID = "policy"; + private static final String CONTAINER_ID = "container"; @Resource private TopologyTemplateOperation topologyTemplateOperation; @Resource @@ -70,13 +66,13 @@ public class PolicyOperationIntegrationTest extends ModelTestBase { private PropertyDataDefinition prop1, prop2; private PolicyDefinition policy; - @BeforeClass + @BeforeAll public static void setupBeforeClass() { ModelTestBase.init(); } - @Before + @BeforeEach public void setUp() throws Exception { prop1 = new PropertyDataDefinition(); prop1.setUniqueId("prop1"); @@ -97,11 +93,12 @@ public class PolicyOperationIntegrationTest extends ModelTestBase { resource.addMetadataProperty(GraphPropertyEnum.UNIQUE_ID, CONTAINER_ID); janusGraphDao.createVertex(resource); GraphVertex loadedResource = janusGraphDao.getVertexById(CONTAINER_ID).left().value(); - topologyTemplateOperation.addToscaDataToToscaElement(loadedResource, EdgeLabelEnum.POLICIES, VertexTypeEnum.POLICIES, policy, JsonPresentationFields.UNIQUE_ID); + topologyTemplateOperation.addToscaDataToToscaElement(loadedResource, EdgeLabelEnum.POLICIES, VertexTypeEnum.POLICIES, policy, + JsonPresentationFields.UNIQUE_ID); // janusGraphDao.commit(); } - @After + @AfterEach public void tearDown() { janusGraphDao.rollback(); } @@ -134,7 +131,8 @@ public class PolicyOperationIntegrationTest extends ModelTestBase { ComponentParametersView componentParametersView = new ComponentParametersView(); componentParametersView.disableAll(); componentParametersView.setIgnorePolicies(false); - Either loadedCmptEither = topologyTemplateOperation.getToscaElement(CONTAINER_ID, componentParametersView); + Either loadedCmptEither = topologyTemplateOperation.getToscaElement(CONTAINER_ID, + componentParametersView); assertThat(loadedCmptEither.isLeft()).isTrue(); ToscaElement loadedCmpt = loadedCmptEither.left().value(); @@ -148,6 +146,6 @@ public class PolicyOperationIntegrationTest extends ModelTestBase { PolicyDataDefinition policy = policies.get(POLICY_ID); List policyProperties = policy.getProperties(); assertThat(policyProperties).usingElementComparatorOnFields("value") - .containsAll(expectedUpdatedProperties); + .containsAll(expectedUpdatedProperties); } } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperationCapabilityIntegrationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperationCapabilityIntegrationTest.java index bfa3dd6175..5dbb96e4f2 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperationCapabilityIntegrationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperationCapabilityIntegrationTest.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,14 +20,20 @@ package org.openecomp.sdc.be.model.jsonjanusgraph.operations; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.annotation.Resource; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openecomp.sdc.be.dao.config.JanusGraphSpringConfig; -import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphDao; +import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum; import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; import org.openecomp.sdc.be.datatypes.elements.MapCapabilityProperty; @@ -40,19 +46,9 @@ import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.config.ModelOperationsSpringConfig; import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.TopologyTemplate; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -import javax.annotation.Resource; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {JanusGraphSpringConfig.class, ModelOperationsSpringConfig.class}) +@SpringJUnitConfig(classes = {JanusGraphSpringConfig.class, ModelOperationsSpringConfig.class}) public class TopologyTemplateOperationCapabilityIntegrationTest extends ModelTestBase { private static final String CONTAINER_ID = "id"; @@ -68,13 +64,13 @@ public class TopologyTemplateOperationCapabilityIntegrationTest extends ModelTes private CapabilityPropertyDataObject capabilityProperty2; private CapabilityPropertyDataObject capabilityProperty3; - @BeforeClass + @BeforeAll public static void setupBeforeClass() { ModelTestBase.init(); } - @Before + @BeforeEach public void setUp() throws Exception { capabilitiesPropsMap = new HashMap<>(); @@ -83,22 +79,24 @@ public class TopologyTemplateOperationCapabilityIntegrationTest extends ModelTes capabilityProperty3 = new CapabilityPropertyDataObject("instance2", "capability3", "prop3", "val3"); capabilitiesProperties = Arrays.asList(capabilityProperty1, capabilityProperty2, capabilityProperty3); - //capablities props == Map>> capabilitiesProperties.forEach(capabilitiesProperty -> { capabilitiesPropsMap.computeIfAbsent(capabilitiesProperty.getInstanceId(), k -> new MapCapabilityProperty(new HashMap<>())) - .getMapToscaDataDefinition().computeIfAbsent(capabilitiesProperty.getCapabilityId(), k -> new MapPropertiesDataDefinition(new HashMap<>())) - .getMapToscaDataDefinition().computeIfAbsent(capabilitiesProperty.getPropName(), k -> new PropertyDefinition(createPropWithValue(capabilitiesProperty.getPropValue()))); + .getMapToscaDataDefinition() + .computeIfAbsent(capabilitiesProperty.getCapabilityId(), k -> new MapPropertiesDataDefinition(new HashMap<>())) + .getMapToscaDataDefinition().computeIfAbsent(capabilitiesProperty.getPropName(), + k -> new PropertyDefinition(createPropWithValue(capabilitiesProperty.getPropValue()))); }); GraphVertex resource = new GraphVertex(VertexTypeEnum.TOPOLOGY_TEMPLATE); resource.addMetadataProperty(GraphPropertyEnum.UNIQUE_ID, CONTAINER_ID); janusGraphDao.createVertex(resource); GraphVertex loadedResource = janusGraphDao.getVertexById(CONTAINER_ID).left().value(); - topologyTemplateOperation.associateElementToData(loadedResource, VertexTypeEnum.CALCULATED_CAP_PROPERTIES, EdgeLabelEnum.CALCULATED_CAP_PROPERTIES, capabilitiesPropsMap).left().value(); + topologyTemplateOperation.associateElementToData(loadedResource, VertexTypeEnum.CALCULATED_CAP_PROPERTIES, + EdgeLabelEnum.CALCULATED_CAP_PROPERTIES, capabilitiesPropsMap).left().value(); } - @After + @AfterEach public void tearDown() { janusGraphDao.rollback(); } @@ -111,7 +109,8 @@ public class TopologyTemplateOperationCapabilityIntegrationTest extends ModelTes capabilityProperty3.setPropValue("newVal3"); setPropertyValue(capabilitiesPropsMap, capabilityProperty1); setPropertyValue(capabilitiesPropsMap, capabilityProperty3); - StorageOperationStatus storageOperationStatus = topologyTemplateOperation.overrideToscaDataOfToscaElement(CONTAINER_ID, EdgeLabelEnum.CALCULATED_CAP_PROPERTIES, capabilitiesPropsMap); + StorageOperationStatus storageOperationStatus = topologyTemplateOperation.overrideToscaDataOfToscaElement(CONTAINER_ID, + EdgeLabelEnum.CALCULATED_CAP_PROPERTIES, capabilitiesPropsMap); assertThat(storageOperationStatus).isEqualTo(StorageOperationStatus.OK); Map updatedCapPropsMap = fetchCapabilitiesProps(CONTAINER_ID); compareCapabilitiesProperties(capabilitiesProperties, updatedCapPropsMap); @@ -132,7 +131,8 @@ public class TopologyTemplateOperationCapabilityIntegrationTest extends ModelTes Component component = new org.openecomp.sdc.be.model.Resource(); component.setUniqueId(CONTAINER_ID); - StorageOperationStatus updateStatus = topologyTemplateOperation.updateToscaDataDeepElementsBlockToToscaElement(CONTAINER_ID, EdgeLabelEnum.CALCULATED_CAP_PROPERTIES, instance1Props, "instance1"); + StorageOperationStatus updateStatus = topologyTemplateOperation.updateToscaDataDeepElementsBlockToToscaElement(CONTAINER_ID, + EdgeLabelEnum.CALCULATED_CAP_PROPERTIES, instance1Props, "instance1"); assertThat(updateStatus).isEqualTo(StorageOperationStatus.OK); assertCapabilityPropValue(capabilityProperty1, "newVal1"); @@ -143,13 +143,15 @@ public class TopologyTemplateOperationCapabilityIntegrationTest extends ModelTes private Map fetchCapabilitiesProps(String containerId) { ComponentParametersView capabilityPropsFilter = new ComponentParametersView(true); capabilityPropsFilter.setIgnoreCapabiltyProperties(false); - return ((TopologyTemplate) topologyTemplateOperation.getToscaElement(containerId, capabilityPropsFilter).left().value()).getCalculatedCapabilitiesProperties(); + return ((TopologyTemplate) topologyTemplateOperation.getToscaElement(containerId, capabilityPropsFilter).left() + .value()).getCalculatedCapabilitiesProperties(); } private void compareCapabilitiesProperties(List expected, Map actual) { expected.forEach(expectedCapabilityProp -> { - assertThat(getPropertyValue(actual, expectedCapabilityProp.instanceId, expectedCapabilityProp.capabilityId, expectedCapabilityProp.propName)) - .isEqualTo(expectedCapabilityProp.propValue); + assertThat( + getPropertyValue(actual, expectedCapabilityProp.instanceId, expectedCapabilityProp.capabilityId, expectedCapabilityProp.propName)) + .isEqualTo(expectedCapabilityProp.propValue); }); } @@ -164,8 +166,8 @@ public class TopologyTemplateOperationCapabilityIntegrationTest extends ModelTes private void setPropertyValue(MapCapabilityProperty capabilitiesInstanceProperties, CapabilityPropertyDataObject capabilityProperty) { capabilitiesInstanceProperties.getMapToscaDataDefinition().get(capabilityProperty.getCapabilityId()) - .getMapToscaDataDefinition().get(capabilityProperty.getPropName()) - .setValue(capabilityProperty.getPropValue()); + .getMapToscaDataDefinition().get(capabilityProperty.getPropName()) + .setValue(capabilityProperty.getPropValue()); } private void assertCapabilityPropValue(CapabilityPropertyDataObject prop, String expectedValue) { @@ -182,6 +184,7 @@ public class TopologyTemplateOperationCapabilityIntegrationTest extends ModelTes } private static class CapabilityPropertyDataObject { + private String instanceId; private String capabilityId; private String propName; diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperationTest.java index 3da37c098a..821f23e191 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperationTest.java @@ -20,16 +20,24 @@ package org.openecomp.sdc.be.model.jsonjanusgraph.operations; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import fj.data.Either; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; -import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.junit.rules.TestName; -import org.junit.runner.RunWith; -import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao; +import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum; import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; @@ -44,42 +52,31 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.utils.GraphTestUtils; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.resources.data.EntryData; import org.openecomp.sdc.be.utils.TypeUtils; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import java.util.*; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; /** * Created by chaya on 6/12/2017. */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration("classpath:application-context-test.xml") +@SpringJUnitConfig(locations = "classpath:application-context-test.xml") public class ToscaElementOperationTest extends ModelTestBase { + @Rule + public TestName testName = new TestName(); private List allVertices = new ArrayList<>(); private boolean isInitialized = false; - @javax.annotation.Resource private ToscaElementOperationTestImpl toscaElementOperation; - @javax.annotation.Resource private JanusGraphDao janusGraphDao; - @BeforeClass + @BeforeAll public static void initTest() { ModelTestBase.init(); } - @Rule - public TestName testName = new TestName(); - - @Before + @BeforeEach public void beforeTest() { if (!isInitialized) { GraphTestUtils.clearGraph(janusGraphDao); diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacadePoliciesTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacadePoliciesTest.java index d60a574064..3cb2208c30 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacadePoliciesTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacadePoliciesTest.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,16 +20,25 @@ package org.openecomp.sdc.be.model.jsonjanusgraph.operations; +import static java.util.Arrays.asList; +import static java.util.Collections.singletonList; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertTrue; + import fj.data.Either; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openecomp.sdc.be.dao.config.JanusGraphSpringConfig; +import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphDao; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; -import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphDao; import org.openecomp.sdc.be.datatypes.elements.PolicyTargetType; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentParametersView; @@ -38,22 +47,9 @@ import org.openecomp.sdc.be.model.PolicyDefinition; import org.openecomp.sdc.be.model.config.ModelOperationsSpringConfig; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertTrue; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {JanusGraphSpringConfig.class, ModelOperationsSpringConfig.class}) +@SpringJUnitConfig(classes = {JanusGraphSpringConfig.class, ModelOperationsSpringConfig.class}) public class ToscaOperationFacadePoliciesTest extends ModelTestBase { @Autowired @@ -63,12 +59,12 @@ public class ToscaOperationFacadePoliciesTest extends ModelTestBase { private PolicyDefinition policy1, policy2; - @BeforeClass + @BeforeAll public static void setupBeforeClass() { ModelTestBase.init(); } - @Before + @BeforeEach public void setUp() throws Exception { policy1 = createPolicyDefinition("type1"); policy2 = createPolicyDefinition("type2"); @@ -76,7 +72,7 @@ public class ToscaOperationFacadePoliciesTest extends ModelTestBase { createPoliciesOnGraph(policy1, policy2); } - private void createPoliciesOnGraph(PolicyDefinition ... policies) { + private void createPoliciesOnGraph(PolicyDefinition... policies) { for (int i = 0; i < policies.length; i++) { PolicyDefinition policy = policies[i]; Either createdPolicy = toscaOperationFacade.associatePolicyToComponent(CONTAINER_ID, policy, i); @@ -84,7 +80,7 @@ public class ToscaOperationFacadePoliciesTest extends ModelTestBase { } } - @After + @AfterEach public void tearDown() { janusGraphDao.rollback(); } @@ -117,14 +113,15 @@ public class ToscaOperationFacadePoliciesTest extends ModelTestBase { private PolicyDefinition clonePolicyWithTargets(PolicyDefinition policy) { PolicyDefinition originalPolicy = new PolicyDefinition(policy); - Map> clonedTargetMap = policy.getTargets().entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> new ArrayList<>(entry.getValue()))); + Map> clonedTargetMap = policy.getTargets().entrySet().stream() + .collect(Collectors.toMap(Map.Entry::getKey, entry -> new ArrayList<>(entry.getValue()))); originalPolicy.setTargets(clonedTargetMap); return originalPolicy; } private void verifyPolicyTargets(PolicyDefinition updatedPolicy, PolicyDefinition expectedPolicy) { assertThat(updatedPolicy.getTargets()) - .isEqualTo(expectedPolicy.getTargets()); + .isEqualTo(expectedPolicy.getTargets()); } private void updatePolicyTypeTargetsIds(PolicyDefinition policy, PolicyTargetType targetType, List updatedTargetIds) { diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/UpgradeOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/UpgradeOperationTest.java index 1494f206f6..6a069a04b9 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/UpgradeOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/UpgradeOperationTest.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,12 +20,16 @@ package org.openecomp.sdc.be.model.jsonjanusgraph.operations; +import static org.assertj.core.api.Assertions.assertThat; + import fj.data.Either; +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Resource; import org.apache.commons.lang3.tuple.ImmutablePair; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao; import org.openecomp.sdc.be.dao.jsongraph.utils.IdBuilderUtils; @@ -33,7 +37,11 @@ import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; -import org.openecomp.sdc.be.model.*; +import org.openecomp.sdc.be.model.ComponentDependency; +import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.LifecycleStateEnum; +import org.openecomp.sdc.be.model.ModelTestBase; +import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.model.category.CategoryDefinition; import org.openecomp.sdc.be.model.category.SubCategoryDefinition; import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.TopologyTemplate; @@ -41,17 +49,9 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.utils.GraphTestUtils; import org.openecomp.sdc.be.model.operations.api.IElementOperation; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.UserAdminOperation; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.List; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration("classpath:application-context-test.xml") +@SpringJUnitConfig(locations = "classpath:application-context-test.xml") public class UpgradeOperationTest extends ModelTestBase { private boolean isInitialized; @@ -64,7 +64,7 @@ public class UpgradeOperationTest extends ModelTestBase { @Resource private NodeTemplateOperation nodeTemplateOperation; @Resource - private UserAdminOperation userAdminOperation; + private UserAdminOperation userAdminOperation; @javax.annotation.Resource private IElementOperation elementOperation; @@ -72,14 +72,14 @@ public class UpgradeOperationTest extends ModelTestBase { private CategoryDefinition resourceCategory; private CategoryDefinition serviceCategory; - - @BeforeClass + + @BeforeAll public static void initTest() { ModelTestBase.init(); } - @Before + @BeforeEach public void beforeTest() { if (!isInitialized) { GraphTestUtils.clearGraph(janusGraphDao); @@ -90,22 +90,21 @@ public class UpgradeOperationTest extends ModelTestBase { @Test public void testGetSimpleDependency() { - + TopologyTemplate vf = createVf("vf1"); - + TopologyTemplate service = createServiceWitnInstance("service1", vf); - Either, StorageOperationStatus> result = upgradeOperation.getComponentDependencies(vf.getUniqueId()); assertThat(result.isLeft()).isTrue(); List dependencies = result.left().value(); assertThat(dependencies).hasSize(1); - + ComponentDependency dependency = dependencies.get(0); assertThat(dependency.getName()).isEqualTo(vf.getName()); assertThat(dependency.getVersion()).isEqualTo(vf.getVersion()); assertThat(dependency.getDependencies()).hasSize(1); - + ComponentDependency container = dependency.getDependencies().get(0); assertThat(container.getName()).isEqualTo(service.getName()); assertThat(container.getVersion()).isEqualTo(service.getVersion()); @@ -123,12 +122,12 @@ public class UpgradeOperationTest extends ModelTestBase { GraphTestUtils.createRootCatalogVertex(janusGraphDao); resourceCategory = createResourceCategories(); - serviceCategory = createServiceCategory(); - + serviceCategory = createServiceCategory(); + } private TopologyTemplate createServiceWitnInstance(String name, TopologyTemplate createdVf) { - + TopologyTemplate serviceNew = createTopologyTemplate(ComponentTypeEnum.SERVICE, name); List categoriesService = new ArrayList<>(); categoriesService.add(serviceCategory); @@ -136,12 +135,13 @@ public class UpgradeOperationTest extends ModelTestBase { Either createService = topologyTemplateOperation.createTopologyTemplate(serviceNew); assertThat(createService.isLeft()).isTrue(); - + ComponentInstance vfInstance = new ComponentInstance(); vfInstance.setUniqueId(createdVf.getUniqueId() + createdVf.getName()); vfInstance.setComponentUid(createdVf.getUniqueId()); vfInstance.setName(createdVf.getName()); - Either, StorageOperationStatus> addInstance = nodeTemplateOperation.addComponentInstanceToTopologyTemplate(serviceNew, createdVf, "0", vfInstance, false, user); + Either, StorageOperationStatus> addInstance = nodeTemplateOperation.addComponentInstanceToTopologyTemplate( + serviceNew, createdVf, "0", vfInstance, false, user); assertThat(addInstance.isLeft()).isTrue(); return serviceNew; } @@ -151,14 +151,14 @@ public class UpgradeOperationTest extends ModelTestBase { categoryService.setName("servicecategory"); categoryService.setNormalizedName("servicecategory"); categoryService.setUniqueId("servicecategory"); - Either createCategory = elementOperation.createCategory(categoryService , NodeTypeEnum.ServiceNewCategory); - + Either createCategory = elementOperation.createCategory(categoryService, NodeTypeEnum.ServiceNewCategory); + assertThat(createCategory.isLeft()).isTrue(); return categoryService; } private TopologyTemplate createVf(String name) { - + TopologyTemplate resource = createTopologyTemplate(ComponentTypeEnum.RESOURCE, name); resource.setResourceType(ResourceTypeEnum.VF); @@ -166,7 +166,7 @@ public class UpgradeOperationTest extends ModelTestBase { categories.add(resourceCategory); resource.setCategories(categories); Either createVf = topologyTemplateOperation.createTopologyTemplate(resource); - assertThat( createVf.isLeft()).isTrue(); + assertThat(createVf.isLeft()).isTrue(); return resource; } @@ -175,11 +175,11 @@ public class UpgradeOperationTest extends ModelTestBase { category.setName("category1"); category.setNormalizedName("category1"); category.setUniqueId("category1"); - Either createCategory = elementOperation.createCategory(category , NodeTypeEnum.ResourceNewCategory); + Either createCategory = elementOperation.createCategory(category, NodeTypeEnum.ResourceNewCategory); assertThat(createCategory.isLeft()).isTrue(); - + SubCategoryDefinition subCategory = new SubCategoryDefinition(); - + subCategory.setName("subcategory1"); subCategory.setNormalizedName("subcategory1"); subCategory.setUniqueId("subcategory1"); diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/AdditionalInformationOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/AdditionalInformationOperationTest.java index 169a844e3a..b61ff3224b 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/AdditionalInformationOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/AdditionalInformationOperationTest.java @@ -20,16 +20,21 @@ package org.openecomp.sdc.be.model.operations.impl; -import org.janusgraph.core.JanusGraphEdge; -import org.janusgraph.core.JanusGraph; -import org.janusgraph.core.JanusGraphVertex; -import fj.data.Either; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import fj.data.Either; +import java.util.Iterator; +import org.janusgraph.core.JanusGraph; +import org.janusgraph.core.JanusGraphEdge; +import org.janusgraph.core.JanusGraphVertex; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mock; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; @@ -40,20 +45,11 @@ import org.openecomp.sdc.be.model.AdditionalInformationDefinition; import org.openecomp.sdc.be.model.ModelTestBase; import org.openecomp.sdc.be.model.operations.impl.util.OperationTestsUtil; import org.openecomp.sdc.be.resources.data.UserData; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -import java.util.Iterator; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration("classpath:application-context-test.xml") +@SpringJUnitConfig(locations = "classpath:application-context-test.xml") public class AdditionalInformationOperationTest extends ModelTestBase { + private static final JanusGraphGenericDao JANUS_GRAPH_GENERIC_DAO = mock(JanusGraphGenericDao.class); private static String USER_ID = "muUserId"; private static String CATEGORY_NAME = "category/mycategory"; @@ -66,20 +62,20 @@ public class AdditionalInformationOperationTest extends ModelTestBase { @javax.annotation.Resource(name = "additional-information-operation") private AdditionalInformationOperation additionalInformationOperation; - @Before - public void createUserAndCategory() { - deleteAndCreateCategory(CATEGORY_NAME); - deleteAndCreateUser(USER_ID, "first_" + USER_ID, "last_" + USER_ID); - - } - - @BeforeClass + @BeforeAll public static void setupBeforeClass() { ModelTestBase.init(); } + @BeforeEach + public void createUserAndCategory() { + deleteAndCreateCategory(CATEGORY_NAME); + deleteAndCreateUser(USER_ID, "first_" + USER_ID, "last_" + USER_ID); + + } + @Test public void testDummy() { @@ -88,24 +84,24 @@ public class AdditionalInformationOperationTest extends ModelTestBase { } @Test - public void testAddInfoParameter_InvalidId(){ + public void testAddInfoParameter_InvalidId() { Either result; String uid = "uid"; String componentId = "componentId"; - when(JANUS_GRAPH_GENERIC_DAO.getVertexByProperty(eq(uid),eq(componentId))).thenReturn(Either.left(janusGraphVertex)); + when(JANUS_GRAPH_GENERIC_DAO.getVertexByProperty(eq(uid), eq(componentId))).thenReturn(Either.left(janusGraphVertex)); result = additionalInformationOperation.addAdditionalInformationParameter - (NodeTypeEnum.Resource,componentId,"key","value"); + (NodeTypeEnum.Resource, componentId, "key", "value"); assertThat(result.isRight()); } @Test - public void testUpdateInfoParameter_InvalidId(){ + public void testUpdateInfoParameter_InvalidId() { Either result; String uid = "uid"; String componentId = "componentId"; - when(JANUS_GRAPH_GENERIC_DAO.getVertexByProperty(eq(uid),eq(componentId))).thenReturn(Either.left(janusGraphVertex)); + when(JANUS_GRAPH_GENERIC_DAO.getVertexByProperty(eq(uid), eq(componentId))).thenReturn(Either.left(janusGraphVertex)); result = additionalInformationOperation.updateAdditionalInformationParameter - (NodeTypeEnum.Resource,componentId,"id","key","value"); + (NodeTypeEnum.Resource, componentId, "id", "key", "value"); assertTrue(result.isRight()); } @@ -119,7 +115,7 @@ public class AdditionalInformationOperationTest extends ModelTestBase { v1.property("uid", componentId); v1.property(GraphPropertiesDictionary.LABEL.getProperty(), "resource"); JanusGraphVertex v2 = graph.addVertex(); - v2.property(id,id); + v2.property(id, id); JanusGraphEdge addEdge = v1.addEdge(GraphEdgeLabels.ADDITIONAL_INFORMATION.getProperty(), v2); addEdge.property("edgeProp", "resource"); diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/AnnotationTypeOperationsTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/AnnotationTypeOperationsTest.java index df164b9d31..8919f2c6ec 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/AnnotationTypeOperationsTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/AnnotationTypeOperationsTest.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,27 +20,24 @@ package org.openecomp.sdc.be.model.operations.impl; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import static java.util.Arrays.asList; +import static org.assertj.core.api.Assertions.assertThat; + +import javax.annotation.Resource; +import org.junit.jupiter.api.AfterEach; +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.dao.janusgraph.JanusGraphGenericDao; import org.openecomp.sdc.be.model.AnnotationTypeDefinition; import org.openecomp.sdc.be.model.ModelTestBase; import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.operations.StorageException; import org.openecomp.sdc.be.utils.TypeUtils; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -import javax.annotation.Resource; - -import static java.util.Arrays.asList; -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration("classpath:application-context-test.xml") +@SpringJUnitConfig(locations = "classpath:application-context-test.xml") public class AnnotationTypeOperationsTest extends ModelTestBase { static final String TYPE = "org.openecomp.annotations.source"; @@ -60,18 +57,18 @@ public class AnnotationTypeOperationsTest extends ModelTestBase { private PropertyDefinition prop1, prop2; private AnnotationTypeDefinition initialAnnotationDefinition; - @BeforeClass + @BeforeAll public static void setupBeforeClass() { ModelTestBase.init(); } - @Before + @BeforeEach public void initTestData() { removeGraphVertices(janusGraphGenericDao.getGraph()); prop1 = createSimpleProperty("val1", "prop1", "string"); } - @After + @AfterEach public void tearDown() { janusGraphGenericDao.rollback(); } @@ -83,14 +80,14 @@ public class AnnotationTypeOperationsTest extends ModelTestBase { AnnotationTypeDefinition result = annotationTypeOperations.addType(initialAnnotationDefinition); assertThat(result.getUniqueId()).isNotEmpty(); assertThat(result) - .isEqualToComparingOnlyGivenFields(initialAnnotationDefinition, "description", "type"); + .isEqualToComparingOnlyGivenFields(initialAnnotationDefinition, "description", "type"); assertThat(result.getProperties()) - .usingElementComparatorOnFields("defaultValue", "name", "type") - .containsExactlyInAnyOrder(prop1); + .usingElementComparatorOnFields("defaultValue", "name", "type") + .containsExactlyInAnyOrder(prop1); assertThat(result.isHighestVersion()).isTrue(); } - @Test + @Test public void testGetLatestType_TypeDoesntExist_shouldReturnNull() { AnnotationTypeDefinition latestType = annotationTypeOperations.getLatestType(TYPE); assertThat(latestType).isNull(); @@ -155,8 +152,8 @@ public class AnnotationTypeOperationsTest extends ModelTestBase { AnnotationTypeDefinition updatedType = annotationTypeOperations.updateType(initialAnnotationDefinition, advancedDefinition); assertThat(updatedType.getDescription()).isEqualTo(NEW_DESCRIPTION); assertThat(updatedType.getProperties()) - .usingElementComparatorOnFields("defaultValue", "name", "type") - .containsExactlyInAnyOrder(prop1, prop2); + .usingElementComparatorOnFields("defaultValue", "name", "type") + .containsExactlyInAnyOrder(prop1, prop2); } @Test @@ -166,8 +163,8 @@ public class AnnotationTypeOperationsTest extends ModelTestBase { AnnotationTypeDefinition advancedDefinition = buildAnnotationDefinition(DESCRIPTION, TYPE, prop2); AnnotationTypeDefinition updatedType = annotationTypeOperations.updateType(initialAnnotationDefinition, advancedDefinition); assertThat(updatedType.getProperties()) - .usingElementComparatorOnFields("defaultValue", "name", "type") - .containsExactlyInAnyOrder(prop2); + .usingElementComparatorOnFields("defaultValue", "name", "type") + .containsExactlyInAnyOrder(prop2); } @Test @@ -178,34 +175,38 @@ public class AnnotationTypeOperationsTest extends ModelTestBase { AnnotationTypeDefinition advancedDefinition = buildAnnotationDefinition(DESCRIPTION, TYPE, prop2); AnnotationTypeDefinition updatedType = annotationTypeOperations.updateType(initialAnnotationDefinition, advancedDefinition); assertThat(updatedType.getProperties()) - .usingElementComparatorOnFields("defaultValue", "name", "type", "description") - .containsExactlyInAnyOrder(prop2); + .usingElementComparatorOnFields("defaultValue", "name", "type", "description") + .containsExactlyInAnyOrder(prop2); } - @Test(expected = StorageException.class) + @Test public void testUpdateType_propertyTypeModification_shouldFail() { + Assertions.assertThrows(StorageException.class,()->{ addAnnotationType(); prop2 = createSimpleProperty("val1", "prop1", "int"); AnnotationTypeDefinition advancedDefinition = buildAnnotationDefinition(DESCRIPTION, TYPE, prop2); annotationTypeOperations.updateType(initialAnnotationDefinition, advancedDefinition); + }); } - @Test(expected = StorageException.class) + @Test public void testUpdateType_propertyRemoved_shouldFail() { - addAnnotationType(); - prop2 = createSimpleProperty("val1", "prop2", "int"); - AnnotationTypeDefinition advancedDefinition = buildAnnotationDefinition(DESCRIPTION, TYPE, prop2); - annotationTypeOperations.updateType(initialAnnotationDefinition, advancedDefinition); + Assertions.assertThrows(StorageException.class,()->{ + addAnnotationType(); + prop2 = createSimpleProperty("val1", "prop2", "int"); + AnnotationTypeDefinition advancedDefinition = buildAnnotationDefinition(DESCRIPTION, TYPE, prop2); + annotationTypeOperations.updateType(initialAnnotationDefinition, advancedDefinition); + }); } private void prepareInitialType() { initialAnnotationDefinition = buildAnnotationDefinition(DESCRIPTION, - TYPE, - prop1); + TYPE, + prop1); initialAnnotationDefinition.setVersion(TypeUtils.getFirstCertifiedVersionVersion()); } - private AnnotationTypeDefinition buildAnnotationDefinition(String description, String type, PropertyDefinition ... properties) { + private AnnotationTypeDefinition buildAnnotationDefinition(String description, String type, PropertyDefinition... properties) { AnnotationTypeDefinition annotationTypeDefinition = new AnnotationTypeDefinition(); annotationTypeDefinition.setDescription(description); annotationTypeDefinition.setType(type); diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ArtifactOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ArtifactOperationTest.java index d6414c5f25..25e1f28612 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ArtifactOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ArtifactOperationTest.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,55 +20,56 @@ package org.openecomp.sdc.be.model.operations.impl; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import fj.data.Either; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation; +import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels; import org.openecomp.sdc.be.dao.neo4j.GraphEdgePropertiesDictionary; -import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; -import org.openecomp.sdc.be.model.*; +import org.openecomp.sdc.be.model.ArtifactDefinition; +import org.openecomp.sdc.be.model.HeatParameterDefinition; +import org.openecomp.sdc.be.model.ModelTestBase; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.util.OperationTestsUtil; -import org.openecomp.sdc.be.resources.data.*; +import org.openecomp.sdc.be.resources.data.ArtifactData; +import org.openecomp.sdc.be.resources.data.HeatParameterData; +import org.openecomp.sdc.be.resources.data.ResourceMetadataData; +import org.openecomp.sdc.be.resources.data.UniqueIdData; +import org.openecomp.sdc.be.resources.data.UserData; import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -import static org.junit.Assert.*; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration("classpath:application-context-test.xml") +@SpringJUnitConfig(locations = "classpath:application-context-test.xml") public class ArtifactOperationTest extends ModelTestBase { private static final String ARTIFACT_NAME = "myHeatArtifact"; - + private static final String RESOURCE_ID = "resourceId"; + private static final String RESOURCE_ID_2 = "resourceId2"; + private static final String USER_ID = "muUserId"; @javax.annotation.Resource(name = "janusgraph-generic-dao") private JanusGraphGenericDao janusGraphDao; - @javax.annotation.Resource private ArtifactOperation artifactOperation; - private static final String RESOURCE_ID = "resourceId"; - private static final String RESOURCE_ID_2 = "resourceId2"; - - private static final String USER_ID = "muUserId"; - - @BeforeClass + @BeforeAll public static void setupBeforeClass() { ModelTestBase.init(); } - @Before + @BeforeEach public void createUserAndCategory() { String CATEGORY_NAME = "category/mycategory"; deleteAndCreateCategory(CATEGORY_NAME); @@ -84,17 +85,21 @@ public class ArtifactOperationTest extends ModelTestBase { assertEquals(1, heatParameters.size()); HeatParameterDefinition parameter = heatParameters.get(0); HeatParameterData parameterData = new HeatParameterData(parameter); - Either parameterNode = janusGraphDao.getNode(parameterData.getUniqueIdKey(), parameterData.getUniqueId(), HeatParameterData.class); + Either parameterNode = janusGraphDao.getNode(parameterData.getUniqueIdKey(), + parameterData.getUniqueId(), HeatParameterData.class); assertTrue(parameterNode.isLeft()); - Either removeArifact = artifactOperation.removeArifactFromResource(RESOURCE_ID, artifactWithHeat.getUniqueId(), NodeTypeEnum.Resource, true, false); + Either removeArifact = artifactOperation.removeArifactFromResource(RESOURCE_ID, + artifactWithHeat.getUniqueId(), NodeTypeEnum.Resource, true, false); assertTrue(removeArifact.isLeft()); ArtifactData artifactData = new ArtifactData(artifactWithHeat); - Either artifactAfterDelete = janusGraphDao.getNode(artifactData.getUniqueIdKey(), artifactData.getUniqueId(), ArtifactData.class); + Either artifactAfterDelete = janusGraphDao.getNode(artifactData.getUniqueIdKey(), + artifactData.getUniqueId(), ArtifactData.class); assertTrue(artifactAfterDelete.isRight()); - Either parameterNodeAfterDelete = janusGraphDao.getNode(parameterData.getUniqueIdKey(), parameterData.getUniqueId(), HeatParameterData.class); + Either parameterNodeAfterDelete = janusGraphDao.getNode(parameterData.getUniqueIdKey(), + parameterData.getUniqueId(), HeatParameterData.class); assertTrue(parameterNodeAfterDelete.isRight()); janusGraphDao.deleteNode(new UniqueIdData(NodeTypeEnum.Resource, RESOURCE_ID), ResourceMetadataData.class); @@ -109,7 +114,8 @@ public class ArtifactOperationTest extends ModelTestBase { assertEquals(1, heatParameters.size()); HeatParameterDefinition parameter = heatParameters.get(0); HeatParameterData parameterData = new HeatParameterData(parameter); - Either parameterNode = janusGraphDao.getNode(parameterData.getUniqueIdKey(), parameterData.getUniqueId(), HeatParameterData.class); + Either parameterNode = janusGraphDao.getNode(parameterData.getUniqueIdKey(), + parameterData.getUniqueId(), HeatParameterData.class); assertTrue(parameterNode.isLeft()); // update to artifact without params @@ -119,17 +125,20 @@ public class ArtifactOperationTest extends ModelTestBase { artifactNoParams.setArtifactVersion("2"); artifactNoParams.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT); - Either updateArifact = artifactOperation.updateArifactOnResource(artifactNoParams, RESOURCE_ID, artifactWithHeat.getUniqueId(), NodeTypeEnum.Resource, false); + Either updateArifact = artifactOperation.updateArifactOnResource(artifactNoParams, RESOURCE_ID, + artifactWithHeat.getUniqueId(), NodeTypeEnum.Resource, false); assertTrue(updateArifact.isLeft()); ArtifactData artifactData = new ArtifactData(artifactWithHeat); - Either artifactAfterUpdate = janusGraphDao.getNode(artifactData.getUniqueIdKey(), artifactData.getUniqueId(), ArtifactData.class); + Either artifactAfterUpdate = janusGraphDao.getNode(artifactData.getUniqueIdKey(), + artifactData.getUniqueId(), ArtifactData.class); assertTrue(artifactAfterUpdate.isLeft()); ArtifactData artifactAfterUpdateValue = artifactAfterUpdate.left().value(); assertEquals(artifactNoParams.getArtifactVersion(), artifactAfterUpdateValue.getArtifactDataDefinition() - .getArtifactVersion()); + .getArtifactVersion()); - Either parameterNodeAfterDelete = janusGraphDao.getNode(parameterData.getUniqueIdKey(), parameterData.getUniqueId(), HeatParameterData.class); + Either parameterNodeAfterDelete = janusGraphDao.getNode(parameterData.getUniqueIdKey(), + parameterData.getUniqueId(), HeatParameterData.class); assertTrue(parameterNodeAfterDelete.isRight()); artifactOperation.removeArifactFromResource(RESOURCE_ID, artifactWithHeat.getUniqueId(), NodeTypeEnum.Resource, true, false); @@ -147,7 +156,8 @@ public class ArtifactOperationTest extends ModelTestBase { assertEquals(1, heatParameters.size()); HeatParameterDefinition parameter = heatParameters.get(0); HeatParameterData parameterData = new HeatParameterData(parameter); - Either parameterNode = janusGraphDao.getNode(parameterData.getUniqueIdKey(), parameterData.getUniqueId(), HeatParameterData.class); + Either parameterNode = janusGraphDao.getNode(parameterData.getUniqueIdKey(), + parameterData.getUniqueId(), HeatParameterData.class); assertTrue(parameterNode.isLeft()); // update to artifact without params @@ -155,17 +165,20 @@ public class ArtifactOperationTest extends ModelTestBase { artifactWithHeat.setArtifactChecksum(null); artifactWithHeat.setPayloadData(null); - Either updateArifact = artifactOperation.updateArifactOnResource(artifactWithHeat, RESOURCE_ID, artifactWithHeat.getUniqueId(), NodeTypeEnum.Resource, false); + Either updateArifact = artifactOperation.updateArifactOnResource(artifactWithHeat, RESOURCE_ID, + artifactWithHeat.getUniqueId(), NodeTypeEnum.Resource, false); assertTrue(updateArifact.isLeft()); ArtifactData artifactData = new ArtifactData(artifactWithHeat); - Either artifactAfterUpdate = janusGraphDao.getNode(artifactData.getUniqueIdKey(), artifactData.getUniqueId(), ArtifactData.class); + Either artifactAfterUpdate = janusGraphDao.getNode(artifactData.getUniqueIdKey(), + artifactData.getUniqueId(), ArtifactData.class); assertTrue(artifactAfterUpdate.isLeft()); ArtifactData artifactAfterUpdateValue = artifactAfterUpdate.left().value(); assertEquals(artifactWithHeat.getArtifactVersion(), artifactAfterUpdateValue.getArtifactDataDefinition() - .getArtifactVersion()); + .getArtifactVersion()); - Either parameterNodeAfterDelete = janusGraphDao.getNode(parameterData.getUniqueIdKey(), parameterData.getUniqueId(), HeatParameterData.class); + Either parameterNodeAfterDelete = janusGraphDao.getNode(parameterData.getUniqueIdKey(), + parameterData.getUniqueId(), HeatParameterData.class); assertTrue(parameterNodeAfterDelete.isLeft()); artifactOperation.removeArifactFromResource(RESOURCE_ID_2, artifactAfterUpdateValue.getUniqueId(), NodeTypeEnum.Resource, true, false); @@ -181,7 +194,8 @@ public class ArtifactOperationTest extends ModelTestBase { ResourceMetadataData resource2 = createResource(RESOURCE_ID_2); Map props = new HashMap<>(); props.put(GraphEdgePropertiesDictionary.NAME.getProperty(), ArtifactGroupTypeEnum.DEPLOYMENT.name()); - Either createRelation = janusGraphDao.createRelation(resource2, new ArtifactData(artifactWithHeat), GraphEdgeLabels.ARTIFACT_REF, props); + Either createRelation = janusGraphDao.createRelation(resource2, new ArtifactData(artifactWithHeat), + GraphEdgeLabels.ARTIFACT_REF, props); assertTrue(createRelation.isLeft()); List heatParameters = artifactWithHeat.getListHeatParameters(); @@ -189,7 +203,8 @@ public class ArtifactOperationTest extends ModelTestBase { assertEquals(1, heatParameters.size()); HeatParameterDefinition parameter = heatParameters.get(0); HeatParameterData parameterData = new HeatParameterData(parameter); - Either parameterNode = janusGraphDao.getNode(parameterData.getUniqueIdKey(), parameterData.getUniqueId(), HeatParameterData.class); + Either parameterNode = janusGraphDao.getNode(parameterData.getUniqueIdKey(), + parameterData.getUniqueId(), HeatParameterData.class); assertTrue(parameterNode.isLeft()); ArtifactDefinition atifactToUpdate = new ArtifactDefinition(artifactWithHeat); @@ -205,28 +220,32 @@ public class ArtifactOperationTest extends ModelTestBase { heatParametersUpdated.add(heatParamUpdate); atifactToUpdate.setListHeatParameters(heatParametersUpdated); - Either updateArifact = artifactOperation.updateArifactOnResource(atifactToUpdate, RESOURCE_ID_2, atifactToUpdate.getUniqueId(), NodeTypeEnum.Resource, false); + Either updateArifact = artifactOperation.updateArifactOnResource(atifactToUpdate, RESOURCE_ID_2, + atifactToUpdate.getUniqueId(), NodeTypeEnum.Resource, false); assertTrue(updateArifact.isLeft()); // verify old artifact and parameter still exist ArtifactData artifactData = new ArtifactData(artifactWithHeat); - Either origArtifact = janusGraphDao.getNode(artifactData.getUniqueIdKey(), artifactData.getUniqueId(), ArtifactData.class); + Either origArtifact = janusGraphDao.getNode(artifactData.getUniqueIdKey(), + artifactData.getUniqueId(), ArtifactData.class); assertTrue(origArtifact.isLeft()); ArtifactData origArtifactData = origArtifact.left().value(); assertEquals(artifactWithHeat.getArtifactVersion(), origArtifactData.getArtifactDataDefinition() - .getArtifactVersion()); + .getArtifactVersion()); - Either parameterNodeAfterDelete = janusGraphDao.getNode(parameterData.getUniqueIdKey(), parameterData.getUniqueId(), HeatParameterData.class); + Either parameterNodeAfterDelete = janusGraphDao.getNode(parameterData.getUniqueIdKey(), + parameterData.getUniqueId(), HeatParameterData.class); assertTrue(parameterNodeAfterDelete.isLeft()); // verify new artifact and new parameter ArtifactDefinition artifactDefinitionUpdated = updateArifact.left().value(); ArtifactData artifactDataUpdated = new ArtifactData(artifactDefinitionUpdated); - Either updatedArtifact = janusGraphDao.getNode(artifactDataUpdated.getUniqueIdKey(), artifactDataUpdated.getUniqueId(), ArtifactData.class); + Either updatedArtifact = janusGraphDao.getNode(artifactDataUpdated.getUniqueIdKey(), + artifactDataUpdated.getUniqueId(), ArtifactData.class); assertTrue(updatedArtifact.isLeft()); ArtifactData updatedArtifactData = updatedArtifact.left().value(); assertEquals(atifactToUpdate.getArtifactVersion(), updatedArtifactData.getArtifactDataDefinition() - .getArtifactVersion()); + .getArtifactVersion()); assertFalse(updatedArtifactData.getUniqueId().equalsIgnoreCase(origArtifactData.getUniqueId())); List heatParametersAfterUpdate = artifactDefinitionUpdated.getListHeatParameters(); @@ -234,11 +253,13 @@ public class ArtifactOperationTest extends ModelTestBase { assertEquals(1, heatParametersAfterUpdate.size()); HeatParameterDefinition UpdatedHeatParameter = heatParametersAfterUpdate.get(0); assertFalse(UpdatedHeatParameter.getUniqueId().equalsIgnoreCase(parameterData.getUniqueId())); - Either parameterNodeAfterUpdate = janusGraphDao.getNode(new HeatParameterData(UpdatedHeatParameter).getUniqueIdKey(), UpdatedHeatParameter.getUniqueId(), HeatParameterData.class); + Either parameterNodeAfterUpdate = janusGraphDao.getNode( + new HeatParameterData(UpdatedHeatParameter).getUniqueIdKey(), UpdatedHeatParameter.getUniqueId(), HeatParameterData.class); assertTrue(parameterNodeAfterUpdate.isLeft()); // delete new artifact - Either removeArifact = artifactOperation.removeArifactFromResource(RESOURCE_ID_2, artifactDefinitionUpdated.getUniqueId(), NodeTypeEnum.Resource, true, false); + Either removeArifact = artifactOperation.removeArifactFromResource(RESOURCE_ID_2, + artifactDefinitionUpdated.getUniqueId(), NodeTypeEnum.Resource, true, false); assertTrue(removeArifact.isLeft()); // verify old artifact and parameter still exist @@ -246,16 +267,18 @@ public class ArtifactOperationTest extends ModelTestBase { assertTrue(origArtifact.isLeft()); origArtifactData = origArtifact.left().value(); assertEquals(artifactWithHeat.getArtifactVersion(), origArtifactData.getArtifactDataDefinition() - .getArtifactVersion()); + .getArtifactVersion()); parameterNodeAfterDelete = janusGraphDao.getNode(parameterData.getUniqueIdKey(), parameterData.getUniqueId(), HeatParameterData.class); assertTrue(parameterNodeAfterDelete.isLeft()); // verify new artifact is deleted - Either artifactAfterDelete = janusGraphDao.getNode(artifactDataUpdated.getUniqueIdKey(), artifactDataUpdated.getUniqueId(), ArtifactData.class); + Either artifactAfterDelete = janusGraphDao.getNode(artifactDataUpdated.getUniqueIdKey(), + artifactDataUpdated.getUniqueId(), ArtifactData.class); assertTrue(artifactAfterDelete.isRight()); - parameterNodeAfterDelete = janusGraphDao.getNode(new HeatParameterData(UpdatedHeatParameter).getUniqueIdKey(), new HeatParameterData(UpdatedHeatParameter).getUniqueId(), HeatParameterData.class); + parameterNodeAfterDelete = janusGraphDao.getNode(new HeatParameterData(UpdatedHeatParameter).getUniqueIdKey(), + new HeatParameterData(UpdatedHeatParameter).getUniqueId(), HeatParameterData.class); assertTrue(parameterNodeAfterDelete.isRight()); artifactOperation.removeArifactFromResource(RESOURCE_ID, artifactWithHeat.getUniqueId(), NodeTypeEnum.Resource, true, false); @@ -279,7 +302,8 @@ public class ArtifactOperationTest extends ModelTestBase { heatParams.add(heatParam); artifactDefinition.setListHeatParameters(heatParams); - Either artifact = artifactOperation.addArifactToComponent(artifactDefinition, RESOURCE_ID, NodeTypeEnum.Resource, true, false); + Either artifact = artifactOperation.addArifactToComponent(artifactDefinition, RESOURCE_ID, + NodeTypeEnum.Resource, true, false); assertTrue(artifact.isLeft()); return artifact.left().value(); } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java index 6ed482f948..8b8e813501 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.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. @@ -25,8 +25,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import org.janusgraph.core.JanusGraph; -import org.janusgraph.core.JanusGraphVertex; import fj.data.Either; import java.util.ArrayList; import java.util.HashMap; @@ -39,14 +37,15 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import javax.annotation.Resource; import org.apache.commons.lang3.tuple.ImmutablePair; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.janusgraph.core.JanusGraph; +import org.janusgraph.core.JanusGraphVertex; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge; import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphGenericDao; -import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; +import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels; import org.openecomp.sdc.be.datatypes.enums.ModelTypeEnum; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.model.CapabilityTypeDefinition; @@ -60,14 +59,9 @@ import org.openecomp.sdc.be.model.tosca.constraints.GreaterThanConstraint; import org.openecomp.sdc.be.model.tosca.constraints.InRangeConstraint; import org.openecomp.sdc.be.model.tosca.constraints.LessOrEqualConstraint; import org.openecomp.sdc.be.resources.data.CapabilityTypeData; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.*; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration("classpath:application-context-test.xml") +@SpringJUnitConfig(locations = "classpath:application-context-test.xml") public class CapabilityTypeOperationTest extends ModelTestBase { @Resource(name = "janusgraph-generic-dao") @@ -75,16 +69,20 @@ public class CapabilityTypeOperationTest extends ModelTestBase { @Resource(name = "capability-type-operation") private CapabilityTypeOperation capabilityTypeOperation; - + @Resource(name = "model-operation") private ModelOperation modelOperation; - @BeforeClass + @BeforeAll public static void setupBeforeClass() { ModelTestBase.init(); } - - @Before + + private static Map asMap(PropertyDefinition... props) { + return Stream.of(props).collect(Collectors.toMap(PropertyDefinition::getName, Function.identity())); + } + + @BeforeEach public void cleanUp() { HealingJanusGraphGenericDao janusGraphGenericDao = capabilityTypeOperation.janusGraphGenericDao; Either graphResult = janusGraphGenericDao.getGraph(); @@ -114,21 +112,24 @@ public class CapabilityTypeOperationTest extends ModelTestBase { capabilityTypeDefinition.setDescription("desc1"); capabilityTypeDefinition.setType("tosca.capabilities.Container1"); - Either addCapabilityType1 = capabilityTypeOperation.addCapabilityType(capabilityTypeDefinition, true); + Either addCapabilityType1 = capabilityTypeOperation.addCapabilityType( + capabilityTypeDefinition, true); assertTrue("check capability type added", addCapabilityType1.isLeft()); CapabilityTypeDefinition capabilityTypeAdded = addCapabilityType1.left().value(); compareBetweenCreatedToSent(capabilityTypeDefinition, capabilityTypeAdded); - Either capabilityTypeByUid = capabilityTypeOperation.getCapabilityTypeByUid(capabilityTypeAdded.getUniqueId()); + Either capabilityTypeByUid = capabilityTypeOperation.getCapabilityTypeByUid( + capabilityTypeAdded.getUniqueId()); compareBetweenCreatedToSent(capabilityTypeByUid.left().value(), capabilityTypeDefinition); - Either addCapabilityType2 = capabilityTypeOperation.addCapabilityType(capabilityTypeDefinition, true); + Either addCapabilityType2 = capabilityTypeOperation.addCapabilityType( + capabilityTypeDefinition, true); assertTrue("check capability type failed", addCapabilityType2.isRight()); assertEquals("check returned error", StorageOperationStatus.SCHEMA_VIOLATION, addCapabilityType2.right().value()); } - + @Test public void testAddCapabilityTypeWithModel() { @@ -136,28 +137,31 @@ public class CapabilityTypeOperationTest extends ModelTestBase { capabilityTypeDefinition.setDescription("desc1"); capabilityTypeDefinition.setType("tosca.capabilities.Container1"); capabilityTypeDefinition.setModel("testModel"); - + Model model = new Model("testModel", ModelTypeEnum.NORMATIVE); - modelOperation.createModel(model , true); + modelOperation.createModel(model, true); - Either addCapabilityType1 = capabilityTypeOperation.addCapabilityType(capabilityTypeDefinition, true); + Either addCapabilityType1 = capabilityTypeOperation.addCapabilityType( + capabilityTypeDefinition, true); assertTrue("check capability type added", addCapabilityType1.isLeft()); CapabilityTypeDefinition capabilityTypeAdded = addCapabilityType1.left().value(); compareBetweenCreatedToSent(capabilityTypeDefinition, capabilityTypeAdded); - Either capabilityTypeByUid = capabilityTypeOperation.getCapabilityTypeByUid(capabilityTypeAdded.getUniqueId()); + Either capabilityTypeByUid = capabilityTypeOperation.getCapabilityTypeByUid( + capabilityTypeAdded.getUniqueId()); compareBetweenCreatedToSent(capabilityTypeByUid.left().value(), capabilityTypeDefinition); - + CapabilityTypeDefinition capabilityTypeWithDerivedFrom = new CapabilityTypeDefinition(); capabilityTypeWithDerivedFrom.setDescription("desc2"); capabilityTypeWithDerivedFrom.setType("tosca.capabilities.Container2"); capabilityTypeWithDerivedFrom.setDerivedFrom("tosca.capabilities.Container1"); capabilityTypeWithDerivedFrom.setModel("testModel"); - Either addCapabilityType2 = capabilityTypeOperation.addCapabilityType(capabilityTypeWithDerivedFrom, true); + Either addCapabilityType2 = capabilityTypeOperation.addCapabilityType( + capabilityTypeWithDerivedFrom, true); assertTrue("check capability type added", addCapabilityType2.isLeft()); - + capabilityTypeAdded = addCapabilityType2.left().value(); compareBetweenCreatedToSent(capabilityTypeWithDerivedFrom, capabilityTypeAdded); @@ -168,7 +172,8 @@ public class CapabilityTypeOperationTest extends ModelTestBase { CapabilityTypeDefinition capabilityTypeDefinition = createCapabilityTypeDef("tosca.capabilities.Container2", "desc1", "derivedFrom"); - Either addCapabilityType1 = capabilityTypeOperation.addCapabilityType(capabilityTypeDefinition, true); + Either addCapabilityType1 = capabilityTypeOperation.addCapabilityType( + capabilityTypeDefinition, true); // assertEquals("check capability type parent not exist", // StorageOperationStatus.INVALID_ID, // addCapabilityType1.right().value()); @@ -197,10 +202,12 @@ public class CapabilityTypeOperationTest extends ModelTestBase { capabilityTypeDefinition.setProperties(properties); - Either addCapabilityType1 = capabilityTypeOperation.addCapabilityType(capabilityTypeDefinition, true); + Either addCapabilityType1 = capabilityTypeOperation.addCapabilityType( + capabilityTypeDefinition, true); CapabilityTypeDefinition capabilityTypeDefinitionCreated = addCapabilityType1.left().value(); - Either capabilityType = capabilityTypeOperation.getCapabilityType(capabilityTypeDefinitionCreated.getUniqueId(), true); + Either capabilityType = capabilityTypeOperation.getCapabilityType( + capabilityTypeDefinitionCreated.getUniqueId(), true); assertTrue("check capability type fetched", capabilityType.isLeft()); CapabilityTypeDefinition fetchedCTD = capabilityType.left().value(); @@ -234,10 +241,12 @@ public class CapabilityTypeOperationTest extends ModelTestBase { capabilityTypeDefinition.setProperties(properties); - Either addCapabilityType1 = capabilityTypeOperation.addCapabilityType(capabilityTypeDefinition, true); + Either addCapabilityType1 = capabilityTypeOperation.addCapabilityType( + capabilityTypeDefinition, true); CapabilityTypeDefinition capabilityTypeDefinitionCreated = addCapabilityType1.left().value(); - Either capabilityType = capabilityTypeOperation.getCapabilityType(capabilityTypeDefinitionCreated.getUniqueId()); + Either capabilityType = capabilityTypeOperation.getCapabilityType( + capabilityTypeDefinitionCreated.getUniqueId()); assertTrue("check capability type fetched", capabilityType.isLeft()); CapabilityTypeDefinition fetchedCTD = capabilityType.left().value(); @@ -274,14 +283,13 @@ public class CapabilityTypeOperationTest extends ModelTestBase { assertEquals("check not found is returned", StorageOperationStatus.NOT_FOUND, capabilityType.right().value()); } - - - + @Test public void updateCapabilityType_returnNotFoundErrorIfTryingToUpdateANonExistingType() { CapabilityTypeDefinition currType = createCapabilityTypeDef(); CapabilityTypeDefinition updatedType = createCapabilityTypeDef(); - Either updateCapabilityTypeRes = capabilityTypeOperation.updateCapabilityType(updatedType, currType); + Either updateCapabilityTypeRes = capabilityTypeOperation.updateCapabilityType(updatedType, + currType); assertThat(updateCapabilityTypeRes.right().value()).isEqualTo(StorageOperationStatus.NOT_FOUND); } @@ -293,7 +301,8 @@ public class CapabilityTypeOperationTest extends ModelTestBase { CapabilityTypeDefinition updatedType = createCapabilityTypeDef("type1", "description2"); capabilityTypeOperation.updateCapabilityType(updatedType, currCapabilityType.left().value()); - Either fetchedUpdatedType = capabilityTypeOperation.getCapabilityType(createdType.getType()); + Either fetchedUpdatedType = capabilityTypeOperation.getCapabilityType( + createdType.getType()); CapabilityTypeDefinition fetchedCapabilityType = fetchedUpdatedType.left().value(); assertThat(fetchedCapabilityType.getProperties()).isNullOrEmpty(); assertThat(fetchedCapabilityType.getDerivedFrom()).isNullOrEmpty(); @@ -314,17 +323,18 @@ public class CapabilityTypeOperationTest extends ModelTestBase { PropertyDefinition prop3 = createSimpleProperty("val3", "prop3", "string"); CapabilityTypeDefinition updatedCapabilityType = createCapabilityTypeDef(asMap(updatedProp1, prop3)); - Either updatedCapabilityTypeRes = - capabilityTypeOperation.updateCapabilityType(updatedCapabilityType, currCapabilityType.left().value()); - + Either updatedCapabilityTypeRes = + capabilityTypeOperation.updateCapabilityType(updatedCapabilityType, currCapabilityType.left().value()); + assertTrue(updatedCapabilityTypeRes.isRight()); assertEquals(StorageOperationStatus.MATCH_NOT_FOUND, updatedCapabilityTypeRes.right().value()); - Either fetchedUpdatedType = capabilityTypeOperation.getCapabilityType(capabilityType.getType()); + Either fetchedUpdatedType = capabilityTypeOperation.getCapabilityType( + capabilityType.getType()); assertEquals(fetchedUpdatedType.left().value().getProperties(), asMap(prop1)); } - + @Test public void updateCapabilityType_updatePropertiesFailedDueDeletedProp() { PropertyDefinition prop1 = createSimpleProperty("val1", "prop1", "string"); @@ -334,17 +344,18 @@ public class CapabilityTypeOperationTest extends ModelTestBase { PropertyDefinition prop3 = createSimpleProperty("val3", "prop3", "string"); CapabilityTypeDefinition updatedCapabilityType = createCapabilityTypeDef(asMap(prop3)); - Either updatedCapabilityTypeRes = - capabilityTypeOperation.updateCapabilityType(updatedCapabilityType, currCapabilityType.left().value()); - + Either updatedCapabilityTypeRes = + capabilityTypeOperation.updateCapabilityType(updatedCapabilityType, currCapabilityType.left().value()); + assertTrue(updatedCapabilityTypeRes.isRight()); assertEquals(StorageOperationStatus.MATCH_NOT_FOUND, updatedCapabilityTypeRes.right().value()); - Either fetchedUpdatedType = capabilityTypeOperation.getCapabilityType(capabilityType.getType()); + Either fetchedUpdatedType = capabilityTypeOperation.getCapabilityType( + capabilityType.getType()); assertEquals(fetchedUpdatedType.left().value().getProperties(), asMap(prop1)); } - + @Test public void updateCapabilityType_updateProperties() { PropertyDefinition prop1 = createSimpleProperty("val1", "prop1", "string"); @@ -355,11 +366,12 @@ public class CapabilityTypeOperationTest extends ModelTestBase { PropertyDefinition prop3 = createSimpleProperty("val3", "prop3", "string"); CapabilityTypeDefinition updatedCapabilityType = createCapabilityTypeDef(asMap(updatedProp1, prop3)); - Either updatedCapabilityTypeRes = - capabilityTypeOperation.updateCapabilityType(updatedCapabilityType, currCapabilityType.left().value()); + Either updatedCapabilityTypeRes = + capabilityTypeOperation.updateCapabilityType(updatedCapabilityType, currCapabilityType.left().value()); assertTrue(updatedCapabilityTypeRes.isLeft()); - - Either fetchedUpdatedType = capabilityTypeOperation.getCapabilityType(capabilityType.getType()); + + Either fetchedUpdatedType = capabilityTypeOperation.getCapabilityType( + capabilityType.getType()); assertEquals(fetchedUpdatedType.left().value().getProperties(), asMap(updatedProp1, prop3)); } @@ -373,7 +385,8 @@ public class CapabilityTypeOperationTest extends ModelTestBase { Either currCapabilityType = capabilityTypeOperation.addCapabilityType(capabilityType1); capabilityTypeOperation.updateCapabilityType(updatedCapabilityType, currCapabilityType.left().value()); - Either latestCapabilityType = capabilityTypeOperation.getCapabilityType(capabilityType1.getType()); + Either latestCapabilityType = capabilityTypeOperation.getCapabilityType( + capabilityType1.getType()); assertThat(latestCapabilityType.left().value().getDerivedFrom()).isEqualTo(rootCapabilityType.getType()); verifyDerivedFromNodeEqualsToRootCapabilityType(rootCapabilityType, latestCapabilityType.left().value().getUniqueId()); } @@ -386,12 +399,13 @@ public class CapabilityTypeOperationTest extends ModelTestBase { capabilityTypeOperation.addCapabilityType(rootCapabilityType); Either currCapabilityType = capabilityTypeOperation.addCapabilityType(capabilityType1); - Either updateRes = - capabilityTypeOperation.updateCapabilityType(updatedCapabilityType, currCapabilityType.left().value()); - + Either updateRes = + capabilityTypeOperation.updateCapabilityType(updatedCapabilityType, currCapabilityType.left().value()); + assertThat(updateRes.right().value()).isEqualTo(StorageOperationStatus.NOT_FOUND); - Either latestCapabilityType = capabilityTypeOperation.getCapabilityType(capabilityType1.getType()); + Either latestCapabilityType = capabilityTypeOperation.getCapabilityType( + capabilityType1.getType()); assertThat(latestCapabilityType.left().value().getDerivedFrom()).isEqualTo(rootCapabilityType.getType()); } @@ -408,11 +422,12 @@ public class CapabilityTypeOperationTest extends ModelTestBase { capabilityTypeOperation.updateCapabilityType(updatedCapabilityType, currCapabilityType.left().value()); - Either latestCapabilityType = capabilityTypeOperation.getCapabilityType(capabilityType1.getType()); + Either latestCapabilityType = capabilityTypeOperation.getCapabilityType( + capabilityType1.getType()); assertThat(latestCapabilityType.left().value().getDerivedFrom()).isEqualTo(derivedType1.getType()); verifyDerivedFromNodeEqualsToRootCapabilityType(derivedType1, latestCapabilityType.left().value().getUniqueId()); } - + @Test public void updateCapabilityType_updateDerivedFrom_Failed_NewParentIsNotChildOfOldOne() { CapabilityTypeDefinition rootCapabilityType = createCapabilityTypeDef(); @@ -424,23 +439,26 @@ public class CapabilityTypeOperationTest extends ModelTestBase { capabilityTypeOperation.addCapabilityType(notDerivedType); Either currCapabilityType = capabilityTypeOperation.addCapabilityType(capabilityType1); - Either result = capabilityTypeOperation.updateCapabilityType(updatedCapabilityType, currCapabilityType.left().value()); + Either result = capabilityTypeOperation.updateCapabilityType(updatedCapabilityType, + currCapabilityType.left().value()); assertThat(result.right().value()).isEqualTo(StorageOperationStatus.CANNOT_UPDATE_EXISTING_ENTITY); - Either latestCapabilityType = capabilityTypeOperation.getCapabilityType(capabilityType1.getType()); + Either latestCapabilityType = capabilityTypeOperation.getCapabilityType( + capabilityType1.getType()); assertThat(latestCapabilityType.left().value().getDerivedFrom()).isEqualTo(rootCapabilityType.getType()); verifyDerivedFromNodeEqualsToRootCapabilityType(rootCapabilityType, latestCapabilityType.left().value().getUniqueId()); } - + private CapabilityTypeDefinition createCapabilityTypeDef() { - return createCapabilityTypeDef("tosca.capabilities.Root", "The TOSCA root Capability Type all other TOSCA base Capability Types derived from", null, new HashMap<>()); + return createCapabilityTypeDef("tosca.capabilities.Root", "The TOSCA root Capability Type all other TOSCA base Capability Types derived from", + null, new HashMap<>()); } private CapabilityTypeDefinition createCapabilityTypeDef(Map properties) { return createCapabilityTypeDef("tosca.capabilities.Root", - "The TOSCA root Capability Type all other TOSCA base Capability Types derived from", null, properties); + "The TOSCA root Capability Type all other TOSCA base Capability Types derived from", null, properties); } - + private CapabilityTypeDefinition createCapabilityTypeDef(String type, String description) { return createCapabilityTypeDef(type, description, null, null); } @@ -449,8 +467,8 @@ public class CapabilityTypeOperationTest extends ModelTestBase { return createCapabilityTypeDef(type, description, derivedFrom, null); } - - private CapabilityTypeDefinition createCapabilityTypeDef(String type, String description, String derivedFrom, Map properties) { + private CapabilityTypeDefinition createCapabilityTypeDef(String type, String description, String derivedFrom, + Map properties) { CapabilityTypeDefinition capabilityTypeDefinition = new CapabilityTypeDefinition(); capabilityTypeDefinition.setDescription(description); capabilityTypeDefinition.setType(type); @@ -470,15 +488,12 @@ public class CapabilityTypeOperationTest extends ModelTestBase { return updatedProp1; } - private static Map asMap(PropertyDefinition ... props) { - return Stream.of(props).collect(Collectors.toMap(PropertyDefinition::getName, Function.identity())); - } - private void verifyDerivedFromNodeEqualsToRootCapabilityType(CapabilityTypeDefinition rootCapabilityType, String parentCapabilityId) { - Either, JanusGraphOperationStatus> derivedFromRelation = janusGraphDao.getChild(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.CapabilityType), parentCapabilityId, GraphEdgeLabels.DERIVED_FROM, - NodeTypeEnum.CapabilityType, CapabilityTypeData.class); + Either, JanusGraphOperationStatus> derivedFromRelation = janusGraphDao.getChild( + UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.CapabilityType), parentCapabilityId, GraphEdgeLabels.DERIVED_FROM, + NodeTypeEnum.CapabilityType, CapabilityTypeData.class); assertThat(derivedFromRelation.left().value().getLeft().getCapabilityTypeDataDefinition()) - .isEqualToComparingFieldByField(rootCapabilityType); + .isEqualToComparingFieldByField(rootCapabilityType); } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperationTest.java index 19812e6d61..546506aa92 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperationTest.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. @@ -38,10 +38,9 @@ import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.tinkerpop.gremlin.structure.Edge; import org.janusgraph.core.JanusGraph; import org.janusgraph.core.JanusGraphVertex; -import org.junit.After; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge; import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphGenericDao; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; @@ -61,11 +60,9 @@ import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.tosca.ToscaType; import org.openecomp.sdc.be.resources.data.CapabilityTypeData; import org.openecomp.sdc.be.resources.data.GroupTypeData; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration("classpath:application-context-test.xml") +@SpringJUnitConfig(locations = "classpath:application-context-test.xml") public class GroupTypeOperationTest extends ModelTestBase { private static final String TOSCA_GROUPS_ROOT = "tosca.groups.Root"; @@ -73,22 +70,22 @@ public class GroupTypeOperationTest extends ModelTestBase { @Resource(name = "janusgraph-generic-dao") private HealingJanusGraphGenericDao janusGraphDao; - + @Resource(name = "capability-type-operation") private CapabilityTypeOperation capabilityTypeOperation; - + @Resource(name = "group-type-operation") private GroupTypeOperation groupTypeOperation; @Resource(name = "model-operation") private ModelOperation modelOperation; - @BeforeClass + @BeforeAll public static void setupBeforeClass() { ModelTestBase.init(); } - @After + @AfterEach public void tearDown() { janusGraphDao.rollback(); cleanUp(); @@ -105,8 +102,8 @@ public class GroupTypeOperationTest extends ModelTestBase { List allGroupTypesNoExclusion = groupTypeOperation.getAllGroupTypes(null, null); assertThat(allGroupTypesNoExclusion) - .usingElementComparatorOnFields("type", "icon", "name") - .containsExactlyInAnyOrder(rootGroupDefinition, type1, type2); + .usingElementComparatorOnFields("type", "icon", "name") + .containsExactlyInAnyOrder(rootGroupDefinition, type1, type2); } @Test @@ -120,45 +117,45 @@ public class GroupTypeOperationTest extends ModelTestBase { List allGroupTypes = groupTypeOperation.getAllGroupTypes(newHashSet("type1", "type2"), null); assertThat(allGroupTypes) - .usingElementComparatorOnFields("type") - .containsExactly(rootGroupDefinition); + .usingElementComparatorOnFields("type") + .containsExactly(rootGroupDefinition); } @Test public void groupTypeWithoutCapabilityCreated() { GroupTypeData rootNode = getOrCreateRootGroupTypeNode(); - + GroupTypeDefinition groupTypeDefinition = new GroupTypeDefinition(); groupTypeDefinition.setDerivedFrom(TOSCA_GROUPS_ROOT); groupTypeDefinition.setDescription("groups l3-networks in network collection"); groupTypeDefinition.setType("org.openecomp.groups.NetworkCollection"); groupTypeDefinition.setVersion("1.0"); - + List properties = asList( - buildProperty("network_collection_type", "l3-network", "network collection type, defined with default value"), - buildProperty("network_collection_subtype", "sub-interface", "network collection subtype, defined with default value"), - buildProperty("network_collection_role", null, "network collection role"), - buildProperty("network_collection_description", null, "network collection description, free format text")); - - groupTypeDefinition.setProperties(properties ); - - Either addGroupTypeResult = groupTypeOperation.addGroupType(groupTypeDefinition, true); + buildProperty("network_collection_type", "l3-network", "network collection type, defined with default value"), + buildProperty("network_collection_subtype", "sub-interface", "network collection subtype, defined with default value"), + buildProperty("network_collection_role", null, "network collection role"), + buildProperty("network_collection_description", null, "network collection description, free format text")); + + groupTypeDefinition.setProperties(properties); + + Either addGroupTypeResult = groupTypeOperation.addGroupType(groupTypeDefinition, true); assertTrue("check group type added", addGroupTypeResult.isLeft()); compareBetweenCreatedToSent(groupTypeDefinition, addGroupTypeResult.left().value()); - + addGroupTypeResult = groupTypeOperation.getGroupTypeByTypeAndVersion("org.openecomp.groups.NetworkCollection", "1.0", null); assertTrue("check group type added", addGroupTypeResult.isLeft()); compareBetweenCreatedToSent(groupTypeDefinition, addGroupTypeResult.left().value()); - + Either groupTypeResult = janusGraphDao .getNode(GraphPropertiesDictionary.TYPE.getProperty(), groupTypeDefinition.getType(), GroupTypeData.class); GroupTypeData groupTypeNode = extractVal(groupTypeResult); - + Either edgeResult = janusGraphDao .getEdgeByNodes(groupTypeNode, rootNode, GraphEdgeLabels.DERIVED_FROM); validate(edgeResult); } - + @Test public void groupTypeWithCapabilityAndPropsButCapTypeWithoutProps() { getOrCreateRootGroupTypeNode(); @@ -176,21 +173,20 @@ public class GroupTypeOperationTest extends ModelTestBase { Map mapCapabilities = new HashMap<>(); ComponentInstanceProperty property = new ComponentInstanceProperty( - buildProperty("vfc_instance_group_reference", null, "Ability to recognize capability per vfc instance group on vnf instance")); + buildProperty("vfc_instance_group_reference", null, "Ability to recognize capability per vfc instance group on vnf instance")); CapabilityDefinition capabilityDef = buildCapabilityDefintion(asList(property)); mapCapabilities.put("vlan_assignment", capabilityDef); groupTypeDefinition.setCapabilities(mapCapabilities); - List properties = asList( - buildProperty("vfc_instance_group_role", null, "role of this VFC group"), - buildProperty("vfc_parent_port_role", null, "common role of parent ports of VFCs in this group"), - buildProperty("network_collection_role", null, "network collection role assigned to this group"), - buildProperty("subinterface_role", null, "common role of subinterfaces of VFCs in this group, criteria the group is created")); + buildProperty("vfc_instance_group_role", null, "role of this VFC group"), + buildProperty("vfc_parent_port_role", null, "common role of parent ports of VFCs in this group"), + buildProperty("network_collection_role", null, "network collection role assigned to this group"), + buildProperty("subinterface_role", null, "common role of subinterfaces of VFCs in this group, criteria the group is created")); - groupTypeDefinition.setProperties(properties ); + groupTypeDefinition.setProperties(properties); - Either addGroupTypeResult = groupTypeOperation.addGroupType(groupTypeDefinition, true); + Either addGroupTypeResult = groupTypeOperation.addGroupType(groupTypeDefinition, true); assertTrue(addGroupTypeResult.isRight()); assertEquals(StorageOperationStatus.MATCH_NOT_FOUND, addGroupTypeResult.right().value()); } @@ -198,16 +194,16 @@ public class GroupTypeOperationTest extends ModelTestBase { @Test public void groupTypeWithCapabilityTypeAndEdgeCreated() { GroupTypeData rootNode = getOrCreateRootGroupTypeNode(); - + Map capTypeProperties = new HashMap<>(); capTypeProperties.put("vfc_instance_group_reference", - buildProperty("vfc_instance_group_reference", null, "Ability to recognize capability per vfc instance group on vnf instance")); + buildProperty("vfc_instance_group_reference", null, "Ability to recognize capability per vfc instance group on vnf instance")); CapabilityTypeDefinition capabilityTypeDef = createCapabilityType(capTypeProperties); Either capabilityTypeResult = janusGraphDao .getNode(GraphPropertiesDictionary.TYPE.getProperty(), capabilityTypeDef.getType(), CapabilityTypeData.class); extractVal(capabilityTypeResult); - + GroupTypeDefinition groupTypeDefinition = new GroupTypeDefinition(); groupTypeDefinition.setDerivedFrom(TOSCA_GROUPS_ROOT); groupTypeDefinition.setDescription("groups l3-networks in network collection"); @@ -215,28 +211,27 @@ public class GroupTypeOperationTest extends ModelTestBase { Map mapCapabilities = new HashMap<>(); ComponentInstanceProperty property = new ComponentInstanceProperty( - buildProperty("vfc_instance_group_reference", null, "Ability to recognize capability per vfc instance group on vnf instance")); + buildProperty("vfc_instance_group_reference", null, "Ability to recognize capability per vfc instance group on vnf instance")); CapabilityDefinition capabilityDef = buildCapabilityDefintion(asList(property)); mapCapabilities.put("vlan_assignment", capabilityDef); groupTypeDefinition.setCapabilities(mapCapabilities); - - + List properties = asList( - buildProperty("vfc_instance_group_role", null, "role of this VFC group"), - buildProperty("vfc_parent_port_role", null, "common role of parent ports of VFCs in this group"), - buildProperty("network_collection_role", null, "network collection role assigned to this group"), - buildProperty("subinterface_role", null, "common role of subinterfaces of VFCs in this group, criteria the group is created")); - - groupTypeDefinition.setProperties(properties ); - - Either addGroupTypeResult = groupTypeOperation.addGroupType(groupTypeDefinition, true); + buildProperty("vfc_instance_group_role", null, "role of this VFC group"), + buildProperty("vfc_parent_port_role", null, "common role of parent ports of VFCs in this group"), + buildProperty("network_collection_role", null, "network collection role assigned to this group"), + buildProperty("subinterface_role", null, "common role of subinterfaces of VFCs in this group, criteria the group is created")); + + groupTypeDefinition.setProperties(properties); + + Either addGroupTypeResult = groupTypeOperation.addGroupType(groupTypeDefinition, true); assertTrue("check group type added", addGroupTypeResult.isLeft()); compareBetweenCreatedToSent(groupTypeDefinition, addGroupTypeResult.left().value()); - + Either groupTypeResult = janusGraphDao .getNode(GraphPropertiesDictionary.TYPE.getProperty(), groupTypeDefinition.getType(), GroupTypeData.class); GroupTypeData groupTypeNode = extractVal(groupTypeResult); - + Either groupTypeDefResult = groupTypeOperation.getGroupTypeByUid(groupTypeNode.getUniqueId()); assertTrue(groupTypeDefResult.isLeft()); GroupTypeDefinition groupTypeDefinitionRetrieved = groupTypeDefResult.left().value(); @@ -247,17 +242,18 @@ public class GroupTypeOperationTest extends ModelTestBase { assertTrue(capabilityDefs.containsKey("vlan_assignment")); CapabilityDefinition updatedCapabilityDef = capabilityDefs.get("vlan_assignment"); assertEquals(2, updatedCapabilityDef.getProperties().size()); - + Either edgeDerivedFromResult = janusGraphDao .getEdgeByNodes(groupTypeNode, rootNode, GraphEdgeLabels.DERIVED_FROM); validate(edgeDerivedFromResult); } - + @Test public void groupTypeWithCapabilityTypeAndEdgeCreated_OverrideDefaultCapabilityTypeValue() { getOrCreateRootGroupTypeNode(); - PropertyDefinition property = buildProperty("vfc_instance_group_reference", null, "Ability to recognize capability per vfc instance group on vnf instance"); + PropertyDefinition property = buildProperty("vfc_instance_group_reference", null, + "Ability to recognize capability per vfc instance group on vnf instance"); Map capTypeProperties = new HashMap<>(); capTypeProperties.put("vfc_instance_group_reference", property); @@ -278,16 +274,15 @@ public class GroupTypeOperationTest extends ModelTestBase { mapCapabilities.put("vlan_assignment", capabilityDef); groupTypeDefinition.setCapabilities(mapCapabilities); - List properties = asList( - buildProperty("vfc_instance_group_role", null, "role of this VFC group"), - buildProperty("vfc_parent_port_role", null, "common role of parent ports of VFCs in this group"), - buildProperty("network_collection_role", null, "network collection role assigned to this group"), - buildProperty("subinterface_role", null, "common role of subinterfaces of VFCs in this group, criteria the group is created")); + buildProperty("vfc_instance_group_role", null, "role of this VFC group"), + buildProperty("vfc_parent_port_role", null, "common role of parent ports of VFCs in this group"), + buildProperty("network_collection_role", null, "network collection role assigned to this group"), + buildProperty("subinterface_role", null, "common role of subinterfaces of VFCs in this group, criteria the group is created")); - groupTypeDefinition.setProperties(properties ); + groupTypeDefinition.setProperties(properties); - Either addGroupTypeResult = groupTypeOperation.addGroupType(groupTypeDefinition, true); + Either addGroupTypeResult = groupTypeOperation.addGroupType(groupTypeDefinition, true); assertTrue("check group type added", addGroupTypeResult.isLeft()); compareBetweenCreatedToSent(groupTypeDefinition, addGroupTypeResult.left().value()); @@ -308,13 +303,14 @@ public class GroupTypeOperationTest extends ModelTestBase { assertEquals("new_value", capDefinition.getProperties().get(0).getValue()); assertEquals(2, capDefinition.getProperties().size()); } - - + + @Test public void updateGroupTypeWithCapability_FailedDueToCapabilityDeleteAttempt() { createRootGroupTypeNode(); - PropertyDefinition property = buildProperty("vfc_instance_group_reference", null, "Ability to recognize capability per vfc instance group on vnf instance"); + PropertyDefinition property = buildProperty("vfc_instance_group_reference", null, + "Ability to recognize capability per vfc instance group on vnf instance"); Map capTypeProperties = new HashMap<>(); capTypeProperties.put("vfc_instance_group_reference", property); @@ -335,24 +331,26 @@ public class GroupTypeOperationTest extends ModelTestBase { mapCapabilities.put("vlan_assignment", capabilityDef); groupTypeDefinition.setCapabilities(mapCapabilities); - Either addGroupTypeResult = groupTypeOperation.addGroupType(groupTypeDefinition); + Either addGroupTypeResult = groupTypeOperation.addGroupType(groupTypeDefinition); assertTrue(addGroupTypeResult.isLeft()); - + GroupTypeDefinition newGroupTypeDefinition = new GroupTypeDefinition(); newGroupTypeDefinition.setDerivedFrom(TOSCA_GROUPS_ROOT); newGroupTypeDefinition.setDescription("groups l3-networks in network collection"); newGroupTypeDefinition.setType("org.openecomp.groups.NetworkCollection"); - Either updateGroupTypeResult = groupTypeOperation.updateGroupType(newGroupTypeDefinition, addGroupTypeResult.left().value()); + Either updateGroupTypeResult = groupTypeOperation.updateGroupType(newGroupTypeDefinition, + addGroupTypeResult.left().value()); assertTrue(updateGroupTypeResult.isRight()); assertEquals(StorageOperationStatus.MATCH_NOT_FOUND, updateGroupTypeResult.right().value()); } - + @Test public void updateGroupTypeWithCapability_FailedDueToCapabilityChangeTypeAttempt() { createRootGroupTypeNode(); - PropertyDefinition property = buildProperty("vfc_instance_group_reference", null, "Ability to recognize capability per vfc instance group on vnf instance"); + PropertyDefinition property = buildProperty("vfc_instance_group_reference", null, + "Ability to recognize capability per vfc instance group on vnf instance"); Map capTypeProperties = new HashMap<>(); capTypeProperties.put("vfc_instance_group_reference", property); @@ -373,14 +371,14 @@ public class GroupTypeOperationTest extends ModelTestBase { mapCapabilities.put("vlan_assignment", capabilityDef); groupTypeDefinition.setCapabilities(mapCapabilities); - Either addGroupTypeResult = groupTypeOperation.addGroupType(groupTypeDefinition); + Either addGroupTypeResult = groupTypeOperation.addGroupType(groupTypeDefinition); assertTrue(addGroupTypeResult.isLeft()); - + GroupTypeDefinition newGroupTypeDefinition = new GroupTypeDefinition(); newGroupTypeDefinition.setDerivedFrom(TOSCA_GROUPS_ROOT); newGroupTypeDefinition.setDescription("groups l3-networks in network collection"); newGroupTypeDefinition.setType("org.openecomp.groups.NetworkCollection"); - + Map updatedMapCapabilities = new HashMap<>(); property.setValue("new_value"); ComponentInstanceProperty newCapDefProperty = new ComponentInstanceProperty(property); @@ -388,17 +386,19 @@ public class GroupTypeOperationTest extends ModelTestBase { updatedCapabilityDef.setType("Another type"); updatedMapCapabilities.put("vlan_assignment", updatedCapabilityDef); newGroupTypeDefinition.setCapabilities(updatedMapCapabilities); - - Either updateGroupTypeResult = groupTypeOperation.updateGroupType(newGroupTypeDefinition, addGroupTypeResult.left().value()); + + Either updateGroupTypeResult = groupTypeOperation.updateGroupType(newGroupTypeDefinition, + addGroupTypeResult.left().value()); assertTrue(updateGroupTypeResult.isRight()); assertEquals(StorageOperationStatus.MATCH_NOT_FOUND, updateGroupTypeResult.right().value()); } - + @Test public void updateGroupTypeWithCapability_Success() { createRootGroupTypeNode(); - PropertyDefinition property = buildProperty("vfc_instance_group_reference", null, "Ability to recognize capability per vfc instance group on vnf instance"); + PropertyDefinition property = buildProperty("vfc_instance_group_reference", null, + "Ability to recognize capability per vfc instance group on vnf instance"); Map capTypeProperties = new HashMap<>(); capTypeProperties.put("vfc_instance_group_reference", property); @@ -419,22 +419,23 @@ public class GroupTypeOperationTest extends ModelTestBase { mapCapabilities.put("vlan_assignment", capabilityDef); groupTypeDefinition.setCapabilities(mapCapabilities); - Either addGroupTypeResult = groupTypeOperation.addGroupType(groupTypeDefinition); + Either addGroupTypeResult = groupTypeOperation.addGroupType(groupTypeDefinition); assertTrue(addGroupTypeResult.isLeft()); - + GroupTypeDefinition newGroupTypeDefinition = new GroupTypeDefinition(); newGroupTypeDefinition.setDerivedFrom(TOSCA_GROUPS_ROOT); newGroupTypeDefinition.setDescription("groups l3-networks in network collection"); newGroupTypeDefinition.setType("org.openecomp.groups.NetworkCollection"); - + Map updatedMapCapabilities = new HashMap<>(); property.setValue("another_value"); ComponentInstanceProperty newCapDefProperty = new ComponentInstanceProperty(property); CapabilityDefinition updatedCapabilityDef = buildCapabilityDefintion(asList(newCapDefProperty)); updatedMapCapabilities.put("vlan_assignment", updatedCapabilityDef); newGroupTypeDefinition.setCapabilities(updatedMapCapabilities); - - Either updateGroupTypeResult = groupTypeOperation.updateGroupType(newGroupTypeDefinition, addGroupTypeResult.left().value()); + + Either updateGroupTypeResult = groupTypeOperation.updateGroupType(newGroupTypeDefinition, + addGroupTypeResult.left().value()); assertTrue(updateGroupTypeResult.isLeft()); } @@ -448,23 +449,24 @@ public class GroupTypeOperationTest extends ModelTestBase { groupTypeDefinition.setVersion("1.0"); List properties = singletonList( - buildProperty("network_collection_type", "l2-network", "network collection type, defined with default value")); - - groupTypeDefinition.setProperties(properties ); - - Either addGroupTypeResult = groupTypeOperation.addGroupType(groupTypeDefinition, true); + buildProperty("network_collection_type", "l2-network", "network collection type, defined with default value")); + + groupTypeDefinition.setProperties(properties); + + Either addGroupTypeResult = groupTypeOperation.addGroupType(groupTypeDefinition, true); assertTrue("check group type added", addGroupTypeResult.isLeft()); compareBetweenCreatedToSent(groupTypeDefinition, addGroupTypeResult.left().value()); - + addGroupTypeResult = groupTypeOperation.getGroupTypeByTypeAndVersion("org.openecomp.groups.PrivateCollection", "1.0", null); assertTrue("check group type added", addGroupTypeResult.isLeft()); compareBetweenCreatedToSent(groupTypeDefinition, addGroupTypeResult.left().value()); - - Either upgradeResult = groupTypeOperation.updateGroupType(groupTypeDefinition, groupTypeDefinition); + + Either upgradeResult = groupTypeOperation.updateGroupType(groupTypeDefinition, + groupTypeDefinition); assertNotNull(upgradeResult); assertTrue(upgradeResult.isLeft()); } - + @Test public void testUpdateNonExistingGroupType() { GroupTypeDefinition groupTypeDefinition = new GroupTypeDefinition(); @@ -472,70 +474,74 @@ public class GroupTypeOperationTest extends ModelTestBase { groupTypeDefinition.setDescription("groups l2-networks in network collection"); groupTypeDefinition.setType("org.openecomp.groups.MyCollection"); groupTypeDefinition.setVersion("1.0"); - - Either upgradeResult = groupTypeOperation.updateGroupType(groupTypeDefinition, groupTypeDefinition); + + Either upgradeResult = groupTypeOperation.updateGroupType(groupTypeDefinition, + groupTypeDefinition); assertNotNull(upgradeResult); assertTrue(upgradeResult.isRight()); } - + @Test public void testUpdateNotDerivedGroupType() { GroupTypeDefinition groupTypeDefinition = new GroupTypeDefinition(); groupTypeDefinition.setDescription("groups social-networks in school"); groupTypeDefinition.setType("org.openecomp.groups.Teachers"); groupTypeDefinition.setVersion("1.0"); - - Either addGroupTypeResult = groupTypeOperation.addGroupType(groupTypeDefinition, true); + + Either addGroupTypeResult = groupTypeOperation.addGroupType(groupTypeDefinition, true); assertTrue("check group type added", addGroupTypeResult.isLeft()); compareBetweenCreatedToSent(groupTypeDefinition, addGroupTypeResult.left().value()); - - Either upgradeResult = groupTypeOperation.updateGroupType(groupTypeDefinition, groupTypeDefinition); + + Either upgradeResult = groupTypeOperation.updateGroupType(groupTypeDefinition, + groupTypeDefinition); assertNotNull(upgradeResult); assertTrue(upgradeResult.isLeft()); assertThat(groupTypeDefinition).isEqualToIgnoringGivenFields(upgradeResult.left().value(), "properties", "capabilities"); } - + @Test public void testUpdateGroupTypeWithNonExistingParent() { GroupTypeDefinition groupTypeDefinition = new GroupTypeDefinition(); groupTypeDefinition.setDescription("groups social-networks in work"); groupTypeDefinition.setType("org.openecomp.groups.Cowokers"); groupTypeDefinition.setVersion("1.0"); - - Either addGroupTypeResult = groupTypeOperation.addGroupType(groupTypeDefinition, true); + + Either addGroupTypeResult = groupTypeOperation.addGroupType(groupTypeDefinition, true); assertTrue("check group type added", addGroupTypeResult.isLeft()); compareBetweenCreatedToSent(groupTypeDefinition, addGroupTypeResult.left().value()); - + groupTypeDefinition.setDerivedFrom("Non.existing.parent"); - Either upgradeResult = groupTypeOperation.updateGroupType(groupTypeDefinition, groupTypeDefinition); + Either upgradeResult = groupTypeOperation.updateGroupType(groupTypeDefinition, + groupTypeDefinition); assertNotNull(upgradeResult); assertTrue(upgradeResult.isRight()); } - + @Test public void testUpgradeGroupType() { GroupTypeDefinition groupTypeDefinition = new GroupTypeDefinition(); groupTypeDefinition.setDescription("groups social-networks in university"); groupTypeDefinition.setType("org.openecomp.groups.Students"); groupTypeDefinition.setVersion("1.0"); - - Either addGroupTypeResult = groupTypeOperation.addGroupType(groupTypeDefinition, true); + + Either addGroupTypeResult = groupTypeOperation.addGroupType(groupTypeDefinition, true); assertTrue("check group type added", addGroupTypeResult.isLeft()); compareBetweenCreatedToSent(groupTypeDefinition, addGroupTypeResult.left().value()); - + GroupTypeDefinition parentGroupTypeDefinition = new GroupTypeDefinition(); parentGroupTypeDefinition.setDescription("groups social-networks in university"); parentGroupTypeDefinition.setType("org.openecomp.groups.Parents"); parentGroupTypeDefinition.setVersion("1.0"); parentGroupTypeDefinition.setHighestVersion(true); - - Either addParentGroupTypeResult = groupTypeOperation.addGroupType(parentGroupTypeDefinition, true); + Either addParentGroupTypeResult = groupTypeOperation.addGroupType(parentGroupTypeDefinition, + true); assertTrue("check group type added", addParentGroupTypeResult.isLeft()); compareBetweenCreatedToSent(parentGroupTypeDefinition, addParentGroupTypeResult.left().value()); - + groupTypeDefinition.setDerivedFrom("org.openecomp.groups.Parents"); - Either upgradeResult = groupTypeOperation.updateGroupType(groupTypeDefinition, addGroupTypeResult.left().value()); + Either upgradeResult = groupTypeOperation.updateGroupType(groupTypeDefinition, + addGroupTypeResult.left().value()); assertNotNull(upgradeResult); assertTrue(upgradeResult.isLeft()); assertThat(groupTypeDefinition).isEqualToIgnoringGivenFields(upgradeResult.left().value(), "properties", "capabilities"); @@ -546,37 +552,37 @@ public class GroupTypeOperationTest extends ModelTestBase { GroupTypeDefinition groupTypeDefinition = createGroupTypeDef(); groupTypeDefinition.setModel("testModel"); Model model = new Model("testModel", ModelTypeEnum.NORMATIVE); - modelOperation.createModel(model , true); + modelOperation.createModel(model, true); Either addGroupType = groupTypeOperation.addGroupType(groupTypeDefinition); assertTrue(addGroupType.isLeft()); Either eitherGroupTypeFetched = - groupTypeOperation.getLatestGroupTypeByType(groupTypeDefinition.getType(), groupTypeDefinition.getModel()); + groupTypeOperation.getLatestGroupTypeByType(groupTypeDefinition.getType(), groupTypeDefinition.getModel()); assertTrue(eitherGroupTypeFetched.isLeft()); assertEquals(groupTypeDefinition.getModel(), eitherGroupTypeFetched.left().value().getModel()); } - + private GroupTypeData getOrCreateRootGroupTypeNode() { Either groupTypeResult = janusGraphDao .getNode(GraphPropertiesDictionary.TYPE.getProperty(), TOSCA_GROUPS_ROOT, GroupTypeData.class); - if(groupTypeResult.isLeft()) { + if (groupTypeResult.isLeft()) { return groupTypeResult.left().value(); } - + return createRootGroupTypeNode(); } - + private GroupTypeData createRootGroupTypeNode() { GroupTypeDefinition rootGroupDefinition = createRootGroupDefinition(); - Either addGroupTypeResult = groupTypeOperation.addGroupType(rootGroupDefinition, false); + Either addGroupTypeResult = groupTypeOperation.addGroupType(rootGroupDefinition, false); assertTrue("check group type added", addGroupTypeResult.isLeft()); - + Either groupTypeResult = janusGraphDao .getNode(GraphPropertiesDictionary.TYPE.getProperty(), rootGroupDefinition.getType(), GroupTypeData.class); - return extractVal(groupTypeResult); + return extractVal(groupTypeResult); } - + private GroupTypeDefinition createRootGroupDefinition() { GroupTypeDefinition groupTypeDefinition = new GroupTypeDefinition(); groupTypeDefinition.setDescription("The TOSCA Group Type all other TOSCA Group Types derive from"); @@ -593,7 +599,7 @@ public class GroupTypeOperationTest extends ModelTestBase { groupTypeDefinition.setIcon(type + "icon"); return groupTypeDefinition; } - + private CapabilityTypeDefinition createCapabilityType(Map properties) { CapabilityTypeDefinition rootCapabilityTypeDefinition = new CapabilityTypeDefinition(); rootCapabilityTypeDefinition.setType("tosca.capabilities.Root"); @@ -601,7 +607,6 @@ public class GroupTypeOperationTest extends ModelTestBase { rootCapabilityTypeDefinition.setVersion("1.0"); capabilityTypeOperation.addCapabilityType(rootCapabilityTypeDefinition, true); - CapabilityTypeDefinition parentCapabilityTypeDefinition = new CapabilityTypeDefinition(); parentCapabilityTypeDefinition.setType("tosca.capabilities.Parent"); parentCapabilityTypeDefinition.setDescription("Dummy parent type"); @@ -613,7 +618,6 @@ public class GroupTypeOperationTest extends ModelTestBase { parentCapabilityTypeDefinition.setProperties(capTypeProperties); capabilityTypeOperation.addCapabilityType(parentCapabilityTypeDefinition, true); - CapabilityTypeDefinition capabilityTypeDefinition = new CapabilityTypeDefinition(); capabilityTypeDefinition.setDescription("ability to expose routing information of the internal network"); capabilityTypeDefinition.setType("org.openecomp.capabilities.VLANAssignment"); @@ -622,15 +626,16 @@ public class GroupTypeOperationTest extends ModelTestBase { capabilityTypeDefinition.setProperties(properties); - Either addCapabilityTypeResult = capabilityTypeOperation.addCapabilityType(capabilityTypeDefinition, true); + Either addCapabilityTypeResult = capabilityTypeOperation.addCapabilityType( + capabilityTypeDefinition, true); assertTrue("check capability type added", addCapabilityTypeResult.isLeft()); CapabilityTypeDefinition capabilityTypeAdded = addCapabilityTypeResult.left().value(); compareBetweenCreatedToSent(capabilityTypeDefinition, capabilityTypeAdded); - + return capabilityTypeDefinition; } - + private CapabilityDefinition buildCapabilityDefintion(List properties) { CapabilityDefinition capabilityDefinition = new CapabilityDefinition(); capabilityDefinition.setName("vlan_assignment"); @@ -650,27 +655,27 @@ public class GroupTypeOperationTest extends ModelTestBase { return property; } - + private void compareBetweenCreatedToSent(CapabilityTypeDefinition expected, CapabilityTypeDefinition actual) { assertEquals(expected.getDerivedFrom(), actual.getDerivedFrom()); assertEquals(expected.getType(), actual.getType()); assertEquals(expected.getDescription(), actual.getDescription()); } - + private void compareBetweenCreatedToSent(GroupTypeDefinition expected, GroupTypeDefinition actual) { assertEquals(expected.getType(), actual.getType()); assertEquals(expected.getDescription(), actual.getDescription()); } - + private void validate(Either result) { extractVal(result); } - + private T extractVal(Either result) { assertTrue(result.isLeft()); T t = result.left().value(); assertNotNull(t); - + return t; } @@ -709,11 +714,12 @@ public class GroupTypeOperationTest extends ModelTestBase { updatedType.setIcon("icon"); groupTypeOperation.updateGroupType(updatedType, currGroupType.left().value()); - Either fetchedUpdatedType = groupTypeOperation.getLatestGroupTypeByType(createdType.getType(), createdType.getModel()); + Either fetchedUpdatedType = groupTypeOperation.getLatestGroupTypeByType(createdType.getType(), + createdType.getModel()); GroupTypeDefinition fetchedGroupType = fetchedUpdatedType.left().value(); assertThat(fetchedGroupType.getProperties()).isEmpty(); assertThat(fetchedGroupType) - .isEqualToIgnoringGivenFields(updatedType, "properties", "capabilities"); + .isEqualToIgnoringGivenFields(updatedType, "properties", "capabilities"); } @@ -727,25 +733,26 @@ public class GroupTypeOperationTest extends ModelTestBase { PropertyDefinition prop3 = createSimpleProperty("val3", "prop3", "string"); GroupTypeDefinition updatedGroupType = createGroupTypeDef(updatedProp1, prop3); - Either updatedGroupTypeRetrieved = groupTypeOperation.updateGroupType(updatedGroupType, currGroupType.left().value()); + Either updatedGroupTypeRetrieved = groupTypeOperation.updateGroupType(updatedGroupType, + currGroupType.left().value()); assertEquals(StorageOperationStatus.MATCH_NOT_FOUND, updatedGroupTypeRetrieved.right().value()); } - + @Test public void validateGroupType_FailedDueAttempToCreateGroupTypeWithPropertyWhichTypeIsDifferentFromTypeOfParentPropertyWithTheSameName() { GroupTypeDefinition rootGroupType = createGroupTypeDef(); Either rootGroupTypeRes = groupTypeOperation.addGroupType(rootGroupType); assertTrue(rootGroupTypeRes.isLeft()); - + PropertyDefinition prop = createSimpleProperty("val1", "prop", "string"); GroupTypeDefinition groupType1 = createGroupTypeDef("type1", "descr1", rootGroupType.getType(), prop); Either groupType1Res = groupTypeOperation.addGroupType(groupType1); assertTrue(groupType1Res.isLeft()); - + PropertyDefinition prop1 = createSimpleProperty("33", "prop", "int"); PropertyDefinition prop2 = createSimpleProperty("val2", "prop2", "string"); GroupTypeDefinition groupType2 = createGroupTypeDef("type2", "descr", groupType1.getType(), prop1, prop2); - + Either updatedGroupTypeRetrieved = groupTypeOperation.validateUpdateProperties(groupType2); assertEquals(StorageOperationStatus.PROPERTY_NAME_ALREADY_EXISTS, updatedGroupTypeRetrieved.right().value()); } @@ -759,7 +766,8 @@ public class GroupTypeOperationTest extends ModelTestBase { Either currGroupType = groupTypeOperation.addGroupType(groupType1); groupTypeOperation.updateGroupType(updatedGroupType, currGroupType.left().value()); - Either latestGroupType = groupTypeOperation.getLatestGroupTypeByType(groupType1.getType(), groupType1.getModel()); + Either latestGroupType = groupTypeOperation.getLatestGroupTypeByType(groupType1.getType(), + groupType1.getModel()); assertThat(latestGroupType.left().value().getDerivedFrom()).isEqualTo(rootGroupType.getType()); verifyDerivedFromNodeEqualsToRootGroupType(rootGroupType, latestGroupType.left().value().getUniqueId()); } @@ -772,10 +780,12 @@ public class GroupTypeOperationTest extends ModelTestBase { groupTypeOperation.addGroupType(rootGroupType); Either currGroupType = groupTypeOperation.addGroupType(groupType1); - Either updateGroupTypeRes = groupTypeOperation.updateGroupType(updatedGroupType, currGroupType.left().value()); + Either updateGroupTypeRes = groupTypeOperation.updateGroupType(updatedGroupType, + currGroupType.left().value()); assertThat(updateGroupTypeRes.right().value()).isEqualTo(StorageOperationStatus.NOT_FOUND); - Either latestGroupType = groupTypeOperation.getLatestGroupTypeByType(groupType1.getType(), groupType1.getModel()); + Either latestGroupType = groupTypeOperation.getLatestGroupTypeByType(groupType1.getType(), + groupType1.getModel()); assertThat(latestGroupType.left().value().getDerivedFrom()).isEqualTo(rootGroupType.getType()); } @@ -792,10 +802,11 @@ public class GroupTypeOperationTest extends ModelTestBase { groupTypeOperation.updateGroupType(updatedGroupType, currGroupType.left().value()); - Either latestGroupType = groupTypeOperation.getLatestGroupTypeByType(groupType1.getType(), groupType1.getModel()); + Either latestGroupType = groupTypeOperation.getLatestGroupTypeByType(groupType1.getType(), + groupType1.getModel()); assertThat(latestGroupType.left().value().getDerivedFrom()).isEqualTo(derivedType1.getType()); } - + @Test public void updateGroupType_updateDerivedFrom_CauseEndlessRecursion() { GroupTypeDefinition rootGroupType = createGroupTypeDef(); @@ -807,10 +818,12 @@ public class GroupTypeOperationTest extends ModelTestBase { Either currGroupType = groupTypeOperation.addGroupType(derivedType1); groupTypeOperation.addGroupType(groupType1); - Either updateResult = groupTypeOperation.updateGroupType(updatedGroupType, currGroupType.left().value()); + Either updateResult = groupTypeOperation.updateGroupType(updatedGroupType, + currGroupType.left().value()); assertThat(updateResult.right().value()).isEqualTo(StorageOperationStatus.GENERAL_ERROR); - Either latestGroupType = groupTypeOperation.getLatestGroupTypeByType(updatedGroupType.getType(), updatedGroupType.getModel()); + Either latestGroupType = groupTypeOperation.getLatestGroupTypeByType(updatedGroupType.getType(), + updatedGroupType.getModel()); assertThat(latestGroupType.left().value().getDerivedFrom()).isEqualTo(rootGroupType.getType()); } @@ -827,7 +840,7 @@ public class GroupTypeOperationTest extends ModelTestBase { .getChild(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.GroupType), parentGroupId, GraphEdgeLabels.DERIVED_FROM, NodeTypeEnum.GroupType, GroupTypeData.class); assertThat(derivedFromRelation.left().value().getLeft().getGroupTypeDataDefinition()) - .isEqualToComparingFieldByField(rootGroupType); + .isEqualToComparingFieldByField(rootGroupType); } private void verifyDerivedFromRelationDoesntExist(String parentGroupId) { @@ -835,19 +848,21 @@ public class GroupTypeOperationTest extends ModelTestBase { .getChild(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.GroupType), parentGroupId, GraphEdgeLabels.DERIVED_FROM, NodeTypeEnum.GroupType, GroupTypeData.class); assertThat(derivedFromRelation.right().value()) - .isEqualTo(JanusGraphOperationStatus.NOT_FOUND); + .isEqualTo(JanusGraphOperationStatus.NOT_FOUND); } private GroupTypeDefinition createGroupTypeDef() { - return createGroupTypeDef("tosca.groups.Root", "description: The TOSCA Group Type all other TOSCA Group Types derive from", null, new PropertyDefinition[]{}); + return createGroupTypeDef("tosca.groups.Root", "description: The TOSCA Group Type all other TOSCA Group Types derive from", null, + new PropertyDefinition[]{}); } - private GroupTypeDefinition createGroupTypeDef(PropertyDefinition ... props) { - return createGroupTypeDef("tosca.groups.Root", null, props); + private GroupTypeDefinition createGroupTypeDef(PropertyDefinition... props) { + return createGroupTypeDef("tosca.groups.Root", null, props); } - private GroupTypeDefinition createGroupTypeDef(String type, String derivedFrom, PropertyDefinition ... props) { - GroupTypeDefinition groupType = createGroupTypeDef(type, "description: The TOSCA Group Type all other TOSCA Group Types derive from", derivedFrom); + private GroupTypeDefinition createGroupTypeDef(String type, String derivedFrom, PropertyDefinition... props) { + GroupTypeDefinition groupType = createGroupTypeDef(type, "description: The TOSCA Group Type all other TOSCA Group Types derive from", + derivedFrom); groupType.setProperties(asList(props)); return groupType; } @@ -856,7 +871,7 @@ public class GroupTypeOperationTest extends ModelTestBase { return createGroupTypeDef(type, description, derivedFrom, null); } - private GroupTypeDefinition createGroupTypeDef(String type, String description, String derivedFrom, PropertyDefinition ... props) { + private GroupTypeDefinition createGroupTypeDef(String type, String description, String derivedFrom, PropertyDefinition... props) { GroupTypeDataDefinition groupTypeDataDefinition = new GroupTypeDataDefinition(); groupTypeDataDefinition.setDescription(description); groupTypeDataDefinition.setType(type); diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperationTest.java index 1a7f1c8ba3..7ccf1f6d6b 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperationTest.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. @@ -26,18 +26,17 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; +import fj.data.Either; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; - import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; @@ -60,14 +59,11 @@ import org.openecomp.sdc.be.resources.data.OperationData; import org.openecomp.sdc.be.resources.data.ResourceMetadataData; import org.openecomp.sdc.be.resources.data.UserData; import org.openecomp.sdc.be.resources.data.category.CategoryData; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import fj.data.Either; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration("classpath:application-context-test.xml") +@SpringJUnitConfig(locations = "classpath:application-context-test.xml") public class InterfaceLifecycleOperationTest { + private static String USER_ID = "muUserId"; private static String CATEGORY_NAME = "category/mycategory"; private static String MODEL_NAME = "Test"; @@ -77,20 +73,20 @@ public class InterfaceLifecycleOperationTest { @InjectMocks private InterfaceLifecycleOperation interfaceLifecycleOperation = new InterfaceLifecycleOperation(); - @Before + @BeforeAll + public static void setupBeforeClass() { + ModelTestBase.init(); + } + + @BeforeEach public void createUserAndCategory() { MockitoAnnotations.initMocks(this); CategoryData categoryData = new CategoryData(NodeTypeEnum.ResourceCategory); - when(janusGraphGenericDao.createNode(any(),any())).thenReturn(Either.left(categoryData)); + when(janusGraphGenericDao.createNode(any(), any())).thenReturn(Either.left(categoryData)); deleteAndCreateCategory(CATEGORY_NAME); deleteAndCreateUser(USER_ID, "first_" + USER_ID, "last_" + USER_ID); } - @BeforeClass - public static void setupBeforeClass() { - ModelTestBase.init(); - } - @Test public void testDummy() { assertNotNull(interfaceLifecycleOperation); @@ -125,24 +121,31 @@ public class InterfaceLifecycleOperationTest { @Test public void createInterfaceOnResourceTest() { - when(janusGraphGenericDao.getChildrenNodes(any(), any(), any(), any(), eq(InterfaceData.class))).thenReturn(Either.right(JanusGraphOperationStatus.GRAPH_IS_NOT_AVAILABLE)); - when(janusGraphGenericDao.getChild(any(), any(), any(), eq(NodeTypeEnum.Resource), eq(ResourceMetadataData.class))).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)); + when(janusGraphGenericDao.getChildrenNodes(any(), any(), any(), any(), eq(InterfaceData.class))).thenReturn( + Either.right(JanusGraphOperationStatus.GRAPH_IS_NOT_AVAILABLE)); + when(janusGraphGenericDao.getChild(any(), any(), any(), eq(NodeTypeEnum.Resource), eq(ResourceMetadataData.class))).thenReturn( + Either.right(JanusGraphOperationStatus.NOT_FOUND)); when(janusGraphGenericDao.getNode(any(), any(), eq(InterfaceData.class))).thenReturn(Either.right(JanusGraphOperationStatus.ALREADY_EXIST)); when(janusGraphGenericDao.createNode(any(), eq(InterfaceData.class))).thenReturn(Either.right(JanusGraphOperationStatus.ALREADY_EXIST)); - when(janusGraphGenericDao.createRelation(any(), any(), eq(GraphEdgeLabels.INTERFACE), any())).thenReturn(Either.right(JanusGraphOperationStatus.OK)); + when(janusGraphGenericDao.createRelation(any(), any(), eq(GraphEdgeLabels.INTERFACE), any())).thenReturn( + Either.right(JanusGraphOperationStatus.OK)); Assert.assertTrue(interfaceLifecycleOperation.createInterfaceOnResource(buildInterfaceDefinition(), "", "", false, false).isRight()); - when(janusGraphGenericDao.createRelation(any(), any(), eq(GraphEdgeLabels.INTERFACE), any())).thenReturn(Either.left(Mockito.mock(GraphRelation.class))); + when(janusGraphGenericDao.createRelation(any(), any(), eq(GraphEdgeLabels.INTERFACE), any())).thenReturn( + Either.left(Mockito.mock(GraphRelation.class))); Assert.assertTrue(interfaceLifecycleOperation.createInterfaceOnResource(buildInterfaceDefinition(), "", "", false, false).isRight()); } @Test public void getAllInterfacesOfResourceTest() { assertTrue(interfaceLifecycleOperation.getAllInterfacesOfResource(null, true).isRight()); - when(janusGraphGenericDao.getChildrenNodes(any(), any(), any(), any(), eq(InterfaceData.class))).thenReturn(Either.right(JanusGraphOperationStatus.GRAPH_IS_NOT_AVAILABLE)); - when(janusGraphGenericDao.getChild(any(), any(), any(), eq(NodeTypeEnum.Resource), eq(ResourceMetadataData.class))).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)); + when(janusGraphGenericDao.getChildrenNodes(any(), any(), any(), any(), eq(InterfaceData.class))).thenReturn( + Either.right(JanusGraphOperationStatus.GRAPH_IS_NOT_AVAILABLE)); + when(janusGraphGenericDao.getChild(any(), any(), any(), eq(NodeTypeEnum.Resource), eq(ResourceMetadataData.class))).thenReturn( + Either.right(JanusGraphOperationStatus.NOT_FOUND)); assertTrue(interfaceLifecycleOperation.getAllInterfacesOfResource("null", true).isLeft()); - when(janusGraphGenericDao.getChild(any(), any(), any(), eq(NodeTypeEnum.Resource), eq(ResourceMetadataData.class))).thenReturn(Either.right(JanusGraphOperationStatus.ALREADY_EXIST)); + when(janusGraphGenericDao.getChild(any(), any(), any(), eq(NodeTypeEnum.Resource), eq(ResourceMetadataData.class))).thenReturn( + Either.right(JanusGraphOperationStatus.ALREADY_EXIST)); assertTrue(interfaceLifecycleOperation.getAllInterfacesOfResource("null", true).isRight()); ResourceMetadataData key = Mockito.mock(ResourceMetadataData.class); @@ -151,8 +154,8 @@ public class InterfaceLifecycleOperationTest { when(key.getMetadataDataDefinition()).thenReturn(def); ImmutablePair pair = new ImmutablePair<>(key, Mockito.mock(GraphEdge.class)); when(janusGraphGenericDao.getChild(any(), any(), any(), eq(NodeTypeEnum.Resource), eq(ResourceMetadataData.class))) - .thenReturn(Either.left(pair)) - .thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)); + .thenReturn(Either.left(pair)) + .thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)); assertTrue(interfaceLifecycleOperation.getAllInterfacesOfResource("null", true).isLeft()); } @@ -160,7 +163,8 @@ public class InterfaceLifecycleOperationTest { public void testGetAllInterfaceLifecycleTypes_TypesNotFound() { when(janusGraphGenericDao.getByCriteriaForModel(NodeTypeEnum.Interface, Collections.emptyMap(), StringUtils.EMPTY, InterfaceData.class)).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)); - Either, StorageOperationStatus> types = interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(StringUtils.EMPTY); + Either, StorageOperationStatus> types = interfaceLifecycleOperation.getAllInterfaceLifecycleTypes( + StringUtils.EMPTY); Assert.assertEquals(types.isRight(), Boolean.TRUE); } @@ -175,15 +179,18 @@ public class InterfaceLifecycleOperationTest { interfaceDataList.add(interfaceData); Either, JanusGraphOperationStatus> allInterfaceTypes = Either.left(interfaceDataList); when(janusGraphGenericDao - .getByCriteriaForModel(NodeTypeEnum.Interface, Collections.emptyMap(), StringUtils.EMPTY, InterfaceData.class)).thenReturn(allInterfaceTypes); + .getByCriteriaForModel(NodeTypeEnum.Interface, Collections.emptyMap(), StringUtils.EMPTY, InterfaceData.class)).thenReturn( + allInterfaceTypes); List> list = new ArrayList<>(); Either>, JanusGraphOperationStatus> childrenNodes = Either.left(list); - when(janusGraphGenericDao.getChildrenNodes(interfaceData.getUniqueIdKey(), interfaceData.getUniqueId(), GraphEdgeLabels.INTERFACE_OPERATION, NodeTypeEnum.InterfaceOperation, OperationData.class)).thenReturn(childrenNodes); + when(janusGraphGenericDao.getChildrenNodes(interfaceData.getUniqueIdKey(), interfaceData.getUniqueId(), GraphEdgeLabels.INTERFACE_OPERATION, + NodeTypeEnum.InterfaceOperation, OperationData.class)).thenReturn(childrenNodes); when(janusGraphGenericDao.getParentNode(any(), any(), any(), any(), any())) - .thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)); - Either, StorageOperationStatus> types = interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(StringUtils.EMPTY); - Assert.assertEquals(types.left().value().size(),1); + .thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)); + Either, StorageOperationStatus> types = interfaceLifecycleOperation.getAllInterfaceLifecycleTypes( + StringUtils.EMPTY); + Assert.assertEquals(types.left().value().size(), 1); } @Test @@ -200,10 +207,12 @@ public class InterfaceLifecycleOperationTest { interfaceTypes.add(interfaceData); when(janusGraphGenericDao.getParentNode(any(), any(), any(), any(), any())) - .thenReturn(Either.left(modelNode)); + .thenReturn(Either.left(modelNode)); when(janusGraphGenericDao - .getByCriteriaForModel(NodeTypeEnum.Interface, Collections.emptyMap(), MODEL_NAME, InterfaceData.class)).thenReturn(Either.left(interfaceTypes)); - when(janusGraphGenericDao.getChildrenNodes(interfaceData.getUniqueIdKey(), interfaceData.getUniqueId(), GraphEdgeLabels.INTERFACE_OPERATION, NodeTypeEnum.InterfaceOperation, OperationData.class)).thenReturn(Either.left(Collections.emptyList())); + .getByCriteriaForModel(NodeTypeEnum.Interface, Collections.emptyMap(), MODEL_NAME, InterfaceData.class)).thenReturn( + Either.left(interfaceTypes)); + when(janusGraphGenericDao.getChildrenNodes(interfaceData.getUniqueIdKey(), interfaceData.getUniqueId(), GraphEdgeLabels.INTERFACE_OPERATION, + NodeTypeEnum.InterfaceOperation, OperationData.class)).thenReturn(Either.left(Collections.emptyList())); Assert.assertEquals(1, interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(MODEL_NAME).left().value().size()); } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperationTest.java index a6b2aa687a..9fd929852a 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperationTest.java @@ -25,6 +25,8 @@ import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; + +import fj.data.Either; import java.util.Iterator; import java.util.List; import java.util.stream.Stream; @@ -32,10 +34,9 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; import org.janusgraph.core.JanusGraph; import org.janusgraph.core.JanusGraphVertex; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge; import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphGenericDao; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao; @@ -51,12 +52,9 @@ import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.resources.data.PolicyTypeData; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import fj.data.Either; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration("classpath:application-context-test.xml") +@SpringJUnitConfig(locations = "classpath:application-context-test.xml") public class PolicyTypeOperationTest extends ModelTestBase { private static final String NULL_STRING = null; @@ -68,13 +66,13 @@ public class PolicyTypeOperationTest extends ModelTestBase { @Autowired private HealingJanusGraphGenericDao janusGraphGenericDao; - @BeforeClass + @BeforeAll public static void setupBeforeClass() { ModelTestBase.init(); } - @Before + @BeforeEach public void cleanUp() { JanusGraphGenericDao janusGraphGenericDao = policyTypeOperation.janusGraphGenericDao; Either graphResult = janusGraphGenericDao.getGraph(); @@ -107,7 +105,8 @@ public class PolicyTypeOperationTest extends ModelTestBase { @Test public void testGetLatestPolicyTypeByType() { PolicyTypeDefinition policyTypeCreated = policyTypeOperation.addPolicyType(createPolicyTypeDef()).left().value(); - Either eitherPolicyTypeFetched = policyTypeOperation.getLatestPolicyTypeByType(policyTypeCreated.getType(), policyTypeCreated.getModel()); + Either eitherPolicyTypeFetched = policyTypeOperation.getLatestPolicyTypeByType( + policyTypeCreated.getType(), policyTypeCreated.getModel()); assertTrue(eitherPolicyTypeFetched.isLeft()); PolicyTypeDefinition policyTypeFetched = eitherPolicyTypeFetched.left().value(); assertEquals(policyTypeFetched.toString(), policyTypeCreated.toString()); @@ -118,7 +117,7 @@ public class PolicyTypeOperationTest extends ModelTestBase { PolicyTypeDefinition policyTypeDefinition = createPolicyTypeDef(); policyTypeDefinition.setModel("testModel"); Model model = new Model("testModel", ModelTypeEnum.NORMATIVE); - modelOperation.createModel(model , true); + modelOperation.createModel(model, true); Either addPolicyType = policyTypeOperation.addPolicyType(policyTypeDefinition); assertTrue(addPolicyType.isLeft()); @@ -134,7 +133,8 @@ public class PolicyTypeOperationTest extends ModelTestBase { String derivedFromRootType = rootPolicyType.getType(); PolicyTypeDefinition policyType1 = createPolicyTypeDef("tosca.policies.type1", "desc1", derivedFromRootType); policyTypeOperation.addPolicyType(policyType1); - Either eitherPolicyTypeFetched = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType(), policyType1.getModel()); + Either eitherPolicyTypeFetched = policyTypeOperation.getLatestPolicyTypeByType( + policyType1.getType(), policyType1.getModel()); assertThat(eitherPolicyTypeFetched.left().value().getDerivedFrom()).isEqualTo(rootPolicyType.getType()); } @@ -145,7 +145,8 @@ public class PolicyTypeOperationTest extends ModelTestBase { PolicyTypeDefinition policyType1 = createPolicyTypeDef("tosca.policies.type1", null, prop1, prop2); PolicyTypeDefinition policyType2 = createPolicyTypeDef("tosca.policies.type2", "desc3", policyType1.getType(), null); addPolicyTypesToDB(policyType1, policyType2); - Either latestPolicyType2 = policyTypeOperation.getLatestPolicyTypeByType(policyType2.getType(), policyType2.getModel()); + Either latestPolicyType2 = policyTypeOperation.getLatestPolicyTypeByType(policyType2.getType(), + policyType2.getModel()); assertThat(latestPolicyType2.isLeft()).isTrue(); assertThat(latestPolicyType2.left().value().getProperties()) .usingElementComparatorOnFields("defaultValue", "name", "type") @@ -166,7 +167,8 @@ public class PolicyTypeOperationTest extends ModelTestBase { addPolicyTypesToDB(rootPolicyType, policyType1, policyType2, policyType3, policyType4); - Either latestPolicyType3 = policyTypeOperation.getLatestPolicyTypeByType(policyType4.getType(), policyType4.getModel()); + Either latestPolicyType3 = policyTypeOperation.getLatestPolicyTypeByType(policyType4.getType(), + policyType4.getModel()); assertThat(latestPolicyType3.isLeft()).isTrue(); assertThat(latestPolicyType3.left().value().getProperties()) .usingElementComparatorOnFields("defaultValue", "name", "type") @@ -220,7 +222,8 @@ public class PolicyTypeOperationTest extends ModelTestBase { Either addedPolicyTypeResult = policyTypeOperation.addPolicyType(policyType1); assertThat(addedPolicyTypeResult.isLeft()).isTrue(); - Either fetchedPolicyType = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType(), policyType1.getModel()); + Either fetchedPolicyType = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType(), + policyType1.getModel()); PolicyTypeDefinition fetchedPolicyTypeVal = fetchedPolicyType.left().value(); assertThat(fetchedPolicyTypeVal.getDerivedFrom()).isEqualTo(derivedFromRootType); verifyDerivedFromNodeEqualsToRootPolicyType(rootPolicyType, fetchedPolicyTypeVal.getUniqueId()); @@ -245,7 +248,8 @@ public class PolicyTypeOperationTest extends ModelTestBase { updatedType.setIcon("icon"); policyTypeOperation.updatePolicyType(updatedType, currPolicyType.left().value()); - Either fetchedUpdatedType = policyTypeOperation.getLatestPolicyTypeByType(createdType.getType(), createdType.getModel()); + Either fetchedUpdatedType = policyTypeOperation.getLatestPolicyTypeByType(createdType.getType(), + createdType.getModel()); PolicyTypeDefinition fetchedPolicyType = fetchedUpdatedType.left().value(); assertThat(fetchedPolicyType.getProperties()).isEmpty(); assertThat(fetchedPolicyType) @@ -266,7 +270,8 @@ public class PolicyTypeOperationTest extends ModelTestBase { policyTypeOperation.updatePolicyType(updatedPolicyType, currPolicyType.left().value()); - Either fetchedUpdatedType = policyTypeOperation.getLatestPolicyTypeByType(policyType.getType(), policyType.getModel()); + Either fetchedUpdatedType = policyTypeOperation.getLatestPolicyTypeByType(policyType.getType(), + policyType.getModel()); assertThat(fetchedUpdatedType.left().value().getProperties()) .usingElementComparatorOnFields("name", "defaultValue", "type") .containsExactlyInAnyOrder(updatedProp1, prop3); @@ -282,7 +287,8 @@ public class PolicyTypeOperationTest extends ModelTestBase { Either currPolicyType = policyTypeOperation.addPolicyType(policyType1); policyTypeOperation.updatePolicyType(updatedPolicyType, currPolicyType.left().value()); - Either latestPolicyType = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType(), policyType1.getModel()); + Either latestPolicyType = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType(), + policyType1.getModel()); assertThat(latestPolicyType.left().value().getDerivedFrom()).isEqualTo(rootPolicyType.getType()); verifyDerivedFromNodeEqualsToRootPolicyType(rootPolicyType, latestPolicyType.left().value().getUniqueId()); } @@ -297,7 +303,8 @@ public class PolicyTypeOperationTest extends ModelTestBase { policyTypeOperation.updatePolicyType(updatedPolicyType, currPolicyType.left().value()); - Either latestPolicyType = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType(), policyType1.getModel()); + Either latestPolicyType = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType(), + policyType1.getModel()); assertThat(latestPolicyType.left().value().getDerivedFrom()).isNull(); verifyDerivedFromRelationDoesntExist(latestPolicyType.left().value().getUniqueId()); } @@ -315,7 +322,8 @@ public class PolicyTypeOperationTest extends ModelTestBase { policyTypeOperation.updatePolicyType(updatedPolicyType, currPolicyType.left().value()); - Either latestPolicyType = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType(), policyType1.getModel()); + Either latestPolicyType = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType(), + policyType1.getModel()); assertThat(latestPolicyType.left().value().getDerivedFrom()).isEqualTo(rootPolicyType.getType()); verifyDerivedFromNodeEqualsToRootPolicyType(rootPolicyType, latestPolicyType.left().value().getUniqueId()); } @@ -329,14 +337,16 @@ public class PolicyTypeOperationTest extends ModelTestBase { } private void verifyDerivedFromNodeEqualsToRootPolicyType(PolicyTypeDefinition rootPolicyType, String parentPolicyId) { - Either, JanusGraphOperationStatus> derivedFromRelation = janusGraphGenericDao.getChild(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.PolicyType), parentPolicyId, GraphEdgeLabels.DERIVED_FROM, + Either, JanusGraphOperationStatus> derivedFromRelation = janusGraphGenericDao.getChild( + UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.PolicyType), parentPolicyId, GraphEdgeLabels.DERIVED_FROM, NodeTypeEnum.PolicyType, PolicyTypeData.class); assertThat(derivedFromRelation.left().value().getLeft().getPolicyTypeDataDefinition()) .isEqualToComparingFieldByField(rootPolicyType); } private void verifyDerivedFromRelationDoesntExist(String parentPolicyId) { - Either, JanusGraphOperationStatus> derivedFromRelation = janusGraphGenericDao.getChild(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.PolicyType), parentPolicyId, GraphEdgeLabels.DERIVED_FROM, + Either, JanusGraphOperationStatus> derivedFromRelation = janusGraphGenericDao.getChild( + UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.PolicyType), parentPolicyId, GraphEdgeLabels.DERIVED_FROM, NodeTypeEnum.PolicyType, PolicyTypeData.class); assertThat(derivedFromRelation.right().value()) .isEqualTo(JanusGraphOperationStatus.NOT_FOUND); @@ -350,15 +360,17 @@ public class PolicyTypeOperationTest extends ModelTestBase { } private PolicyTypeDefinition createPolicyTypeDef() { - return createPolicyTypeDef("tosca.policies.Root", "description: The TOSCA Policy Type all other TOSCA Policy Types derive from", null, new PropertyDefinition[]{}); + return createPolicyTypeDef("tosca.policies.Root", "description: The TOSCA Policy Type all other TOSCA Policy Types derive from", null, + new PropertyDefinition[]{}); } - private PolicyTypeDefinition createPolicyTypeDef(PropertyDefinition ... props) { - return createPolicyTypeDef("tosca.policies.Root", null, props); + private PolicyTypeDefinition createPolicyTypeDef(PropertyDefinition... props) { + return createPolicyTypeDef("tosca.policies.Root", null, props); } - private PolicyTypeDefinition createPolicyTypeDef(String type, String derivedFrom, PropertyDefinition ... props) { - PolicyTypeDefinition policyType = createPolicyTypeDef(type, "description: The TOSCA Policy Type all other TOSCA Policy Types derive from", derivedFrom); + private PolicyTypeDefinition createPolicyTypeDef(String type, String derivedFrom, PropertyDefinition... props) { + PolicyTypeDefinition policyType = createPolicyTypeDef(type, "description: The TOSCA Policy Type all other TOSCA Policy Types derive from", + derivedFrom); policyType.setProperties(asList(props)); return policyType; } @@ -367,7 +379,7 @@ public class PolicyTypeOperationTest extends ModelTestBase { return createPolicyTypeDef(type, description, derivedFrom, null); } - private PolicyTypeDefinition createPolicyTypeDef(String type, String description, String derivedFrom, PropertyDefinition ... props) { + private PolicyTypeDefinition createPolicyTypeDef(String type, String description, String derivedFrom, PropertyDefinition... props) { PolicyTypeDataDefinition policyTypeDataDefinition = new PolicyTypeDataDefinition(); policyTypeDataDefinition.setDescription(description); policyTypeDataDefinition.setType(type); @@ -383,7 +395,7 @@ public class PolicyTypeOperationTest extends ModelTestBase { return policyTypeDefinition; } - private void addPolicyTypesToDB(PolicyTypeDefinition ... policyTypeDefinitions) { + private void addPolicyTypesToDB(PolicyTypeDefinition... policyTypeDefinitions) { Stream.of(policyTypeDefinitions).forEach(policyTypeOperation::addPolicyType); } } \ No newline at end of file diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RelationshipTypeOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RelationshipTypeOperationTest.java index 371c3edfe5..ee3ea9e026 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RelationshipTypeOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RelationshipTypeOperationTest.java @@ -24,21 +24,18 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import fj.data.Either; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; - -import fj.data.Either; -import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.tuple.ImmutablePair; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; @@ -64,11 +61,9 @@ import org.openecomp.sdc.be.model.tosca.constraints.InRangeConstraint; import org.openecomp.sdc.be.model.tosca.constraints.LessOrEqualConstraint; import org.openecomp.sdc.be.resources.data.ModelData; import org.openecomp.sdc.be.resources.data.RelationshipTypeData; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration("classpath:application-context-test.xml") +@SpringJUnitConfig(locations = "classpath:application-context-test.xml") public class RelationshipTypeOperationTest extends ModelTestBase { private static final String PROP = "prop"; @@ -98,12 +93,12 @@ public class RelationshipTypeOperationTest extends ModelTestBase { relationshipTypeDefinition.setUniqueId("tosca.relationships.Container1"); } - @BeforeClass + @BeforeAll public static void setupBeforeClass() { ModelTestBase.init(); } - @Before + @BeforeEach public void setUp() throws Exception { MockitoAnnotations.initMocks(this); @@ -119,18 +114,17 @@ public class RelationshipTypeOperationTest extends ModelTestBase { @Test public void testAddRelationshipTypeValidationFailStatusNullInTransactionFalse() { Mockito.doReturn(Either.right(JanusGraphOperationStatus.NOT_CONNECTED)) - .when(propertyOperation) - .getAllTypePropertiesFromAllDerivedFrom(Mockito.anyString(), Mockito.any(), Mockito.any()); - + .when(propertyOperation) + .getAllTypePropertiesFromAllDerivedFrom(Mockito.anyString(), Mockito.any(), Mockito.any()); + Mockito.doReturn(Either.left(new RelationshipTypeData(relationshipTypeDefinition))) - .when(janusGraphGenericDao).getNode(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()); - - Mockito.doReturn(Either.left(Collections.singletonMap("derivedFromProp1", new PropertyDefinition()))).when(propertyOperation) - .findPropertiesOfNode(Mockito.any(), Mockito.anyString()); + .when(janusGraphGenericDao).getNode(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()); + Mockito.doReturn(Either.left(Collections.singletonMap("derivedFromProp1", new PropertyDefinition()))).when(propertyOperation) + .findPropertiesOfNode(Mockito.any(), Mockito.anyString()); Either addRelationshipType = - relationshipTypeOperation.addRelationshipType(relationshipTypeDefinition, false); + relationshipTypeOperation.addRelationshipType(relationshipTypeDefinition, false); assertTrue(addRelationshipType.isRight()); } @@ -138,18 +132,18 @@ public class RelationshipTypeOperationTest extends ModelTestBase { @Test public void testAddRelationshipTypeValidationFailStatusPropertiesReturnedInTransactionFalse() { Mockito.doReturn(Either.left(Collections.singletonMap("prop1", new PropertyDefinition()))).when(propertyOperation) - .getAllTypePropertiesFromAllDerivedFrom(Mockito.anyString(), Mockito.any(), Mockito.any()); + .getAllTypePropertiesFromAllDerivedFrom(Mockito.anyString(), Mockito.any(), Mockito.any()); Mockito.doReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)).when(propertyOperation) - .validatePropertiesUniqueness(Mockito.any(), Mockito.any()); - + .validatePropertiesUniqueness(Mockito.any(), Mockito.any()); + Mockito.doReturn(Either.left(new RelationshipTypeData(relationshipTypeDefinition))) - .when(janusGraphGenericDao).getNode(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()); - + .when(janusGraphGenericDao).getNode(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()); + Mockito.doReturn(Either.left(Collections.singletonMap("derivedFromProp1", new PropertyDefinition()))).when(propertyOperation) - .findPropertiesOfNode(Mockito.any(), Mockito.anyString()); + .findPropertiesOfNode(Mockito.any(), Mockito.anyString()); Either addRelationshipType = - relationshipTypeOperation.addRelationshipType(relationshipTypeDefinition, false); + relationshipTypeOperation.addRelationshipType(relationshipTypeDefinition, false); assertTrue(addRelationshipType.isRight()); } @@ -158,7 +152,7 @@ public class RelationshipTypeOperationTest extends ModelTestBase { public void testGetAllRelationshipTypesNotFound() { Mockito.doReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)).when( janusGraphGenericDao).getByCriteriaForModel(NodeTypeEnum.RelationshipType, null, null, - RelationshipTypeData.class); + RelationshipTypeData.class); Either, JanusGraphOperationStatus> either = relationshipTypeOperation.getAllRelationshipTypes(null); assertTrue(either.isLeft() && MapUtils.isEmpty(either.left().value())); @@ -168,7 +162,7 @@ public class RelationshipTypeOperationTest extends ModelTestBase { public void testGetAllRelationshipTypesNotConnnected() { Mockito.doReturn(Either.right(JanusGraphOperationStatus.NOT_CONNECTED)).when( janusGraphGenericDao).getByCriteriaForModel(NodeTypeEnum.RelationshipType, null, null, - RelationshipTypeData.class); + RelationshipTypeData.class); Either, JanusGraphOperationStatus> either = relationshipTypeOperation.getAllRelationshipTypes(null); assertTrue(either.isRight() && JanusGraphOperationStatus.NOT_CONNECTED == either.right().value()); @@ -187,33 +181,33 @@ public class RelationshipTypeOperationTest extends ModelTestBase { relationshipTypeDataList.add(relationshipTypeData1); Mockito.doReturn(Either.left(relationshipTypeDataList)) - .when(janusGraphGenericDao).getByCriteriaForModel(NodeTypeEnum.RelationshipType, null, null, + .when(janusGraphGenericDao).getByCriteriaForModel(NodeTypeEnum.RelationshipType, null, null, RelationshipTypeData.class); Mockito.doReturn(Either.left(relationshipTypeData1)).when(janusGraphGenericDao) - .getNode(Mockito.anyString(), Mockito.anyString(), Mockito.eq(RelationshipTypeData.class)); + .getNode(Mockito.anyString(), Mockito.anyString(), Mockito.eq(RelationshipTypeData.class)); Mockito.doReturn(Either.left(createPropertyData("prop1"))).when(propertyOperation) - .findPropertiesOfNode(NodeTypeEnum.RelationshipType, "tosca.relationships.Root1"); + .findPropertiesOfNode(NodeTypeEnum.RelationshipType, "tosca.relationships.Root1"); RelationshipInstDataDefinition derivedFromRelationshipTypeDefinition = new RelationshipInstDataDefinition(); derivedFromRelationshipTypeDefinition.setUniqueId("tosca.relationships.Root1"); derivedFromRelationshipTypeDefinition.setType("tosca.relationships.Parent"); Mockito.doReturn(Either.left(new RelationshipTypeData(derivedFromRelationshipTypeDefinition))) - .when(derivedFromOperation) - .getDerivedFromChild("tosca.relationships.Root1", NodeTypeEnum.RelationshipType, RelationshipTypeData.class); + .when(derivedFromOperation) + .getDerivedFromChild("tosca.relationships.Root1", NodeTypeEnum.RelationshipType, RelationshipTypeData.class); Either, JanusGraphOperationStatus> either = - relationshipTypeOperation.getAllRelationshipTypes(null); + relationshipTypeOperation.getAllRelationshipTypes(null); assertTrue(either.isLeft()); RelationshipTypeDefinition relationshipTypeDefinition = either.left().value().get("tosca.relationships.Root1"); assertEquals("tosca.relationships.Parent", relationshipTypeDefinition.getDerivedFrom()); - + Mockito.doReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)) .when(janusGraphGenericDao).getByCriteriaForModel(NodeTypeEnum.RelationshipType, null, "modelA", - RelationshipTypeData.class); + RelationshipTypeData.class); either = relationshipTypeOperation.getAllRelationshipTypes("modelA"); assertTrue(either.isLeft()); assertTrue(MapUtils.isEmpty(either.left().value())); @@ -241,11 +235,11 @@ public class RelationshipTypeOperationTest extends ModelTestBase { relationshipTypeDefinition.setProperties(properties); Either addRelationshipType1 = - relationshipTypeOperation.addRelationshipType(relationshipTypeDefinition, true); + relationshipTypeOperation.addRelationshipType(relationshipTypeDefinition, true); RelationshipTypeDefinition relationshipTypeDefinitionCreated = addRelationshipType1.left().value(); Either relationshipType = - relationshipTypeOperation.getRelationshipType(relationshipTypeDefinitionCreated.getUniqueId(), true); + relationshipTypeOperation.getRelationshipType(relationshipTypeDefinitionCreated.getUniqueId(), true); assertTrue("check relationship type fetched", relationshipType.isLeft()); RelationshipTypeDefinition fetchedCTD = relationshipType.left().value(); @@ -260,7 +254,7 @@ public class RelationshipTypeOperationTest extends ModelTestBase { private void compareProperties(Map first, Map second) { assertTrue("check properties are full or empty", - ((first == null && second == null) || (first != null && second != null))); + ((first == null && second == null) || (first != null && second != null))); if (first != null) { assertEquals("check properties size", first.size(), second.size()); @@ -282,11 +276,11 @@ public class RelationshipTypeOperationTest extends ModelTestBase { private void comparePropertyDefinition(PropertyDefinition first, PropertyDefinition second) { assertTrue("check objects are full or empty", - ((first == null && second == null) || (first != null && second != null))); + ((first == null && second == null) || (first != null && second != null))); if (first != null) { assertTrue("check property description", compareValue(first.getDescription(), second.getDescription())); assertTrue("check property default value", compareValue((String) first.getDefaultValue(), - (String) second.getDefaultValue())); + (String) second.getDefaultValue())); assertTrue("check property type", compareValue(first.getType(), second.getType())); compareList(first.getConstraints(), second.getConstraints()); } @@ -296,7 +290,7 @@ public class RelationshipTypeOperationTest extends ModelTestBase { private void compareList(List first, List second) { assertTrue("check lists are full or empty", - ((first == null && second == null) || (first != null && second != null))); + ((first == null && second == null) || (first != null && second != null))); if (first != null) { assertEquals("check list size", first.size(), second.size()); } @@ -321,7 +315,7 @@ public class RelationshipTypeOperationTest extends ModelTestBase { PropertyDefinition property1 = new PropertyDefinition(); property1.setDefaultValue("10"); property1.setDescription("Size of the local disk, in Gigabytes (GB), " - + "available to applications running on the Compute node."); + + "available to applications running on the Compute node."); property1.setType(ToscaType.INTEGER.name().toLowerCase()); List constraints = new ArrayList<>(); GreaterThanConstraint propertyConstraint1 = new GreaterThanConstraint("0"); @@ -362,55 +356,53 @@ public class RelationshipTypeOperationTest extends ModelTestBase { RelationshipTypeDefinition relationshipTypeDefinition = new RelationshipTypeDefinition(relationshipTypeData); relationshipTypeDefinition.setProperties(createPropertyData("prop1")); relationshipTypeDefinition.setDerivedFrom("tosca.relationships.Root"); - - Mockito.doReturn(Either.left(Collections.singletonMap("prop1", new PropertyDefinition()))).when(propertyOperation) - .getAllTypePropertiesFromAllDerivedFrom(Mockito.anyString(), Mockito.any(), Mockito.any()); + .getAllTypePropertiesFromAllDerivedFrom(Mockito.anyString(), Mockito.any(), Mockito.any()); Mockito.doReturn(Either.left(new ArrayList<>(relationshipTypeDefinition.getProperties().values()))).when(propertyOperation) - .validatePropertiesUniqueness(Mockito.any(), Mockito.any()); + .validatePropertiesUniqueness(Mockito.any(), Mockito.any()); Mockito.doReturn(Either.left(relationshipTypeData)).when(janusGraphGenericDao) - .createNode(Mockito.any(), Mockito.eq(RelationshipTypeData.class)); - + .createNode(Mockito.any(), Mockito.eq(RelationshipTypeData.class)); + Mockito.doReturn(Either.left(new HashMap())).when(propertyOperation) - .addPropertiesToElementType(Mockito.anyString(), Mockito.any(), Mockito.anyMap()); + .addPropertiesToElementType(Mockito.anyString(), Mockito.any(), Mockito.anyMap()); Mockito.doReturn(Either.left(relationshipTypeDefinition)) - .when(relationshipTypeOperation).getRelationshipTypeByUid(Mockito.anyString()); + .when(relationshipTypeOperation).getRelationshipTypeByUid(Mockito.anyString()); Mockito.doReturn(Either.left(new GraphRelation())) - .when(derivedFromOperation) - .addDerivedFromRelation(Mockito.anyString(), Mockito.anyString(), Mockito.any()); + .when(derivedFromOperation) + .addDerivedFromRelation(Mockito.anyString(), Mockito.anyString(), Mockito.any()); Mockito.doReturn(Either.left(relationshipTypeDefinition)) - .when(relationshipTypeOperation).getRelationshipType(Mockito.anyString(), Mockito.anyBoolean()); + .when(relationshipTypeOperation).getRelationshipType(Mockito.anyString(), Mockito.anyBoolean()); Mockito.doReturn(Either.left(Collections.singletonMap("derivedFromProp1", new PropertyDefinition()))).when(propertyOperation) - .findPropertiesOfNode(Mockito.any(), Mockito.anyString()); - + .findPropertiesOfNode(Mockito.any(), Mockito.anyString()); + Mockito.doReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)).when(janusGraphGenericDao) - .getChild(Mockito.any(), Mockito.anyString(), Mockito.any(), Mockito.any(), Mockito.eq(RelationshipTypeData.class)); - + .getChild(Mockito.any(), Mockito.anyString(), Mockito.any(), Mockito.any(), Mockito.eq(RelationshipTypeData.class)); + Mockito.doReturn(Either.left(new RelationshipTypeData(relationshipTypeDefinition))) - .when(janusGraphGenericDao).getNode(Mockito.anyString(), Mockito.any(), Mockito.eq(RelationshipTypeData.class), Mockito.any()); - - + .when(janusGraphGenericDao).getNode(Mockito.anyString(), Mockito.any(), Mockito.eq(RelationshipTypeData.class), Mockito.any()); + ModelData modelData = new ModelData("modelA", "modelA", ModelTypeEnum.NORMATIVE); ImmutablePair pair = new ImmutablePair<>(modelData, new GraphEdge()); Mockito.doReturn(Either.left(pair)) - .when(janusGraphGenericDao).getParentNode("uid", relationshipInstDataDefinition1.getUniqueId(), GraphEdgeLabels.MODEL_ELEMENT, NodeTypeEnum.Model, ModelData.class); - + .when(janusGraphGenericDao) + .getParentNode("uid", relationshipInstDataDefinition1.getUniqueId(), GraphEdgeLabels.MODEL_ELEMENT, NodeTypeEnum.Model, ModelData.class); + Either either = - relationshipTypeOperation.addRelationshipType(relationshipTypeDefinition, true); + relationshipTypeOperation.addRelationshipType(relationshipTypeDefinition, true); assertTrue(either.isLeft()); } - + @Test public void testAddRelationshipTypeToModel() { - + final String relationshipName = "tosca.relationships.MyRelationship"; final String derivedFromRelationshipName = "tosca.relationships.Root"; final String modelName = "modelA"; @@ -421,66 +413,72 @@ public class RelationshipTypeOperationTest extends ModelTestBase { relationshipTypeDefinition.setType(relationshipName); relationshipTypeDefinition.setModel(modelName); relationshipTypeDefinition.setDerivedFrom(derivedFromRelationshipName); - + RelationshipTypeData derivedFromRelationshipTypeData = new RelationshipTypeData(); RelationshipInstDataDefinition dervideFromRelationshipInstDataDefinition = new RelationshipInstDataDefinition(); dervideFromRelationshipInstDataDefinition.setUniqueId("modelA.tosca.relationships.Root"); dervideFromRelationshipInstDataDefinition.setType("tosca.relationships.Root"); derivedFromRelationshipTypeData.setRelationshipTypeDataDefinition(dervideFromRelationshipInstDataDefinition); - + Mockito.doReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)) - .when(janusGraphGenericDao).getNode("uid", relationshipTypeDefinition.getUniqueId(), RelationshipTypeData.class); - + .when(janusGraphGenericDao).getNode("uid", relationshipTypeDefinition.getUniqueId(), RelationshipTypeData.class); + Mockito.doReturn(Either.left(derivedFromRelationshipTypeData)) - .when(janusGraphGenericDao).getNode("type", "tosca.relationships.Root", RelationshipTypeData.class, "modelA"); - + .when(janusGraphGenericDao).getNode("type", "tosca.relationships.Root", RelationshipTypeData.class, "modelA"); + Mockito.doReturn(Either.left(Collections.singletonMap("prop1", new PropertyDefinition()))).when(propertyOperation) - .getAllTypePropertiesFromAllDerivedFrom(modelName + DOT + derivedFromRelationshipName, NodeTypeEnum.RelationshipType, RelationshipTypeData.class); - + .getAllTypePropertiesFromAllDerivedFrom(modelName + DOT + derivedFromRelationshipName, NodeTypeEnum.RelationshipType, + RelationshipTypeData.class); + Mockito.doReturn(Either.left(new ArrayList<>(relationshipTypeDefinition.getProperties().values()))).when(propertyOperation) - .validatePropertiesUniqueness(Mockito.any(), Mockito.any()); - + .validatePropertiesUniqueness(Mockito.any(), Mockito.any()); + Mockito.doReturn(Either.left(new RelationshipTypeData(relationshipTypeDefinition))).when(janusGraphGenericDao) - .createNode(Mockito.any(), Mockito.eq(RelationshipTypeData.class)); - + .createNode(Mockito.any(), Mockito.eq(RelationshipTypeData.class)); + Mockito.doReturn(Either.left(new HashMap())).when(propertyOperation) - .addPropertiesToElementType(Mockito.anyString(), Mockito.any(), Mockito.anyMap()); - + .addPropertiesToElementType(Mockito.anyString(), Mockito.any(), Mockito.anyMap()); + Mockito.doReturn(Either.left(new GraphRelation())).when(janusGraphGenericDao) - .createRelation(Mockito.any(), Mockito.any(), Mockito.eq(GraphEdgeLabels.MODEL_ELEMENT), Mockito.any()); - + .createRelation(Mockito.any(), Mockito.any(), Mockito.eq(GraphEdgeLabels.MODEL_ELEMENT), Mockito.any()); + Mockito.doReturn(Either.left(Collections.singletonMap("derivedFromProp1", new PropertyDefinition()))).when(propertyOperation) - .findPropertiesOfNode(NodeTypeEnum.RelationshipType, derivedFromRelationshipTypeData.getUniqueId()); - + .findPropertiesOfNode(NodeTypeEnum.RelationshipType, derivedFromRelationshipTypeData.getUniqueId()); + Mockito.doReturn(Either.left(Collections.singletonMap("prop1", new PropertyDefinition()))).when(propertyOperation) - .findPropertiesOfNode(NodeTypeEnum.RelationshipType, relationshipTypeDefinition.getUniqueId()); - + .findPropertiesOfNode(NodeTypeEnum.RelationshipType, relationshipTypeDefinition.getUniqueId()); + Mockito.doReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)).when(janusGraphGenericDao) - .getChild("uid", derivedFromRelationshipTypeData.getUniqueId(), GraphEdgeLabels.DERIVED_FROM, NodeTypeEnum.RelationshipType, RelationshipTypeData.class); - + .getChild("uid", derivedFromRelationshipTypeData.getUniqueId(), GraphEdgeLabels.DERIVED_FROM, NodeTypeEnum.RelationshipType, + RelationshipTypeData.class); + Mockito.doReturn(Either.left(new ImmutablePair(new RelationshipTypeData(relationshipTypeDefinition), null))).when(janusGraphGenericDao) - .getChild("uid", relationshipTypeDefinition.getUniqueId(), GraphEdgeLabels.DERIVED_FROM, NodeTypeEnum.RelationshipType, RelationshipTypeData.class); - - + .getChild("uid", relationshipTypeDefinition.getUniqueId(), GraphEdgeLabels.DERIVED_FROM, NodeTypeEnum.RelationshipType, + RelationshipTypeData.class); + Mockito.doReturn(Either.left(new GraphRelation())).when(derivedFromOperation) - .addDerivedFromRelation(relationshipTypeDefinition.getUniqueId(), derivedFromRelationshipTypeData.getUniqueId(), NodeTypeEnum.RelationshipType); - + .addDerivedFromRelation(relationshipTypeDefinition.getUniqueId(), derivedFromRelationshipTypeData.getUniqueId(), + NodeTypeEnum.RelationshipType); + ModelData modelData = new ModelData("modelA", "modelA", ModelTypeEnum.NORMATIVE); ImmutablePair pair = new ImmutablePair<>(modelData, new GraphEdge()); Mockito.doReturn(Either.left(pair)) - .when(janusGraphGenericDao).getParentNode("uid", dervideFromRelationshipInstDataDefinition.getUniqueId(), GraphEdgeLabels.MODEL_ELEMENT, NodeTypeEnum.Model, ModelData.class); - + .when(janusGraphGenericDao) + .getParentNode("uid", dervideFromRelationshipInstDataDefinition.getUniqueId(), GraphEdgeLabels.MODEL_ELEMENT, NodeTypeEnum.Model, + ModelData.class); + Mockito.doReturn(Either.left(pair)) - .when(janusGraphGenericDao).getParentNode("uid", relationshipTypeDefinition.getUniqueId(), GraphEdgeLabels.MODEL_ELEMENT, NodeTypeEnum.Model, ModelData.class); - + .when(janusGraphGenericDao) + .getParentNode("uid", relationshipTypeDefinition.getUniqueId(), GraphEdgeLabels.MODEL_ELEMENT, NodeTypeEnum.Model, ModelData.class); + Mockito.doReturn(Either.left(new RelationshipTypeData(relationshipTypeDefinition))) - .when(janusGraphGenericDao).getNode("uid", relationshipTypeDefinition.getUniqueId(), RelationshipTypeData.class); - + .when(janusGraphGenericDao).getNode("uid", relationshipTypeDefinition.getUniqueId(), RelationshipTypeData.class); + Mockito.doReturn(Either.left(new RelationshipTypeData(relationshipTypeDefinition))) - .when(janusGraphGenericDao).getNode("type", relationshipTypeDefinition.getUniqueId(), RelationshipTypeData.class, "modelA"); - + .when(janusGraphGenericDao).getNode("type", relationshipTypeDefinition.getUniqueId(), RelationshipTypeData.class, "modelA"); + Either either = - relationshipTypeOperation.addRelationshipType(relationshipTypeDefinition, true); + relationshipTypeOperation.addRelationshipType(relationshipTypeDefinition, true); assertTrue(either.isLeft()); } @@ -488,10 +486,10 @@ public class RelationshipTypeOperationTest extends ModelTestBase { @Test public void testGetRelationshipTypeNotConnected() { Mockito.doReturn(Either.right(JanusGraphOperationStatus.NOT_CONNECTED)) - .when(relationshipTypeOperation).getRelationshipTypeByUid(Mockito.anyString()); + .when(relationshipTypeOperation).getRelationshipTypeByUid(Mockito.anyString()); Either either = - relationshipTypeOperation.getRelationshipType(Mockito.anyString(), Mockito.anyBoolean()); + relationshipTypeOperation.getRelationshipType(Mockito.anyString(), Mockito.anyBoolean()); assertTrue(either.isRight()); } @@ -499,10 +497,10 @@ public class RelationshipTypeOperationTest extends ModelTestBase { @Test public void testGetRelationshipTypeSuccess() { Mockito.doReturn(Either.left(relationshipTypeDefinition)) - .when(relationshipTypeOperation).getRelationshipTypeByUid(Mockito.anyString()); + .when(relationshipTypeOperation).getRelationshipTypeByUid(Mockito.anyString()); Either either = - relationshipTypeOperation.getRelationshipType(Mockito.anyString(), Mockito.anyBoolean()); + relationshipTypeOperation.getRelationshipType(Mockito.anyString(), Mockito.anyBoolean()); assertTrue(either.isLeft()); } @@ -517,42 +515,43 @@ public class RelationshipTypeOperationTest extends ModelTestBase { newRelationshipTypeDefinition.setProperties(createPropertyData("prop1")); Mockito.doReturn(Either.left(new RelationshipTypeData(newRelationshipTypeDefinition))).when( - janusGraphGenericDao) - .updateNode(Mockito.any(), Mockito.eq(RelationshipTypeData.class)); + janusGraphGenericDao) + .updateNode(Mockito.any(), Mockito.eq(RelationshipTypeData.class)); Mockito.doReturn(Either.left(newRelationshipTypeDefinition.getProperties())) - .when(propertyOperation).deletePropertiesAssociatedToNode(Mockito.any(), Mockito.anyString()); + .when(propertyOperation).deletePropertiesAssociatedToNode(Mockito.any(), Mockito.anyString()); Mockito.doReturn(Either.left(newRelationshipTypeDefinition.getProperties())) - .when(propertyOperation).addPropertiesToElementType(Mockito.anyString(), Mockito.any(), Mockito.anyMap()); + .when(propertyOperation).addPropertiesToElementType(Mockito.anyString(), Mockito.any(), Mockito.anyMap()); Mockito.doReturn(Either.left(newRelationshipTypeDefinition)).when(relationshipTypeOperation) - .getRelationshipTypeByUid(Mockito.anyString()); + .getRelationshipTypeByUid(Mockito.anyString()); Mockito.doReturn(StorageOperationStatus.OK).when(derivedFromOperation) - .removeDerivedFromRelation(Mockito.anyString(), Mockito.anyString(), Mockito.any()); + .removeDerivedFromRelation(Mockito.anyString(), Mockito.anyString(), Mockito.any()); Mockito.doReturn(Either.left(new GraphRelation())) - .when(derivedFromOperation) - .addDerivedFromRelation(Mockito.anyString(), Mockito.anyString(), Mockito.any()); - + .when(derivedFromOperation) + .addDerivedFromRelation(Mockito.anyString(), Mockito.anyString(), Mockito.any()); + Mockito.doReturn(Either.left(new RelationshipTypeData(relationshipTypeDefinition))) - .when(janusGraphGenericDao).getNode(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()); - + .when(janusGraphGenericDao).getNode(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()); + Mockito.doReturn(Either.left(Collections.singletonMap("derivedFromProp1", new PropertyDefinition()))).when(propertyOperation) - .findPropertiesOfNode(Mockito.any(), Mockito.anyString()); - + .findPropertiesOfNode(Mockito.any(), Mockito.anyString()); + Mockito.doReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)).when(janusGraphGenericDao) - .getChild(Mockito.any(), Mockito.anyString(), Mockito.any(), Mockito.any(), Mockito.eq(RelationshipTypeData.class)); - + .getChild(Mockito.any(), Mockito.anyString(), Mockito.any(), Mockito.any(), Mockito.eq(RelationshipTypeData.class)); + ModelData modelData = new ModelData("modelA", "modelA", ModelTypeEnum.NORMATIVE); ImmutablePair pair = new ImmutablePair<>(modelData, new GraphEdge()); Mockito.doReturn(Either.left(pair)) - .when(janusGraphGenericDao).getParentNode("uid", newRelationshipTypeDefinition.getUniqueId(), GraphEdgeLabels.MODEL_ELEMENT, NodeTypeEnum.Model, ModelData.class); + .when(janusGraphGenericDao) + .getParentNode("uid", newRelationshipTypeDefinition.getUniqueId(), GraphEdgeLabels.MODEL_ELEMENT, NodeTypeEnum.Model, ModelData.class); Either either = - relationshipTypeOperation.updateRelationshipType(relationshipTypeDefinition, - newRelationshipTypeDefinition, false); + relationshipTypeOperation.updateRelationshipType(relationshipTypeDefinition, + newRelationshipTypeDefinition, false); assertTrue(either.isLeft()); } @@ -562,29 +561,30 @@ public class RelationshipTypeOperationTest extends ModelTestBase { RelationshipTypeData relationshipTypeData = new RelationshipTypeData(relationshipTypeDefinition); Mockito.doReturn(Either.left(relationshipTypeData)).when(janusGraphGenericDao) - .getNode(Mockito.anyString(), Mockito.any(), Mockito.eq(RelationshipTypeData.class)); + .getNode(Mockito.anyString(), Mockito.any(), Mockito.eq(RelationshipTypeData.class)); Mockito.doReturn(Either.left(relationshipTypeDefinition.getProperties())) - .when(propertyOperation).findPropertiesOfNode(Mockito.any(), Mockito.anyString()); + .when(propertyOperation).findPropertiesOfNode(Mockito.any(), Mockito.anyString()); RelationshipTypeDefinition childRelationshipTypeDefinition = new RelationshipTypeDefinition(); childRelationshipTypeDefinition.setType("tosca.relationships.ContainerChild"); Mockito.doReturn(Either.left(new ImmutablePair(new RelationshipTypeData(childRelationshipTypeDefinition), null))).when( - janusGraphGenericDao) - .getChild(Mockito.anyString(), Mockito.anyString(), Mockito.any(), Mockito.any(), - Mockito.eq(RelationshipTypeData.class)); - + janusGraphGenericDao) + .getChild(Mockito.anyString(), Mockito.anyString(), Mockito.any(), Mockito.any(), + Mockito.eq(RelationshipTypeData.class)); + ModelData modelData = new ModelData("modelA", "modelA", ModelTypeEnum.NORMATIVE); ImmutablePair pair = new ImmutablePair<>(modelData, new GraphEdge()); Mockito.doReturn(Either.left(pair)) - .when(janusGraphGenericDao).getParentNode("uid", relationshipTypeDefinition.getUniqueId(), GraphEdgeLabels.MODEL_ELEMENT, NodeTypeEnum.Model, ModelData.class); + .when(janusGraphGenericDao) + .getParentNode("uid", relationshipTypeDefinition.getUniqueId(), GraphEdgeLabels.MODEL_ELEMENT, NodeTypeEnum.Model, ModelData.class); Either either = - relationshipTypeOperation.getRelationshipTypeByUid("tosca.relationships.Container1"); + relationshipTypeOperation.getRelationshipTypeByUid("tosca.relationships.Container1"); assertTrue(either.isLeft() - && "tosca.relationships.ContainerChild".equals(either.left().value().getDerivedFrom())); + && "tosca.relationships.ContainerChild".equals(either.left().value().getDerivedFrom())); } private Map createPropertyData(String value) { diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaElementLifecycleOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaElementLifecycleOperationTest.java index 4817f7a1c4..abb5a1888b 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaElementLifecycleOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaElementLifecycleOperationTest.java @@ -37,13 +37,12 @@ import java.util.Map; import org.apache.tinkerpop.gremlin.structure.io.IoCore; import org.janusgraph.core.JanusGraph; import org.janusgraph.core.JanusGraphVertex; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.junit.rules.TestName; -import org.junit.runner.RunWith; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; @@ -74,44 +73,36 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaElementLifecycl import org.openecomp.sdc.be.model.jsonjanusgraph.utils.GraphTestUtils; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.common.util.ValidationUtils; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration("classpath:application-context-test.xml") +@SpringJUnitConfig(locations = "classpath:application-context-test.xml") public class ToscaElementLifecycleOperationTest extends ModelTestBase { + @Rule + public TestName name = new TestName(); @javax.annotation.Resource protected JanusGraphDao janusGraphDao; - + String categoryName = "category"; + String subcategory = "mycategory"; + String outputDirectory = "C:\\Output"; @javax.annotation.Resource private NodeTypeOperation nodeTypeOperation; - @javax.annotation.Resource private TopologyTemplateOperation topologyTemplateOperation; - @javax.annotation.Resource private ToscaElementLifecycleOperation lifecycleOperation; - - String categoryName = "category"; - String subcategory = "mycategory"; - String outputDirectory = "C:\\Output"; - - @Rule - public TestName name = new TestName(); - - @BeforeClass - public static void initLifecycleOperation() { - ModelTestBase.init(); - } - private GraphVertex ownerVertex; private GraphVertex modifierVertex; private GraphVertex vfVertex; private GraphVertex serviceVertex; private GraphVertex rootVertex; - @Before + @BeforeAll + public static void initLifecycleOperation() { + ModelTestBase.init(); + } + + @BeforeEach public void setupBefore() { clearGraph(); createUsers(); @@ -125,8 +116,10 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase { @Test public void lifecycleTest() { - Either res = lifecycleOperation.checkinToscaELement(LifecycleStateEnum.findState((String) vfVertex.getMetadataProperty(GraphPropertyEnum.STATE)), vfVertex.getUniqueId(), modifierVertex.getUniqueId(), - ownerVertex.getUniqueId()); + Either res = lifecycleOperation.checkinToscaELement( + LifecycleStateEnum.findState((String) vfVertex.getMetadataProperty(GraphPropertyEnum.STATE)), vfVertex.getUniqueId(), + modifierVertex.getUniqueId(), + ownerVertex.getUniqueId()); StorageOperationStatus status; assertTrue(res.isLeft()); @@ -147,7 +140,8 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase { prop55.setName("prop55"); prop55.setDefaultValue("def55"); - status = nodeTypeOperation.addToscaDataToToscaElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop55, JsonPresentationFields.NAME); + status = nodeTypeOperation.addToscaDataToToscaElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop55, + JsonPresentationFields.NAME); assertSame(status, StorageOperationStatus.OK); CapabilityDataDefinition cap1 = new CapabilityDataDefinition(); @@ -155,10 +149,12 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase { cap1.setDescription("create"); cap1.setUniqueId(UniqueIdBuilder.buildCapabilityUid(id, "cap1")); - status = nodeTypeOperation.addToscaDataToToscaElement(id, EdgeLabelEnum.CAPABILITIES, VertexTypeEnum.CAPABILITIES, cap1, JsonPresentationFields.NAME); + status = nodeTypeOperation.addToscaDataToToscaElement(id, EdgeLabelEnum.CAPABILITIES, VertexTypeEnum.CAPABILITIES, cap1, + JsonPresentationFields.NAME); assertSame(status, StorageOperationStatus.OK); - res = lifecycleOperation.checkinToscaELement(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, id, ownerVertex.getUniqueId(), ownerVertex.getUniqueId()); + res = lifecycleOperation.checkinToscaELement(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, id, ownerVertex.getUniqueId(), + ownerVertex.getUniqueId()); assertTrue(res.isLeft()); id = res.left().value().getUniqueId(); @@ -167,19 +163,22 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase { id = res.left().value().getUniqueId(); prop55.setDefaultValue("AAAAAAAA"); - status = nodeTypeOperation.updateToscaDataOfToscaElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop55, JsonPresentationFields.NAME); + status = nodeTypeOperation.updateToscaDataOfToscaElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop55, + JsonPresentationFields.NAME); assertSame(status, StorageOperationStatus.OK); cap1.setDescription("update"); - status = nodeTypeOperation.updateToscaDataOfToscaElement(id, EdgeLabelEnum.CAPABILITIES, VertexTypeEnum.CAPABILITIES, cap1, JsonPresentationFields.NAME); + status = nodeTypeOperation.updateToscaDataOfToscaElement(id, EdgeLabelEnum.CAPABILITIES, VertexTypeEnum.CAPABILITIES, cap1, + JsonPresentationFields.NAME); assertSame(status, StorageOperationStatus.OK); PropertyDataDefinition prop66 = new PropertyDataDefinition(); prop66.setName("prop66"); prop66.setDefaultValue("def66"); - status = nodeTypeOperation.addToscaDataToToscaElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop66, JsonPresentationFields.NAME); + status = nodeTypeOperation.addToscaDataToToscaElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop66, + JsonPresentationFields.NAME); assertSame(status, StorageOperationStatus.OK); res = lifecycleOperation.certifyToscaElement(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId()); @@ -198,10 +197,12 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase { prop77.setName("prop77"); prop77.setDefaultValue("def77"); - status = nodeTypeOperation.addToscaDataToToscaElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop77, JsonPresentationFields.NAME); + status = nodeTypeOperation.addToscaDataToToscaElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop77, + JsonPresentationFields.NAME); assertSame(status, StorageOperationStatus.OK); - res = lifecycleOperation.checkinToscaELement(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, id, ownerVertex.getUniqueId(), ownerVertex.getUniqueId()); + res = lifecycleOperation.checkinToscaELement(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, id, ownerVertex.getUniqueId(), + ownerVertex.getUniqueId()); assertTrue(res.isLeft()); id = res.left().value().getUniqueId(); @@ -213,7 +214,8 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase { prop88.setName("prop88"); prop88.setDefaultValue("def88"); - status = nodeTypeOperation.addToscaDataToToscaElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop88, JsonPresentationFields.NAME); + status = nodeTypeOperation.addToscaDataToToscaElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop88, + JsonPresentationFields.NAME); assertSame(status, StorageOperationStatus.OK); res = lifecycleOperation.certifyToscaElement(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId()); @@ -231,10 +233,12 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase { prop99.setName("prop99"); prop99.setDefaultValue("def99"); - status = nodeTypeOperation.addToscaDataToToscaElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop99, JsonPresentationFields.NAME); + status = nodeTypeOperation.addToscaDataToToscaElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop99, + JsonPresentationFields.NAME); assertSame(status, StorageOperationStatus.OK); - status = nodeTypeOperation.deleteToscaDataElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, "prop99", JsonPresentationFields.NAME); + status = nodeTypeOperation.deleteToscaDataElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, "prop99", + JsonPresentationFields.NAME); assertSame(status, StorageOperationStatus.OK); verifyInCatalogData(4, null); @@ -242,8 +246,9 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase { @Test public void serviceConformanceLevelTest() { - Either res = lifecycleOperation.checkinToscaELement(LifecycleStateEnum.findState((String) serviceVertex.getMetadataProperty(GraphPropertyEnum.STATE)), serviceVertex.getUniqueId(), - modifierVertex.getUniqueId(), ownerVertex.getUniqueId()); + Either res = lifecycleOperation.checkinToscaELement( + LifecycleStateEnum.findState((String) serviceVertex.getMetadataProperty(GraphPropertyEnum.STATE)), serviceVertex.getUniqueId(), + modifierVertex.getUniqueId(), ownerVertex.getUniqueId()); assertTrue(res.isLeft()); String id = res.left().value().getUniqueId(); @@ -277,22 +282,25 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase { expectedIds.add(vertex4.getUniqueId()); verifyInCatalogData(4, expectedIds); - lifecycleOperation.checkinToscaELement(LifecycleStateEnum.findState((String) vertex4.getMetadataProperty(GraphPropertyEnum.STATE)), vertex4.getUniqueId(), modifierVertex.getUniqueId(), ownerVertex.getUniqueId()); - Either certifyToscaElement = lifecycleOperation.certifyToscaElement(vertex4.getUniqueId(), modifierVertex.getUniqueId(), ownerVertex.getUniqueId()); + lifecycleOperation.checkinToscaELement(LifecycleStateEnum.findState((String) vertex4.getMetadataProperty(GraphPropertyEnum.STATE)), + vertex4.getUniqueId(), modifierVertex.getUniqueId(), ownerVertex.getUniqueId()); + Either certifyToscaElement = lifecycleOperation.certifyToscaElement(vertex4.getUniqueId(), + modifierVertex.getUniqueId(), ownerVertex.getUniqueId()); assertTrue(certifyToscaElement.isLeft()); expectedIds.remove(vertex4.getUniqueId()); String certifiedId = certifyToscaElement.left().value().getUniqueId(); expectedIds.add(certifiedId); verifyInCatalogData(4, expectedIds); - Either res = lifecycleOperation.checkoutToscaElement(certifiedId, modifierVertex.getUniqueId(), ownerVertex.getUniqueId()); + Either res = lifecycleOperation.checkoutToscaElement(certifiedId, modifierVertex.getUniqueId(), + ownerVertex.getUniqueId()); assertTrue(certifyToscaElement.isLeft()); expectedIds.add(res.left().value().getUniqueId()); verifyInCatalogData(5, expectedIds); } @Test - public void testGetToscaElOwner_Fail(){ + public void testGetToscaElOwner_Fail() { Either result; String toscaEleId = "toscaElementId"; janusGraphDao.getVertexById(toscaEleId, JsonParseFlagEnum.NoParse); @@ -453,21 +461,24 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase { prop22.setDefaultValue("def22"); addProperties.add(prop22); - StorageOperationStatus status = nodeTypeOperation.addToscaDataToToscaElement(vfVertex, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, addProperties, JsonPresentationFields.NAME); + StorageOperationStatus status = nodeTypeOperation.addToscaDataToToscaElement(vfVertex, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, + addProperties, JsonPresentationFields.NAME); assertSame(status, StorageOperationStatus.OK); PropertyDataDefinition prop33 = new PropertyDataDefinition(); prop33.setName("prop33"); prop33.setDefaultValue("def33"); - status = nodeTypeOperation.addToscaDataToToscaElement(vfVertex, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop33, JsonPresentationFields.NAME); + status = nodeTypeOperation.addToscaDataToToscaElement(vfVertex, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop33, + JsonPresentationFields.NAME); assertSame(status, StorageOperationStatus.OK); PropertyDataDefinition prop44 = new PropertyDataDefinition(); prop44.setName("prop44"); prop44.setDefaultValue("def44"); - status = nodeTypeOperation.addToscaDataToToscaElement(vfVertex.getUniqueId(), EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop44, JsonPresentationFields.NAME); + status = nodeTypeOperation.addToscaDataToToscaElement(vfVertex.getUniqueId(), EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop44, + JsonPresentationFields.NAME); assertSame(status, StorageOperationStatus.OK); PropertyDataDefinition capProp = new PropertyDataDefinition(); @@ -480,14 +491,16 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase { Map capProps = new HashMap(); capProps.put("capName", dataToCreate); - Either res = nodeTypeOperation.associateElementToData(vfVertex, VertexTypeEnum.CAPABILITIES_PROPERTIES, EdgeLabelEnum.CAPABILITIES_PROPERTIES, capProps); + Either res = nodeTypeOperation.associateElementToData(vfVertex, VertexTypeEnum.CAPABILITIES_PROPERTIES, + EdgeLabelEnum.CAPABILITIES_PROPERTIES, capProps); // exportGraphMl(janusGraphDao.getGraph().left().value()); List pathKeys = new ArrayList<>(); pathKeys.add("capName"); capProp.setDefaultValue("BBBB"); - status = nodeTypeOperation.updateToscaDataDeepElementOfToscaElement(vfVertex, EdgeLabelEnum.CAPABILITIES_PROPERTIES, VertexTypeEnum.CAPABILITIES_PROPERTIES, capProp, pathKeys, JsonPresentationFields.NAME); + status = nodeTypeOperation.updateToscaDataDeepElementOfToscaElement(vfVertex, EdgeLabelEnum.CAPABILITIES_PROPERTIES, + VertexTypeEnum.CAPABILITIES_PROPERTIES, capProp, pathKeys, JsonPresentationFields.NAME); return vf; } @@ -587,7 +600,7 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase { public void verifyInCatalogData(int expected, List expectedIds) { - Either, StorageOperationStatus> highestResourcesRes = topologyTemplateOperation.getElementCatalogData(true, null); + Either, StorageOperationStatus> highestResourcesRes = topologyTemplateOperation.getElementCatalogData(true, null); assertTrue(highestResourcesRes.isLeft()); List highestResources = highestResourcesRes.left().value(); // calculate expected count value @@ -597,7 +610,7 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase { } } - @After + @AfterEach public void teardown() { clearGraph(); } diff --git a/onboarding/pom.xml b/onboarding/pom.xml index cf8ca1abeb..b820980699 100644 --- a/onboarding/pom.xml +++ b/onboarding/pom.xml @@ -14,331 +14,332 @@ ~ limitations under the License. --> - + - 4.0.0 + sdc-onboarding - sdc-onboarding - pom + + + + maven-jar-plugin + org.apache.maven.plugins + ${mvn.jar.version} + + + maven-clean-plugin + org.apache.maven.plugins + ${mvn.clean.version} + + + maven-surefire-plugin + + + ${project.basedir}/src/test/resources + + + false + + ${project.basedir}/configuration + src/test/resources/logback-test.xml + + + + org.apache.maven.plugins + + + maven-install-plugin + org.apache.maven.plugins + ${mvn.install.version} + + + maven-resources-plugin + org.apache.maven.plugins + ${mvn.resource.version} + + + + + src/test/resources + + **/* + + + + + + + + lombok + org.projectlombok + provided + ${lombok.version} + + + spring-expression + org.springframework + ${spring.framework.version} + + + spring-context + + + spring-expression + org.springframework + + + spring-core + org.springframework + + + org.springframework + ${spring.framework.version} + + + spring-webmvc + + + spring-expression + org.springframework + + + spring-core + org.springframework + + + spring-web + org.springframework + + + org.springframework + ${spring.framework.version} + + + commons-text + org.apache.commons + ${apache-commons-text.version} + + + jcommander + com.beust + ${jcommander.version} + + + httpasyncclient + org.apache.httpcomponents + ${httpasyncclient.version} + + + jaxb-impl + com.sun.xml.bind + ${com.sun.xml.version} + + + bsh + org.beanshell + ${bsh.version} + + + commons-digester + commons-digester + ${commons.digester.version} + + + classmate + com.fasterxml + ${classmate.version} + + + slf4j-api + org.slf4j + ${slf4j.version} + + + groovy-all-minimal + org.codehaus.groovy + ${groovy.minimal.version} + + + janino + org.codehaus.janino + provided + ${janino.version} + + + jackson-annotations + com.fasterxml.jackson.core + ${jackson.annotations.version} + + + jackson-core + com.fasterxml.jackson.core + ${jackson.version} + + + aspectjrt + org.aspectj + ${aspectjrt.version} + + + javax.servlet-api + javax.servlet + provided + ${servlet-api.version} + + + commons-beanutils + commons-beanutils + ${commons-beanutils} + + + annotations + com.google.code.findbugs + 3.0.1u2 + + + cglib-nodep + cglib + ${cglib.nodep.version} + + + logback-classic + ch.qos.logback + ${logback.version} + + + logback-core + ch.qos.logback + ${logback.version} + + + jackson-databind + + + jackson-core + com.fasterxml.jackson.core + + + com.fasterxml.jackson.core + ${jackson.version} + + + jackson-dataformat-yaml + com.fasterxml.jackson.dataformat + ${jackson.version} + + + commons-codec + commons-codec + ${commons.codec.version} + + + cassandra-driver-core + com.datastax.cassandra + ${datastax.cassandra.version} + + + cassandra-driver-mapping + com.datastax.cassandra + ${datastax.cassandra.version} + + + javax.ws.rs-api + javax.ws.rs + ${ws.rs.version} + + + gson + com.google.code.gson + ${gson.version} + + + commons-io + commons-io + ${commons.io.version} + + + commons-lang3 + org.apache.commons + ${commons.lang3.version} + + + swagger-annotations + io.swagger.core.v3 + ${swagger.version} + + + wiremock + com.github.tomakehurst + ${wire-mock.version} + + + - - org.openecomp.sdc - sdc-main - 1.10.0-SNAPSHOT - + 4.0.0 - - ../common - ../openecomp-be - ../openecomp-ui - + + ../common + ../openecomp-be + ../openecomp-ui + - + pom - true - UTF-8 + + sdc-main + org.openecomp.sdc + 1.10.0-SNAPSHOT + - - 2.1 - 2.5 - 3.1.0 - 2.4 - 2.4 - 2.4 - 2.1.1 + - - ${aspectj.version} - 2.0b6 - 3.2.4 - 1.3.3 - ${commons-codec} - 2.1 - ${lang3.version} - 3.8.0 - 1.5.8 - ${httpclient.version} - 4.4.1 - 4.1.2 - 2.3.3 - 2.2.6 - 3.0.1-b06 - 1 - ${jackson.version} - ${jackson.version} - 1.58 - 1.19.1 - 1.18.1 - 1.5.1 - ${slf4j-api.version} - ${spring.version} - ${swagger-core-mvn-plugin.version} - 4.4.1 - 1.0.2 - 1.0.2 - 1.0.2 - 1.0.0 - 1.0.3 - ${project.version} - + ${aspectj.version} + 2.0b6 - - - - org.projectlombok - lombok - ${lombok.version} - provided - - - org.springframework - spring-expression - ${spring.framework.version} - - - org.springframework - spring-context - ${spring.framework.version} - - - org.springframework - spring-expression - - - org.springframework - spring-core - - - - - org.springframework - spring-webmvc - ${spring.framework.version} - - - org.springframework - spring-expression - - - org.springframework - spring-core - - - org.springframework - spring-web - - - - - org.apache.commons - commons-text - ${apache-commons-text.version} - - - com.beust - jcommander - ${jcommander.version} - - - org.apache.httpcomponents - httpasyncclient - ${httpasyncclient.version} - - - com.sun.xml.bind - jaxb-impl - ${com.sun.xml.version} - - - org.beanshell - bsh - ${bsh.version} - - - commons-digester - commons-digester - ${commons.digester.version} - - - com.fasterxml - classmate - ${classmate.version} - - - org.slf4j - slf4j-api - ${slf4j.version} - - - org.codehaus.groovy - groovy-all-minimal - ${groovy.minimal.version} - - - org.codehaus.janino - janino - ${janino.version} - provided - - - com.fasterxml.jackson.core - jackson-annotations - ${jackson.annotations.version} - - - com.fasterxml.jackson.core - jackson-core - ${jackson.version} - - - org.aspectj - aspectjrt - ${aspectjrt.version} - - - javax.servlet - javax.servlet-api - ${servlet-api.version} - provided - - - commons-beanutils - commons-beanutils - ${commons-beanutils} - - - com.google.code.findbugs - annotations - 3.0.1u2 - - - cglib - cglib-nodep - ${cglib.nodep.version} - - - ch.qos.logback - logback-classic - ${logback.version} - - - ch.qos.logback - logback-core - ${logback.version} - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-core - - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - ${jackson.version} - - - commons-codec - commons-codec - ${commons.codec.version} - - - com.datastax.cassandra - cassandra-driver-core - ${datastax.cassandra.version} - - - com.datastax.cassandra - cassandra-driver-mapping - ${datastax.cassandra.version} - - - javax.ws.rs - javax.ws.rs-api - ${ws.rs.version} - - - com.google.code.gson - gson - ${gson.version} - - - commons-io - commons-io - ${commons.io.version} - - - org.apache.commons - commons-lang3 - ${commons.lang3.version} - - - io.swagger.core.v3 - swagger-annotations - ${swagger.version} - - - com.github.tomakehurst - wiremock - ${wire-mock.version} - - - + + ${project.version} + 3.2.4 + 1.3.3 + 2.3.3 + ${commons-codec} + 2.1 + ${lang3.version} - - - - org.apache.maven.plugins - maven-jar-plugin - ${mvn.jar.version} - - - org.apache.maven.plugins - maven-clean-plugin - ${mvn.clean.version} - - - org.apache.maven.plugins - maven-surefire-plugin - - false - - ${project.basedir}/src/test/resources - - - - src/test/resources/logback-test.xml - - ${project.basedir}/configuration - - - - - org.apache.maven.plugins - maven-install-plugin - ${mvn.install.version} - - - org.apache.maven.plugins - maven-resources-plugin - ${mvn.resource.version} - - - - - src/test/resources - - **/* - - - - + + 3.8.0 + 1.5.8 + ${httpclient.version} + 4.4.1 + 4.1.2 + ${jackson.version} + ${jackson.version} + 3.0.1-b06 + 2.2.6 + 1 + ${servlet-api.version} + 1.58 + 1.19.1 + 1.18.1 + true + 2.1 + 2.5 + 2.4 + 2.4 + 2.4 + 3.1.0 + 2.1.1 + 1.5.1 + UTF-8 + ${slf4j-api.version} + ${spring.version} + ${swagger-core-mvn-plugin.version} + 4.4.1 + 1.0.2 + 1.0.3 + 1.0.0 + 1.0.2 + 1.0.2 + diff --git a/openecomp-be/backend/openecomp-sdc-security-util/pom.xml b/openecomp-be/backend/openecomp-sdc-security-util/pom.xml index 494b9aac57..0ee74c03fe 100644 --- a/openecomp-be/backend/openecomp-sdc-security-util/pom.xml +++ b/openecomp-be/backend/openecomp-sdc-security-util/pom.xml @@ -1,71 +1,71 @@ - - - backend - org.openecomp.sdc - 1.10.0-SNAPSHOT - - 4.0.0 + + openecomp-sdc-security-util + + + slf4j-api + org.slf4j + 1.7.25 + - openecomp-sdc-security-util + + commons-crypto + org.apache.commons + 1.0.0 + + + commons-lang3 + org.apache.commons + ${commons.lang3.version} + - - - org.slf4j - slf4j-api - 1.7.25 - + + functionaljava + org.functionaljava + ${functionaljava.version} + - - org.apache.commons - commons-crypto - 1.0.0 - + + jackson-core + com.fasterxml.jackson.core + ${jackson.version} + + + jackson-databind + + + jackson-core + com.fasterxml.jackson.core + + + com.fasterxml.jackson.core + ${jackson.version} + - - org.apache.commons - commons-lang3 - ${commons.lang3.version} - + + commons-codec + commons-codec + ${commons-codec} + - - org.functionaljava - functionaljava - ${functionaljava.version} - + + javax.servlet-api + javax.servlet + ${servlet-api.version} + - - com.fasterxml.jackson.core - jackson-core - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-core - - - + - - commons-codec - commons-codec - ${commons-codec} - + 4.0.0 - - javax.servlet - javax.servlet-api - ${javax.servlet.version} - - + + backend + org.openecomp.sdc + 1.10.0-SNAPSHOT + diff --git a/pom.xml b/pom.xml index 9a038bddc0..a430ae9b67 100644 --- a/pom.xml +++ b/pom.xml @@ -19,405 +19,111 @@ limitations under the License. Modifications copyright (c) 2018-2019 Nokia ================================================================================ --> - - 4.0.0 - - org.openecomp.sdc sdc-main - 1.10.0-SNAPSHOT - pom - sdc - - - org.onap.oparent - oparent - 3.2.0 - - - - - UTF-8 - yyyyMMdd'T'HHmmss'Z' - - ${project.version} - - 0.11 - 3.10 - 30.1-jre - 0.3.3 - 5.3.9 - 2.34 - 4.1.66.Final - 3.1.0 - 2.26.3 - 3.4.0 - 4.3.1.0 - 2.1.8 - 1.18.20 - 1.9.4 - 2.8.0 - 2.7 - 4.1.0 - 1.6.1 - 1.9 - 2.3.1 - 0.10.3 - 3.0.7 - 2.1.7 - 3.0.0 - 6.1.6.Final - - 4.1 - 2.1.1 - 2.0.1.Final - 4.0.1 - - 9.4.41.v20210516 - 3.4.4 - - 2.2.0.0 - 2.1.3 - - - 2.12.4 - ${jackson.version} - - 2.1.1 - false - - - 1.29 - 4.9 - 4.5.13 - 4.4.1 - 1.1 - - - 1.2.15 - - - - - 1.2.3 - 1.7.25 - 1.15 - 1.2 - 3.0.6 - 2.13.1 - - - 0.20.1 - 1.9.7 - ${aspectj.version} - 0.13.2 - - - - 1.6.4 - - 3.0.3 - - - 2.3.1 - - - 1.1 - - - 3.7.7 - ${mockito.version} - 1.35 - 1.7.1 - 5.7.2 - 3.16.0 - 7.4.0 - 6.8.1 - 0.11 - 2.2 - 1.3 - 2.22.2 - 2.4 - 1.6.0.1 - - - ${project.version} - ${project.basedir}/node/node - ${project.build.directory}/surefire-reports - - ${project.build.directory}/code-coverage/lcov.info - - - ${project.reporting.outputDirectory}/jacoco-ut/jacoco.xml - - ${project.build.sourceEncoding} - ${project.basedir} - pom.xml,src/test - - 3.8.0 - - nexus - nexus - - - https://nexus3.onap.org/repository/npm.public/npm/-/ - https://nexus.onap.org - /content/sites/site/org/openecomp/sdc/${project.version} - 176c31dfe190a - - 2.6.1.Final - - 2.9.9 - - - 1.6.0 - - 0.8.7 - - 4.5.1 - - - 1C - true - false - - 1.35 - 1.69 - - false - - - - - - com.google.guava - guava - ${guava.version} - - - - org.glassfish.jersey.ext - jersey-bean-validation - ${jersey-bom.version} - - - - org.glassfish.hk2.external - asm-all-repackaged - 2.4.0 - - - - org.assertj - assertj-core - ${assertj.version} - - - - org.jmockit - jmockit - ${jmockit.version} - - - - com.github.tomakehurst - wiremock-standalone - ${wire-mock.version} - - - - io.cucumber - cucumber-java - ${cucumber.version} - - - - io.cucumber - cucumber-junit - ${cucumber.version} - - - - org.apache.commons - commons-lang3 - ${lang3.version} - - - org.codehaus.groovy - groovy - ${groovy.version} - - - io.netty - netty-all - ${netty.version} - - - io.netty - netty-handler - ${netty.version} - - - io.swagger.core.v3 - swagger-maven-plugin - ${swagger-core-mvn-plugin.version} - - - - - - - - org.jacoco - org.jacoco.agent - runtime - ${jacoco.version} - test - - - - org.junit.jupiter - junit-jupiter-engine - ${junitJupiter.version} - test - - - - org.junit.vintage - junit-vintage-engine - ${junitJupiter.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.0.1 - - false - org.umlgraph.doclet.UmlGraphDoc - - org.umlgraph - umlgraph - 5.6 - - true - - - - - org.jacoco jacoco-maven-plugin + org.jacoco ${jacoco.version} - org.apache.maven.plugins maven-assembly-plugin - 3.1.0 posix + org.apache.maven.plugins + 3.1.0 - org.codehaus.mojo exec-maven-plugin + org.codehaus.mojo 1.6.0 - org.sonarsource.scanner.maven sonar-maven-plugin + org.sonarsource.scanner.maven 3.7.0.1746 - org.apache.maven.plugins maven-clean-plugin + org.apache.maven.plugins 3.1.0 - ru.yaal.maven write-text-files-maven-plugin + ru.yaal.maven 1.1 - org.codehaus.gmaven gmaven-plugin + org.codehaus.gmaven 1.5 - org.codehaus.mojo build-helper-maven-plugin + org.codehaus.mojo 3.2.0 - org.apache.maven.plugins maven-deploy-plugin + org.apache.maven.plugins 2.8.2 - org.apache.maven.plugins maven-shade-plugin + org.apache.maven.plugins 3.1.1 - org.apache.maven.plugins maven-resources-plugin + org.apache.maven.plugins 3.2.0 - io.fabric8 docker-maven-plugin + io.fabric8 0.31.0 - org.apache.maven.plugins maven-war-plugin + org.apache.maven.plugins 3.2.2 - com.github.eirslett frontend-maven-plugin + com.github.eirslett 1.12.0 - org.apache.maven.plugins maven-surefire-plugin + org.apache.maven.plugins ${maven-surefire-plugin.version} - org.apache.maven.plugins maven-failsafe-plugin + org.apache.maven.plugins ${maven-surefire-plugin.version} - org.apache.maven.plugins maven-compiler-plugin + org.apache.maven.plugins 3.8.1 - com.github.sylvainlaurent.maven yaml-json-validator-maven-plugin + com.github.sylvainlaurent.maven 1.0.2 - pl.project13.maven git-commit-id-plugin + pl.project13.maven 4.0.0 @@ -426,83 +132,77 @@ Modifications copyright (c) 2018-2019 Nokia maven-checkstyle-plugin - 2.17 - checkstyle-suppressions.xml + ${checkstyle.skip} checkstyle.suppressions.file - ${checkstyle.skip} + checkstyle-suppressions.xml + 2.17 - org.codehaus.mojo build-helper-maven-plugin - parse-version - pre-clean parse-version + parse-version + pre-clean + org.codehaus.mojo - org.jacoco jacoco-maven-plugin - false - default-instrument instrument + default-instrument - default-restore-instrumented-classes restore-instrumented-classes + default-restore-instrumented-classes - default-report - - report - ${project.build.directory}/jacoco.exec + + report + + default-report + org.jacoco + false - org.apache.maven.plugins maven-site-plugin - 3.7.1 - org.apache.maven.wagon wagon-webdav-jackrabbit + org.apache.maven.wagon 3.0.0 + org.apache.maven.plugins + 3.7.1 - org.codehaus.gmaven gmaven-plugin - false - integration-test - - execute - pom.properties['deploy.url'] = @@ -514,57 +214,57 @@ Modifications copyright (c) 2018-2019 Nokia project.distributionManagement.repository.id; + + execute + + false + integration-test + org.codehaus.gmaven - org.apache.maven.plugins maven-compiler-plugin + true 11 11 - true + org.apache.maven.plugins - org.apache.maven.plugins maven-surefire-plugin - - - org.apache.maven.surefire - surefire-junit-platform - ${maven-surefire-plugin.version} - - + ${surefire.forkCount} + methods false + ${surefire.reuseForks} + ${surefire.skip.tests} ${project.build.directory}/jacoco.exec - ${surefire.forkCount} - ${surefire.reuseForks} - methods - ${surefire.skip.tests} + + + surefire-junit-platform + org.apache.maven.surefire + ${maven-surefire-plugin.version} + + + org.apache.maven.plugins - pl.project13.maven git-commit-id-plugin - - - - revision - - - + true true ${project.build.outputDirectory}/META-INF/git.properties - true - false + + true + git.build.version git.build.time @@ -575,24 +275,165 @@ Modifications copyright (c) 2018-2019 Nokia git.commit.message.short git.commit.message.full - - true - false + false + + + + revision + + + + pl.project13.maven + + + + org.jacoco.agent + runtime + org.jacoco + test + ${jacoco.version} + + + + junit-jupiter-engine + org.junit.jupiter + test + ${junitJupiter.version} + + + + junit-vintage-engine + org.junit.vintage + test + ${junitJupiter.version} + + + + mockito-core + org.mockito + test + ${mockito.version} + + + + + + guava + com.google.guava + ${guava.version} + + + + jersey-bean-validation + org.glassfish.jersey.ext + ${jersey-bom.version} + + + + asm-all-repackaged + org.glassfish.hk2.external + 2.4.0 + + + + assertj-core + org.assertj + ${assertj.version} + + + + jmockit + org.jmockit + ${jmockit.version} + + + + wiremock-standalone + com.github.tomakehurst + ${wire-mock.version} + + + + cucumber-java + io.cucumber + ${cucumber.version} + + + + cucumber-junit + io.cucumber + ${cucumber.version} + + + + commons-lang3 + org.apache.commons + ${lang3.version} + + + groovy + org.codehaus.groovy + ${groovy.version} + + + netty-all + io.netty + ${netty.version} + + + netty-handler + io.netty + ${netty.version} + + + swagger-maven-plugin + io.swagger.core.v3 + ${swagger-core-mvn-plugin.version} + + + + + + ecomp-releases + Release Repository + ${nexus.proxy}/content/repositories/releases/ + + + ecomp-site + dav:${nexus.proxy}${sitePath} + + + ecomp-snapshots + Snapshot Repository + ${nexus.proxy}/content/repositories/snapshots/ + + + org.openecomp.sdc + + 4.0.0 + + sdc + + pom + + + oparent + org.onap.oparent + + 3.2.0 + - all true - - true - + all onboarding common-app-logging @@ -609,13 +450,12 @@ Modifications copyright (c) 2018-2019 Nokia utils/webseal-simulator integration-tests - - - all-for-integration-tests-only true - true + + + all-for-integration-tests-only onboarding common-app-logging @@ -632,18 +472,19 @@ Modifications copyright (c) 2018-2019 Nokia utils/webseal-simulator integration-tests + + true + true + - skip-integration-tests skipITs true - - true - + skip-integration-tests onboarding common-app-logging @@ -659,19 +500,18 @@ Modifications copyright (c) 2018-2019 Nokia sdc-os-chef utils/webseal-simulator + + true + - skip-tests skipTests true - - true - true - + skip-tests onboarding common-app-logging @@ -687,20 +527,16 @@ Modifications copyright (c) 2018-2019 Nokia sdc-os-chef utils/webseal-simulator + + true + true + - fast-build false - - true - true - true - true - true - true - + fast-build onboarding common-app-logging @@ -716,58 +552,237 @@ Modifications copyright (c) 2018-2019 Nokia sdc-os-chef utils/webseal-simulator + + true + true + true + true + true + true + - start-sdc false + start-sdc + + integration-tests + - true - true true - true true + true + true + true - - integration-tests - - stop-sdc false + stop-sdc + + integration-tests + - true - true true + true true + true - true + true - - integration-tests - - run-integration-tests false + run-integration-tests + + integration-tests + - true true true + true - - integration-tests - + + 1.9 + 4.1.0 + + 1.9.7 + + ${aspectj.version} + 3.16.0 + 0.11 + 0.11 + 1.69 + 2.1.8 + 3.8.0 + 4.3.1.0 + 2.1.1 + 1.9.4 + 1.15 + 2.7 + 1.1 + 1.2 + 4.1 + 2.8.0 + 6.8.1 + 3.4.4 + 1.35 + 3.4.0 + 4.9 + 3.0.7 + 2.3.1 + 30.1-jre + 1.3 + + 2.2 + 6.1.6.Final + 4.5.13 + 4.4.1 + + 0.10.3 + 1.6.0.1 + + ${jackson.version} + 2.12.4 + + + 0.8.7 + 3.0.6 + + 0.3.3 + 4.5.1 + + + 4.0.1 + 2.0.1.Final + 2.3.1 + 0.13.2 + 0.20.1 + + + 2.34 + + + + 9.4.41.v20210516 + 1.35 + 2.9.9 + 1.1 + 1.7.1 + 5.7.2 + + + 3.10 + 2.13.1 + 1.2.3 + 1.18.20 + + + + 3.0.0 + + 2.4 + + + 2.22.2 + + + yyyyMMdd'T'HHmmss'Z' + + + 3.7.7 + ${mockito.version} + 4.1.66.Final + nexus + nexus + https://nexus.onap.org + https://nexus3.onap.org/repository/npm.public/npm/-/ + 1.6.1 + 1.2.15 + + 2.1.3 + 2.2.0.0 + UTF-8 + 3.0.3 + 1.6.0 + + + 4.0.1 + 1.6.4 + /content/sites/site/org/openecomp/sdc/${project.version} + false + 1.7.25 + 1.29 + pom.xml,src/test + + ${project.reporting.outputDirectory}/jacoco-ut/jacoco.xml + + + ${project.build.directory}/code-coverage/lcov.info + + + ${project.basedir}/node/node + ${project.basedir} + + + ${project.version} + ${project.build.sourceEncoding} + ${project.build.directory}/surefire-reports + + 5.3.9 + + 176c31dfe190a + + 1C + + + true + + false + + 2.1.7 + + + 7.4.0 + 2.6.1.Final + ${project.version} + + false + 2.26.3 + + 2.1.1 + + + + + + maven-javadoc-plugin + + org.umlgraph.doclet.UmlGraphDoc + + umlgraph + org.umlgraph + 5.6 + + false + true + + org.apache.maven.plugins + 3.0.1 + + + + @@ -788,20 +803,5 @@ Modifications copyright (c) 2018-2019 Nokia - - - ecomp-releases - Release Repository - ${nexus.proxy}/content/repositories/releases/ - - - ecomp-snapshots - Snapshot Repository - ${nexus.proxy}/content/repositories/snapshots/ - - - ecomp-site - dav:${nexus.proxy}${sitePath} - - + 1.10.0-SNAPSHOT diff --git a/utils/webseal-simulator/pom.xml b/utils/webseal-simulator/pom.xml index e9801c9402..180ac3cff1 100644 --- a/utils/webseal-simulator/pom.xml +++ b/utils/webseal-simulator/pom.xml @@ -1,164 +1,137 @@ - - 4.0.0 webseal-simulator - war - - - org.openecomp.sdc - sdc-main - 1.10.0-SNAPSHOT - ../../ - - - - yyyyMMdd'T'HHmmss'Z' - https://nexus.onap.org - UTF-8 - true - - + + WSSimulator-${project.version} + + + yaml-json-validator-maven-plugin + + + + ${skipYamlJsonValidator} + + + + 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 + + + - javax.servlet javax.servlet-api - ${javax.servlet.version} + javax.servlet + compile + ${servlet-api.version} - org.apache.httpcomponents httpclient + org.apache.httpcomponents ${httpclient.version} - commons-logging commons-logging-api + commons-logging 1.0.4 - commons-io commons-io + commons-io ${commons.io.version} - commons-codec commons-codec - ${commons-codec} + commons-codec compile + ${commons-codec} - org.eclipse.jetty jetty-proxy - ${jetty.version} - compile - org.eclipse.jetty jetty-http + org.eclipse.jetty + org.eclipse.jetty + compile + ${jetty.version} - org.eclipse.jetty jetty-servlets - ${jetty.version} - compile - org.eclipse.jetty jetty-http + org.eclipse.jetty + org.eclipse.jetty + compile + ${jetty.version} - com.typesafe config - 1.0.2 + com.typesafe compile + 1.0.2 - org.openecomp.sdc openecomp-sdc-logging-api - ${project.version} - org.powermock powermock-module-junit4 + org.powermock + org.openecomp.sdc + ${project.version} - - WSSimulator-${project.version} - - - com.github.sylvainlaurent.maven - yaml-json-validator-maven-plugin - - - validate - validate - - validate - - - - - - src/main/resources/**/*.y*ml - src/test/resources/**/*.y*ml - - - - - src/main/resources/**/*.json - src/test/resources/**/*.json - - - - ${skipYamlJsonValidator} - - - - - - + 4.0.0 - - - - ecomp-releases - Release Repository - ${nexus.proxy}/content/repositories/releases/ - - - ecomp-snapshots - Snapshots Repository - ${nexus.proxy}/content/repositories/snapshots/ - - - ecomp-public - Public Repository - ${nexus.proxy}/content/repositories/public/ - - - + war + + + sdc-main + org.openecomp.sdc + ../../ + 1.10.0-SNAPSHOT + - docker false @@ -167,38 +140,33 @@ maven-clean-plugin - 3.0.0 - clean-static-files - clean - - clean - ${project.basedir}/sdc-simulator + false *.war - false + + clean + + clean-static-files + clean + 3.0.0 maven-resources-plugin - copy-resources-simulator - verify - - copy-resources - ${project.basedir}/sdc-simulator @@ -211,28 +179,29 @@ + + copy-resources + + copy-resources-simulator + verify - io.fabric8 docker-maven-plugin - ${verbose} ${docker.api.version} - nexus3.onap.org:10001 - docker docker + docker - onap/sdc-simulator sdc-simulator try @@ -248,35 +217,67 @@ + onap/sdc-simulator + nexus3.onap.org:10001 + ${verbose} - clean-images - pre-clean remove + clean-images + pre-clean - generate-images - install build + generate-images + install - push-images - deploy push + push-images + deploy + io.fabric8 + docker + + + yyyyMMdd'T'HHmmss'Z' + https://nexus.onap.org + UTF-8 + true + + + + + + ecomp-releases + Release Repository + ${nexus.proxy}/content/repositories/releases/ + + + ecomp-snapshots + Snapshots Repository + ${nexus.proxy}/content/repositories/snapshots/ + + + ecomp-public + Public Repository + ${nexus.proxy}/content/repositories/public/ + + +