diff options
444 files changed, 10287 insertions, 2785 deletions
diff --git a/.gitattributes b/.gitattributes index 41292170cf..5191c0fad5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -13,7 +13,7 @@ *.xml text *.sql text *.bpmn text - +*.sh text eol=lf # Declare files that will always have CRLF line endings on checkout. @@ -26,7 +26,7 @@ meetings: server: 'n/a' channel: 'n/a' repeats: 'weekly' - time: '14:00 UTC' + time: '13:30 UTC' repositories: - so - so-chef-repo @@ -45,41 +45,16 @@ committers: company: 'Ericsson' id: 'byungwoojun' timezone: 'America/New_York' - - name: 'DeWayne Filppi' - email: 'dewayne@cloudify.co' - company: 'Cloudify' - id: 'dfilppi' - timezone: 'America/Los_Angeles' - name: 'Max Benjamin' email: 'max.benjamin@att.com' company: 'ATT' id: 'mfour' timezone: 'America/New_York' - - name: 'Yan Yang' - email: 'yangyanyj@chinamobile.com' - company: 'China Mobile' - id: 'yangyan' - timezone: 'Asia/Shanghai' - - name: 'Marcus Williams' - email: 'marcus.williams@intel.com' - company: 'Intel' - id: 'mgkwill' - timezone: 'America/Los_Angeles' - - name: 'Sanchita Pathak' - email: 'sanchita@techmahindra.com' - company: 'Tech Mahindra' - id: 'sanchitap' - timezone: 'Asia/Kolkata' - name: 'Steve Smokowski' email: 'ss835w@att.com' company: 'ATT' id: 'stevesmokowski' timezone: 'America/New_York' - - name: 'Subhash Kumar Singh' - email: 'Subhash.Kumar.Singh@huawei.com' - company: 'Huawei' - id: 'subhash_singh' - timezone: 'Asia/Kolkata' - name: 'Lukasz Muszkieta' email: 'lukasz.muszkieta@nokia.com' company: 'Nokia' @@ -115,4 +90,9 @@ tsc: - type: 'addition' name: 'Max Benjamin' link: 'https://lists.onap.org/g/onap-tsc/message/4981?p=,,,20,0,0,0::Created,,committer,20,2,0,31638681' - + - type: 'removal' + name: 'DeWayne Filppi' + name: 'Yan Yang' + name: 'Marcus Williams' + name: 'Sanchita Pathak' + name: 'Subhash Kumar Singh' diff --git a/adapters/etsi-sol002-adapter/pom.xml b/adapters/etsi-sol002-adapter/pom.xml index b419d8806b..5dee8fe8e6 100644 --- a/adapters/etsi-sol002-adapter/pom.xml +++ b/adapters/etsi-sol002-adapter/pom.xml @@ -17,12 +17,6 @@ <name>ETSI SOL002 Application Jar</name> - <properties> - <java.version>1.8</java.version> - <maven.compiler.source>${java.version}</maven.compiler.source> - <maven.compiler.target>${java.version}</maven.compiler.target> - </properties> - <dependencies> <dependency> <groupId>org.springframework.boot</groupId> @@ -88,6 +82,18 @@ </executions> </plugin> </plugins> + <resources> + <resource> + <directory>${basedir}/src/main/resources</directory> + <excludes> + <exclude>certs/*</exclude> + </excludes> + </resource> + <resource> + <directory>${basedir}/src/main/resources/certs</directory> + <filtering>false</filtering> + </resource> + </resources> </build> </project> diff --git a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ApplicationConfiguration.java b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ApplicationConfiguration.java index 411572ff5b..38f7a0cd3f 100644 --- a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ApplicationConfiguration.java +++ b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ApplicationConfiguration.java @@ -20,17 +20,44 @@ package org.onap.so.adapters.vevnfm.configuration; +import java.io.IOException; +import java.security.*; +import java.security.cert.CertificateException; +import javax.net.ssl.SSLContext; +import org.apache.http.client.HttpClient; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.ssl.SSLContextBuilder; import org.onap.so.adapters.vevnfm.provider.AuthorizationHeadersProvider; import org.onap.so.configuration.rest.HttpHeadersProvider; import org.onap.so.rest.service.HttpRestServiceProvider; import org.onap.so.rest.service.HttpRestServiceProviderImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.Resource; +import org.springframework.http.client.BufferingClientHttpRequestFactory; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestTemplate; @Configuration public class ApplicationConfiguration { + private static final Logger logger = LoggerFactory.getLogger(ApplicationConfiguration.class); + + private final Resource clientKeyStore; + private final String clientKeyStorePassword; + private final Resource clientTrustStore; + private final String clientTrustStorePassword; + + public ApplicationConfiguration(final ConfigProperties configProperties) { + clientKeyStore = configProperties.getClientKeyStore(); + clientKeyStorePassword = configProperties.getClientKeyStorePassword(); + clientTrustStore = configProperties.getClientTrustStore(); + clientTrustStorePassword = configProperties.getClientTrustStorePassword(); + } + @Bean public AuthorizationHeadersProvider headersProvider() { return new AuthorizationHeadersProvider(); @@ -39,6 +66,35 @@ public class ApplicationConfiguration { @Bean public HttpRestServiceProvider restProvider(final RestTemplate restTemplate, final HttpHeadersProvider headersProvider) { + modify(restTemplate); return new HttpRestServiceProviderImpl(restTemplate, headersProvider); } + + private void modify(final RestTemplate restTemplate) { + + if (clientKeyStore == null || clientTrustStore == null) { + return; + } + + try { + final KeyStore keystore = KeyStore.getInstance("PKCS12"); + keystore.load(clientKeyStore.getInputStream(), clientKeyStorePassword.toCharArray()); + + final SSLContext sslContext = new SSLContextBuilder() + .loadTrustMaterial(clientTrustStore.getURL(), clientTrustStorePassword.toCharArray()) + .loadKeyMaterial(keystore, clientKeyStorePassword.toCharArray()).build(); + + logger.info("Setting truststore: {}", clientTrustStore.getURL()); + + final SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(sslContext); + final HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory).build(); + final HttpComponentsClientHttpRequestFactory factory = + new HttpComponentsClientHttpRequestFactory(httpClient); + + restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(factory)); + } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException | CertificateException + | IOException | UnrecoverableKeyException e) { + logger.error("Error reading truststore, TLS connection to VNFM will fail.", e); + } + } } diff --git a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ConfigProperties.java b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ConfigProperties.java index d4ca5af0f2..a8a436ddc6 100644 --- a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ConfigProperties.java +++ b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ConfigProperties.java @@ -23,6 +23,7 @@ package org.onap.so.adapters.vevnfm.configuration; import org.onap.so.adapters.vevnfm.constant.NotificationVnfFilterType; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.Resource; @Configuration public class ConfigProperties { @@ -72,6 +73,18 @@ public class ConfigProperties { @Value("${spring.security.usercredentials[0].openpass}") private String springSecurityOpenpass; + @Value("${client.key-store:#{null}}") + private Resource clientKeyStore; + + @Value("${client.key-store-password:#{null}}") + private String clientKeyStorePassword; + + @Value("${client.trust-store:#{null}}") + private Resource clientTrustStore; + + @Value("${client.trust-store-password:#{null}}") + private String clientTrustStorePassword; + public String getVevnfmadapterVnfFilterJson() { return vevnfmadapterVnfFilterJson; } @@ -131,4 +144,20 @@ public class ConfigProperties { public String getSpringSecurityOpenpass() { return springSecurityOpenpass; } + + public Resource getClientKeyStore() { + return clientKeyStore; + } + + public String getClientKeyStorePassword() { + return clientKeyStorePassword; + } + + public Resource getClientTrustStore() { + return clientTrustStore; + } + + public String getClientTrustStorePassword() { + return clientTrustStorePassword; + } } diff --git a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java index c128275e43..eba1d087c6 100644 --- a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java +++ b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java @@ -28,7 +28,6 @@ import org.onap.so.adapters.vevnfm.configuration.ConfigProperties; import org.onap.so.adapters.vevnfm.exception.VeVnfmException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.retry.annotation.Backoff; import org.springframework.retry.annotation.EnableRetry; import org.springframework.retry.annotation.Recover; @@ -44,7 +43,6 @@ public class StartupService { private final String vnfmDefaultEndpoint; private final AaiConnection aaiConnection; - @Autowired public StartupService(final ConfigProperties configProperties, final AaiConnection aaiConnection) { this.vnfmDefaultEndpoint = configProperties.getVnfmDefaultEndpoint(); this.aaiConnection = aaiConnection; diff --git a/adapters/etsi-sol002-adapter/src/main/resources/application.yaml b/adapters/etsi-sol002-adapter/src/main/resources/application.yaml index c69c95187a..f5b6bc3158 100644 --- a/adapters/etsi-sol002-adapter/src/main/resources/application.yaml +++ b/adapters/etsi-sol002-adapter/src/main/resources/application.yaml @@ -19,17 +19,23 @@ server: vevnfmadapter: vnf-filter-json: '{notificationTypes:[VnfLcmOperationOccurrenceNotification],operationStates:[COMPLETED]}' - endpoint: http://so-ve-vnfm-adapter.onap:9098 + endpoint: http://so-ve-vnfm-adapter:9098 + +client: + key-store: classpath:ve-vnfm-adapter.p12 + key-store-password: 'ywsqCy:EEo#j}HJHM7z^Rk[L' + trust-store: classpath:org.onap.so.trust.jks + trust-store-password: ',sx#.C*W)]wVgJC6ccFHI#:H' mso: key: 07a7159d3bf51a0e53be7a8f89699be7 aai: - endpoint: https://aai.onap:30233 + endpoint: https://aai:30233 auth: 75C4483F9C05E2C33A8602635FA532397EC44AB667A2B64DED4FEE08DD932F2E3C1FEE vnfm: - default-endpoint: https://so-vnfm-simulator.onap:9093 + default-endpoint: https://so-vnfm-simulator:9093 subscription: /vnflcm/v1/subscriptions notification: /lcm/v1/vnf/instances/notifications @@ -37,7 +43,7 @@ notification: vnf-filter-type: NONE dmaap: - endpoint: http://message-router.onap:30227 + endpoint: http://message-router:30227 topic: /events/unauthenticated.DCAE_CL_OUTPUT closed-loop: control: diff --git a/adapters/etsi-sol002-adapter/src/main/resources/certs/org.onap.so.trust.jks b/adapters/etsi-sol002-adapter/src/main/resources/certs/org.onap.so.trust.jks Binary files differnew file mode 100644 index 0000000000..1f0d8a550a --- /dev/null +++ b/adapters/etsi-sol002-adapter/src/main/resources/certs/org.onap.so.trust.jks diff --git a/adapters/etsi-sol002-adapter/src/main/resources/certs/ve-vnfm-adapter.p12 b/adapters/etsi-sol002-adapter/src/main/resources/certs/ve-vnfm-adapter.p12 Binary files differnew file mode 100644 index 0000000000..ae4fddc684 --- /dev/null +++ b/adapters/etsi-sol002-adapter/src/main/resources/certs/ve-vnfm-adapter.p12 diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/pom.xml index f1f8bb5a70..e8b1fd08e6 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so.adapters</groupId> <artifactId>etsi-sol003-adapter</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>etsi-sol003-adapter-application</artifactId> <name>ETSI SOL003 Application Jar</name> diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/pom.xml index 9c88f6a546..391a5c622d 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so.adapters</groupId> <artifactId>etsi-sol003-adapter</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>etsi-sol003-adapter-common</artifactId> <name>ETSI SOL003 Adapter Common</name> diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/AbstractServiceProviderConfiguration.java b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/common/configuration/AbstractServiceProviderConfiguration.java index b9ce641096..6161fa60f9 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/AbstractServiceProviderConfiguration.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/common/configuration/AbstractServiceProviderConfiguration.java @@ -1,27 +1,25 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2020 Ericsson. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ - -package org.onap.so.adapters.etsisol003adapter.lcm.extclients; +package org.onap.so.adapters.etsi.sol003.adapter.common.configuration; import java.util.Iterator; -import org.onap.so.adapters.etsisol003adapter.lcm.v1.JSON; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.GsonHttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; @@ -33,6 +31,7 @@ import com.google.gson.Gson; * that will be useful to some such classes. * * @author gareth.roper@est.tech + * @author Waqas Ikram (waqas.ikram@est.tech) */ public abstract class AbstractServiceProviderConfiguration { @@ -43,7 +42,9 @@ public abstract class AbstractServiceProviderConfiguration { iterator.remove(); } } - final Gson gson = new JSON().getGson(); - restTemplate.getMessageConverters().add(new GsonHttpMessageConverter(gson)); + restTemplate.getMessageConverters().add(new GsonHttpMessageConverter(getGson())); } + + protected abstract Gson getGson(); + } diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/pom.xml index 560cd87bee..8359fd3829 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so.adapters</groupId> <artifactId>etsi-sol003-lcm</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>etsi-sol003-lcm-adapter</artifactId> <name>ETSI SOL003 Life Cycle Management Adapter</name> @@ -106,4 +106,4 @@ <scope>test</scope> </dependency> </dependencies> -</project>
\ No newline at end of file +</project> diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/vnfm/VnfmServiceProviderConfiguration.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/vnfm/VnfmServiceProviderConfiguration.java index e35dafb4ea..da727b395a 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/vnfm/VnfmServiceProviderConfiguration.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/vnfm/VnfmServiceProviderConfiguration.java @@ -39,7 +39,8 @@ import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContextBuilder; import org.onap.aai.domain.yang.EsrSystemInfo; import org.onap.aai.domain.yang.EsrVnfm; -import org.onap.so.adapters.etsisol003adapter.lcm.extclients.AbstractServiceProviderConfiguration; +import org.onap.so.adapters.etsi.sol003.adapter.common.configuration.AbstractServiceProviderConfiguration; +import org.onap.so.adapters.etsisol003adapter.lcm.v1.JSON; import org.onap.so.configuration.rest.BasicHttpHeadersProvider; import org.onap.so.rest.service.HttpRestServiceProvider; import org.onap.so.rest.service.HttpRestServiceProviderImpl; @@ -55,6 +56,7 @@ import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.security.oauth2.client.OAuth2RestTemplate; import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; import org.springframework.web.client.RestTemplate; +import com.google.gson.Gson; /** * Configures the HttpRestServiceProvider for REST call to a VNFM. @@ -151,4 +153,9 @@ public class VnfmServiceProviderConfiguration extends AbstractServiceProviderCon } } + @Override + protected Gson getGson() { + return new JSON().getGson(); + } + } diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/pom.xml index f6789575c6..01ba94ddd4 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so.adapters</groupId> <artifactId>etsi-sol003-lcm</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>etsi-sol003-lcm-api</artifactId> <name>ETSI SOL003 Life Cycle Management Adapter API</name> diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-ext-clients/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-ext-clients/pom.xml index 5452b578a7..14e8a600b5 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-ext-clients/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-ext-clients/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so.adapters</groupId> <artifactId>etsi-sol003-lcm</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>etsi-sol003-lcm-ext-clients</artifactId> <name>ETSI SOL003 Life Cycle Management Adapter Ext Clients</name> diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/pom.xml index e3f87680d8..5bcc43f2bd 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so.adapters</groupId> <artifactId>etsi-sol003-adapter</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>etsi-sol003-lcm</artifactId> <name>ETSI SOL003 Life Cycle Management</name> diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/pom.xml index 250ac504c7..fd4dc0d972 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so.adapters</groupId> <artifactId>etsi-sol003-pkgm</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>etsi-sol003-pkgm-adapter</artifactId> <name>ETSI SOL003 VNF Package Management Adapter</name> diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/AbstractServiceProviderConfiguration.java b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/AbstractServiceProviderConfiguration.java deleted file mode 100644 index f9da6981c8..0000000000 --- a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/AbstractServiceProviderConfiguration.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.etsisol003adapter.pkgm.extclients; - -import java.time.LocalDateTime; -import java.util.Iterator; -import org.onap.so.adapters.etsisol003adapter.pkgm.JSON; -import org.onap.so.adapters.etsisol003adapter.pkgm.rest.EtsiSubscriptionNotificationController; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.json.GsonHttpMessageConverter; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; -import org.springframework.web.client.RestTemplate; -import org.threeten.bp.OffsetDateTime; -import com.google.gson.Gson; - -/** - * A base class that can be extended by classes for configuring HttpRestServiceProvider classes. Provides common methods - * that will be useful to some such classes. - * - * @author gareth.roper@est.tech - */ -public abstract class AbstractServiceProviderConfiguration { - private final JSON.OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new JSON.OffsetDateTimeTypeAdapter(); - - public void setGsonMessageConverter(final RestTemplate restTemplate) { - final Iterator<HttpMessageConverter<?>> iterator = restTemplate.getMessageConverters().iterator(); - while (iterator.hasNext()) { - if (iterator.next() instanceof MappingJackson2HttpMessageConverter) { - iterator.remove(); - } - } - final Gson gson = JSON.createGson().registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter) - .registerTypeAdapter(LocalDateTime.class, - new EtsiSubscriptionNotificationController.LocalDateTimeTypeAdapter()) - .create(); - restTemplate.getMessageConverters().add(new GsonHttpMessageConverter(gson)); - } -} diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java index 5caeebe53d..1ff3672df9 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java @@ -25,7 +25,6 @@ import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; -import java.util.Iterator; import java.util.concurrent.TimeUnit; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLContext; @@ -40,7 +39,7 @@ import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.ssl.SSLContextBuilder; import org.onap.logging.filter.spring.SpringClientPayloadFilter; -import org.onap.so.adapters.etsisol003adapter.pkgm.extclients.AbstractServiceProviderConfiguration; +import org.onap.so.adapters.etsi.sol003.adapter.common.configuration.AbstractServiceProviderConfiguration; import org.onap.so.configuration.rest.BasicHttpHeadersProvider; import org.onap.so.configuration.rest.HttpClientConnectionConfiguration; import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter; @@ -56,12 +55,8 @@ import org.springframework.context.annotation.Configuration; import org.springframework.core.io.Resource; import org.springframework.http.client.BufferingClientHttpRequestFactory; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.json.GsonHttpMessageConverter; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.web.client.RestTemplate; import com.google.gson.Gson; -import com.google.gson.GsonBuilder; /** * Configures the HttpRestServiceProvider to make REST calls to the ETSI Catalog Manager @@ -173,15 +168,9 @@ public class EtsiCatalogServiceProviderConfiguration extends AbstractServiceProv } - public void setGsonMessageConverter(final RestTemplate restTemplate) { - final Iterator<HttpMessageConverter<?>> iterator = restTemplate.getMessageConverters().iterator(); - while (iterator.hasNext()) { - if (iterator.next() instanceof MappingJackson2HttpMessageConverter) { - iterator.remove(); - } - } - final Gson gson = new GsonBuilder().create(); - restTemplate.getMessageConverters().add(new GsonHttpMessageConverter(gson)); + @Override + protected Gson getGson() { + return new JSON().getGson(); } } diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/vnfm/VnfmHttpServiceProviderConfiguration.java b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/vnfm/VnfmHttpServiceProviderConfiguration.java index 568c3df48b..22bbef9c01 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/vnfm/VnfmHttpServiceProviderConfiguration.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/vnfm/VnfmHttpServiceProviderConfiguration.java @@ -20,7 +20,11 @@ package org.onap.so.adapters.etsisol003adapter.pkgm.extclients.vnfm; import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; -import org.onap.so.adapters.etsisol003adapter.pkgm.extclients.AbstractServiceProviderConfiguration; +import java.time.LocalDateTime; +import java.time.OffsetDateTime; +import org.onap.so.adapters.etsi.sol003.adapter.common.configuration.AbstractServiceProviderConfiguration; +import org.onap.so.adapters.etsisol003adapter.pkgm.JSON; +import org.onap.so.adapters.etsisol003adapter.pkgm.rest.EtsiSubscriptionNotificationController; import org.onap.so.configuration.rest.BasicHttpHeadersProvider; import org.onap.so.rest.service.HttpRestServiceProvider; import org.onap.so.rest.service.HttpRestServiceProviderImpl; @@ -29,6 +33,7 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.client.RestTemplate; +import com.google.gson.Gson; /** * @author Waqas Ikram (waqas.ikram@est.tech) @@ -36,6 +41,8 @@ import org.springframework.web.client.RestTemplate; */ @Configuration public class VnfmHttpServiceProviderConfiguration extends AbstractServiceProviderConfiguration { + private final JSON.OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new JSON.OffsetDateTimeTypeAdapter(); + public static final String VNFM_ADAPTER_HTTP_SERVICE_PROVIDER_BEAN = "vnfmAdapterHttpServiceProvider"; @Bean @@ -46,4 +53,12 @@ public class VnfmHttpServiceProviderConfiguration extends AbstractServiceProvide return new HttpRestServiceProviderImpl(restTemplate, new BasicHttpHeadersProvider().getHttpHeaders()); } + @Override + protected Gson getGson() { + return JSON.createGson().registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter) + .registerTypeAdapter(LocalDateTime.class, + new EtsiSubscriptionNotificationController.LocalDateTimeTypeAdapter()) + .create(); + } + } diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-api/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-api/pom.xml index 884419c550..8d79aff29d 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-api/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-api/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so.adapters</groupId> <artifactId>etsi-sol003-pkgm</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>etsi-sol003-pkgm-api</artifactId> <name>ETSI SOL003 VNF Package Management Adapter API</name> diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-ext-clients/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-ext-clients/pom.xml index 6e6de84b5f..f34fb61802 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-ext-clients/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-ext-clients/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so.adapters</groupId> <artifactId>etsi-sol003-pkgm</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>etsi-sol003-pkgm-ext-clients</artifactId> <name>ETSI SOL003 VNF Package Management Adapter Ext Clients</name> diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/pom.xml index fb5b636ee4..37f9e2efee 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so.adapters</groupId> <artifactId>etsi-sol003-adapter</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>etsi-sol003-pkgm</artifactId> <name>ETSI SOL003 VNF Package Management</name> diff --git a/adapters/etsi-sol003-adapter/pom.xml b/adapters/etsi-sol003-adapter/pom.xml index 6c3a1f5b1c..ceaaab42d0 100644 --- a/adapters/etsi-sol003-adapter/pom.xml +++ b/adapters/etsi-sol003-adapter/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <groupId>org.onap.so.adapters</groupId> <artifactId>etsi-sol003-adapter</artifactId> @@ -16,10 +16,10 @@ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <version-swagger-codegen>2.3.1</version-swagger-codegen> <gson-fire-version>1.8.2</gson-fire-version> - <retrofit-version>2.3.0</retrofit-version> + <retrofit-version>2.7.2</retrofit-version> <threetenbp-version>1.3.5</threetenbp-version> <oltu-version>1.0.1</oltu-version> - <swagger-core-version>1.5.15</swagger-core-version> + <swagger-core-version>1.5.21</swagger-core-version> <okhttp3-version>3.14.0</okhttp3-version> <okhttp-version>2.7.5</okhttp-version> <okio-version>1.13.0</okio-version> @@ -32,4 +32,4 @@ <module>etsi-sol003-lcm</module> <module>etsi-sol003-adapter-application</module> </modules> -</project>
\ No newline at end of file +</project> diff --git a/adapters/mso-adapter-utils/pom.xml b/adapters/mso-adapter-utils/pom.xml index a121d2d89b..6346983f96 100644 --- a/adapters/mso-adapter-utils/pom.xml +++ b/adapters/mso-adapter-utils/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <groupId>org.onap.so.adapters</groupId> <artifactId>mso-adapter-utils</artifactId> @@ -113,12 +113,6 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>org.jmockit</groupId> - <artifactId>jmockit</artifactId> - <version>1.8</version> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.yaml</groupId> <artifactId>snakeyaml</artifactId> </dependency> diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaCacheConfig.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaCacheConfig.java index 2f7d19ff1d..cc79e615f1 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaCacheConfig.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaCacheConfig.java @@ -24,12 +24,14 @@ import org.springframework.cache.CacheManager; import org.springframework.cache.caffeine.CaffeineCacheManager; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; import com.github.benmanes.caffeine.cache.Caffeine; @Configuration public class NovaCacheConfig { @Bean + @Primary public CacheManager cacheManager() { CaffeineCacheManager cacheManager = new CaffeineCacheManager("novaClient"); cacheManager.setCaffeine(caffeineCacheBuilder()); diff --git a/adapters/mso-adapters-rest-interface/pom.xml b/adapters/mso-adapters-rest-interface/pom.xml index 584c47fea6..9e86f41af3 100644 --- a/adapters/mso-adapters-rest-interface/pom.xml +++ b/adapters/mso-adapters-rest-interface/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <groupId>org.onap.so.adapters</groupId> <artifactId>mso-adapters-rest-interface</artifactId> @@ -18,7 +18,8 @@ <plugins> <plugin> <artifactId>maven-jar-plugin</artifactId> - <version>2.6</version> + <!--<version>2.6</version>--> + <version>3.0.2</version> <configuration> <classesDirectory>target/classes</classesDirectory> </configuration> diff --git a/adapters/mso-catalog-db-adapter/pom.xml b/adapters/mso-catalog-db-adapter/pom.xml index 8735f98804..9b51e35c57 100644 --- a/adapters/mso-catalog-db-adapter/pom.xml +++ b/adapters/mso-catalog-db-adapter/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <groupId>org.onap.so.adapters</groupId> @@ -13,7 +13,6 @@ <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - <java.version>1.8</java.version> <swagger.version>2.0.8</swagger.version> </properties> <build> @@ -39,6 +38,9 @@ <executions> <execution> <id>extract-docker-file</id> + <configuration> + <skip>false</skip> + </configuration> </execution> </executions> </plugin> @@ -53,19 +55,6 @@ </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>3.3</version> - <configuration> - <source>1.8</source> - <target>1.8</target> - <fork>true</fork> - <compilerArgs> - <arg>-parameters</arg> - </compilerArgs> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <executions> <execution> @@ -84,14 +73,14 @@ </plugin> </plugins> <pluginManagement> - <plugins> - <plugin> - <groupId>org.eclipse.m2e</groupId> - <artifactId>lifecycle-mapping</artifactId> - <version>1.0.0</version> - <configuration> - <lifecycleMappingMetadata> - <pluginExecutions> + <plugins> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> <pluginExecution> <pluginExecutionFilter> <groupId>org.apache.maven.plugins</groupId> @@ -186,7 +175,12 @@ <dependency> <groupId>uk.co.blackpepper.bowman</groupId> <artifactId>bowman-client</artifactId> - <version>0.3.0</version> + <version>${bowman.client.version}</version> + </dependency> + <dependency> + <groupId>org.javassist</groupId> + <artifactId>javassist</artifactId> + <version>3.25.0-GA</version> </dependency> <dependency> <groupId>ch.vorburger.mariaDB4j</groupId> diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDbRepositoryConfiguration.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDbRepositoryConfiguration.java index fdec7cf5d6..4d8f55e220 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDbRepositoryConfiguration.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDbRepositoryConfiguration.java @@ -20,8 +20,8 @@ package org.onap.so.adapters.catalogdb; -import java.util.stream.Collectors; import javax.persistence.EntityManager; +import javax.persistence.metamodel.Type; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.data.rest.core.config.RepositoryRestConfiguration; @@ -35,8 +35,8 @@ public class CatalogDbRepositoryConfiguration extends RepositoryRestConfigurerAd @Override public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { - config.exposeIdsFor(entityManager.getMetamodel().getEntities().stream().map(e -> e.getJavaType()) - .collect(Collectors.toList()).toArray(new Class[0])); + config.exposeIdsFor( + entityManager.getMetamodel().getEntities().stream().map(Type::getJavaType).toArray(Class[]::new)); } } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java index f283af1ba6..aa039c6ac4 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java @@ -655,4 +655,36 @@ public class CatalogDbAdapterRest { return Response.status(HttpStatus.SC_NOT_FOUND).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .build(); } + + @GET + @Path("processingFlags") + @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Transactional(readOnly = true) + public Response getAllProcessingFlags() { + return getAllProcessingFlagsImpl(); + } + + public Response getAllProcessingFlagsImpl() { + List<ProcessingFlags> processingFlags = null; + + int respStatus = HttpStatus.SC_OK; + try { + processingFlags = processingFlagsRepo.findAll(); + if (processingFlags == null) { + logger.debug("ProcessingFlags not found"); + respStatus = HttpStatus.SC_NOT_FOUND; + } else { + + logger.debug("ProcessingFlags processingFlags = {}", processingFlags.toString()); + } + return Response.status(respStatus).entity(processingFlags) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).build(); + } catch (Exception e) { + logger.error("Exception - queryProcesssingFlags", e); + CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), + CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); + return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .entity(new GenericEntity<CatalogQueryException>(excResp) {}).build(); + } + } } diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql index a5e546e093..ea371f54f7 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql @@ -68,32 +68,33 @@ INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FL ('Service-Macro-Create', '7', 'ConfigAssignVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), ('Service-Macro-Create', '8', 'AssignPnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), ('Service-Macro-Create', '9', 'WaitForPnfReadyBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Create', '10', 'ActivatePnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Create', '11', 'CreateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Create', '12', 'ActivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Create', '13', 'CreateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Create', '14', 'ActivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Create', '15', 'CreateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Create', '16', 'ActivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Create', '17', 'ConfigDeployVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Create', '18', 'ActivateVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Create', '19', 'ActivateNetworkCollectionBB',1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Create', '20', 'ActivateServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Create', '11', 'ActivatePnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Create', '12', 'CreateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Create', '13', 'ActivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Create', '14', 'CreateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Create', '15', 'ActivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Create', '16', 'CreateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Create', '17', 'ActivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Create', '18', 'ConfigDeployVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Create', '19', 'ActivateVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Create', '20', 'ActivateNetworkCollectionBB',1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Create', '21', 'ActivateServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), ('Service-Macro-Delete', '1', 'DeactivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), ('Service-Macro-Delete', '2', 'DeleteVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), ('Service-Macro-Delete', '3', 'DeactivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), ('Service-Macro-Delete', '4', 'DeleteVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), ('Service-Macro-Delete', '5', 'DeactivateVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '6', 'DeactivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '7', 'DeleteNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '8', 'DeactivateNetworkCollectionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '9', 'DeleteNetworkCollectionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '10', 'DeactivateServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '11', 'UnassignVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '12', 'UnassignVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '13', 'UnassignVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '14', 'UnassignNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '15', 'UnassignServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '6', 'DeactivatePnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '7', 'DeactivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '8', 'DeleteNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '9', 'DeactivateNetworkCollectionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '10', 'DeleteNetworkCollectionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '11', 'DeactivateServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '12', 'UnassignVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '13', 'UnassignVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '14', 'UnassignVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '15', 'UnassignNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '16', 'UnassignServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), ('Network-Create', '1', 'AssignNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Network-Create' and CLOUD_OWNER = 'DEFAULT')), ('Network-Create', '2', 'CreateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Network-Create' and CLOUD_OWNER = 'DEFAULT')), ('Network-Create', '3', 'ActivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Network-Create' and CLOUD_OWNER = 'DEFAULT')), @@ -210,6 +211,9 @@ INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FL ('VNF-Config-Update', '8', 'VNFUnsetInMaintFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Config-Update' and CLOUD_OWNER = 'DEFAULT')), ('VNF-Config-Update', '9', 'VNFUnsetClosedLoopDisabledFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Config-Update' and CLOUD_OWNER = 'DEFAULT')); +INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FLOW_VERSION, NB_REQ_REF_LOOKUP_ID, SCOPE, ACTION) VALUES +('Service-Macro-Create', '10', 'ControllerExecutionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT'), 'pnf', 'config-assign'); + INSERT INTO rainy_day_handler_macro (FLOW_NAME, SERVICE_TYPE, VNF_TYPE, ERROR_CODE, WORK_STEP, POLICY) VALUES ('ActivateNetworkBB', '*', '*', '*', '*' , 'Rollback'), @@ -280,6 +284,7 @@ VALUES ('DeactivateVolumeGroupBB', 'VOLUME_GROUP', 'DEACTIVATE'), ('DeactivateVfModuleBB', 'VF_MODULE', 'DEACTIVATE'), ('DeactivateNetworkBB', 'NETWORK', 'DEACTIVATE'), +('DeactivatePnfBB', 'NO_VALIDATE', 'DEACTIVATE'), ('ChangeModelServiceInstanceBB', 'SERVICE', 'CHANGEMODEL'), @@ -929,3 +934,13 @@ VALUES ('VNFConfigModifyActivity','*','*','*','*','Manual','Abort','*', '*'), ('VNFUnsetInMaintFlagActivity','*','*','*','*','Manual','Abort','*', '*'), ('VNFUnsetClosedLoopDisabledActivity','*','*','*','*','Manual','Abort','*', '*'); + +UPDATE orchestration_flow_reference set FLOW_NAME='ControllerExecutionBB', SCOPE='vnf', ACTION='config-assign' WHERE COMPOSITE_ACTION = 'Service-Macro-Create' and FLOW_NAME = 'ConfigAssignVnfBB'; +UPDATE orchestration_flow_reference set FLOW_NAME='ControllerExecutionBB', SCOPE='vnf', ACTION='config-deploy' WHERE COMPOSITE_ACTION = 'Service-Macro-Create' and FLOW_NAME = 'ConfigDeployVnfBB'; +UPDATE orchestration_flow_reference set FLOW_NAME='ControllerExecutionBB', SCOPE='vnf', ACTION='HealthCheck' WHERE COMPOSITE_ACTION = 'VFModule-ScaleOut' and FLOW_NAME = 'GenericVnfHealthCheckBB'; +UPDATE orchestration_flow_reference set FLOW_NAME='ControllerExecutionBB', SCOPE='vfmodule', ACTION='ScaleOutReconfiguration' WHERE COMPOSITE_ACTION = 'VFModule-ScaleOut' and FLOW_NAME = 'GenericVnfHealthCheckBB'; + +INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FLOW_VERSION, NB_REQ_REF_LOOKUP_ID, SCOPE, ACTION) VALUES +('VFModule-Delete', '1', 'ControllerExecutionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Delete' and CLOUD_OWNER = 'DEFAULT'), "vnf", "HealthCheck"), +('VFModule-Delete', '2', 'ControllerExecutionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Delete' and CLOUD_OWNER = 'DEFAULT'), "vfmodule", "ScaleInReconfiguration"), +('VFModule-Delete', '6', 'ControllerExecutionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Delete' and CLOUD_OWNER = 'DEFAULT'), "vnf", "HealthCheck");
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java index 04161e9df9..3906229c2c 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java @@ -21,7 +21,9 @@ package org.onap.so.adapters.catalogdb.catalogrest; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.io.IOException; +import java.util.List; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.json.JSONException; @@ -37,6 +39,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.web.util.UriComponentsBuilder; +import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @@ -831,6 +834,34 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { } @Test + public void testGetAllProcessingFlags() throws Exception { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = + UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_PROCESSING_FLAGS)); + + ResponseEntity<String> response = + restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); + ObjectMapper mapper = new ObjectMapper(); + + List<ProcessingFlags> processingFlagsResponse = + mapper.readValue(response.getBody(), new TypeReference<List<ProcessingFlags>>() {}); + + boolean testFlagFound = false; + for (int i = 0; i < processingFlagsResponse.size(); i++) { + if (processingFlagsResponse.get(i).getFlag().equals("TESTFLAG")) { + assertEquals(processingFlagsResponse.get(i).getEndpoint(), "TESTENDPOINT"); + assertEquals(processingFlagsResponse.get(i).getDescription(), "TEST FLAG"); + testFlagFound = true; + } + } + assertTrue(testFlagFound); + } + + @Test public void testSetProcessingFlagsFlagValue() throws JSONException { ProcessingFlags updatedProcessingFlag = new ProcessingFlags(); updatedProcessingFlag.setFlag("TESTFLAG"); diff --git a/adapters/mso-nssmf-adapter/pom.xml b/adapters/mso-nssmf-adapter/pom.xml index b257adaa96..db791826c3 100644 --- a/adapters/mso-nssmf-adapter/pom.xml +++ b/adapters/mso-nssmf-adapter/pom.xml @@ -26,7 +26,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <groupId>org.onap.so.adapters</groupId> <artifactId>mso-nssmf-adapter</artifactId> diff --git a/adapters/mso-openstack-adapters/Deployment/Dockerfile.adapters b/adapters/mso-openstack-adapters/Deployment/Dockerfile.adapters index 4d3e36ed9c..8bc2ea6f83 100644 --- a/adapters/mso-openstack-adapters/Deployment/Dockerfile.adapters +++ b/adapters/mso-openstack-adapters/Deployment/Dockerfile.adapters @@ -1,4 +1,4 @@ -FROM openjdk:8-jdk-alpine +FROM onap/integration-java11:7.0.0 MAINTAINER mc4615@att.com EXPOSE 8080 ENV APP_HOME /home/$USER_NAME/app @@ -37,4 +37,4 @@ ENTRYPOINT ["java","-jar","-Dspring.profiles.active=dev","mso-openstack-adapters # OR for interactive mode (-it), run the following command # docker run -it --net=mso_network -p 8080:8080 --name mchan mercechan/msoadapters # COMMANDS ######## -######### README #########
\ No newline at end of file +######### README ######### diff --git a/adapters/mso-openstack-adapters/pom.xml b/adapters/mso-openstack-adapters/pom.xml index 53af40ca4b..ad41b0f050 100644 --- a/adapters/mso-openstack-adapters/pom.xml +++ b/adapters/mso-openstack-adapters/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>mso-openstack-adapters</artifactId> <packaging>jar</packaging> @@ -18,10 +18,6 @@ <plugins> <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-dependency-plugin</artifactId> - </plugin> - <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> @@ -135,6 +131,9 @@ <executions> <execution> <id>extract-docker-file</id> + <configuration> + <skip>false</skip> + </configuration> </execution> </executions> </plugin> @@ -153,9 +152,7 @@ <executions> <execution> <id>original</id> - <configuration> - <skip>false</skip> - </configuration> + <phase>package</phase> </execution> </executions> </plugin> @@ -263,10 +260,24 @@ </dependency> <dependency> <groupId>org.pacesys.openstack4j.connectors</groupId> - <artifactId>openstack4j-httpclient</artifactId> + <artifactId>openstack4j-jersey2</artifactId> <version>3.2.0</version> </dependency> - + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-client</artifactId> + <version>2.22.1</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.media</groupId> + <artifactId>jersey-media-json-jackson</artifactId> + <version>2.22.1</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-common</artifactId> + <version>2.22.1</version> + </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> @@ -342,5 +353,10 @@ <artifactId>camunda-external-task-client</artifactId> <version>1.1.1</version> </dependency> + <dependency> + <groupId>com.github.seancfoley</groupId> + <artifactId>ipaddress</artifactId> + <version>2.0.0</version> + </dependency> </dependencies> </project> diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java index 15c5eda054..1f0422b0b2 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java @@ -47,20 +47,19 @@ public class DeleteAAIInventory { @Autowired protected Environment env; - public void heatbridge(CloudInformation cloudInformation, boolean dryrun) { + public void heatbridge(CloudInformation cloudInformation) { try { - if (!dryrun) { - logger.debug("Heatbridge delete executing"); + logger.debug("Heatbridge delete executing"); + + CloudSite cloudSite = cloudConfig.getCloudSite(cloudInformation.getRegionId()) + .orElseThrow(() -> new MsoCloudSiteNotFound(cloudInformation.getRegionId())); + CloudIdentity cloudIdentity = cloudSite.getIdentityService(); + HeatBridgeApi heatBridgeClient = + new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity, cloudInformation.getOwner(), + cloudInformation.getRegionId(), cloudSite.getRegionId(), cloudInformation.getTenantId()); + heatBridgeClient.authenticate(); + heatBridgeClient.deleteVfModuleData(cloudInformation.getVnfId(), cloudInformation.getVfModuleId()); - CloudSite cloudSite = cloudConfig.getCloudSite(cloudInformation.getRegionId()) - .orElseThrow(() -> new MsoCloudSiteNotFound(cloudInformation.getRegionId())); - CloudIdentity cloudIdentity = cloudSite.getIdentityService(); - HeatBridgeApi heatBridgeClient = new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity, - cloudInformation.getOwner(), cloudInformation.getRegionId(), cloudSite.getRegionId(), - cloudInformation.getTenantId()); - heatBridgeClient.authenticate(); - heatBridgeClient.deleteVfModuleData(cloudInformation.getVnfId(), cloudInformation.getVfModuleId()); - } } catch (Exception ex) { logger.debug("Heatbrige failed for stackId: " + cloudInformation.getTemplateInstanceId(), ex); } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java index b104c3310c..4e5e880f80 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java @@ -21,7 +21,6 @@ package org.onap.so.adapters.inventory.delete; import javax.annotation.PostConstruct; -import org.camunda.bpm.client.ExternalTaskClient; import org.onap.so.utils.ExternalTaskServiceUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Profile; @@ -43,10 +42,11 @@ public class DeleteInventoryService { @PostConstruct public void auditAAIInventory() throws Exception { - ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient(); - client.subscribe("InventoryDelete") - .lockDuration(Long.parseLong(env.getProperty("mso.audit.lock-time", "60000"))) - .handler(deleteInventory::executeExternalTask).open(); + for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { + externalTaskServiceUtils.createExternalTaskClient().subscribe("InventoryDelete") + .lockDuration(externalTaskServiceUtils.getLockDurationMedium()) + .handler(deleteInventory::executeExternalTask).open(); + } } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java index c5feee2089..10faa2b08f 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java @@ -60,14 +60,13 @@ public class DeleteInventoryTask extends ExternalTaskUtils { protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) { mdcSetup.setupMDC(externalTask); - boolean inventoryException = false; String externalTaskId = externalTask.getId(); CloudInformation cloudInformation = externalTask.getVariable("cloudInformation"); boolean success = true; if (cloudInformation != null) { Integer retryCount = externalTask.getRetries(); try { - deleteInventory.heatbridge(cloudInformation, env.getProperty("heatBridgeDryrun", Boolean.class, true)); + deleteInventory.heatbridge(cloudInformation); } catch (Exception e) { logger.error("Error during inventory of stack", e); success = false; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java index d282046b3f..d4a4bb792f 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java @@ -22,7 +22,6 @@ package org.onap.so.adapters.tasks; import javax.annotation.PostConstruct; import org.camunda.bpm.client.ExternalTaskClient; -import org.onap.so.utils.ExternalTaskServiceUtils; import org.onap.so.adapters.tasks.audit.AuditCreateStackService; import org.onap.so.adapters.tasks.audit.AuditDeleteStackService; import org.onap.so.adapters.tasks.audit.AuditQueryStackService; @@ -30,6 +29,7 @@ import org.onap.so.adapters.tasks.inventory.CreateInventoryTask; import org.onap.so.adapters.tasks.orchestration.PollService; import org.onap.so.adapters.tasks.orchestration.RollbackService; import org.onap.so.adapters.tasks.orchestration.StackService; +import org.onap.so.utils.ExternalTaskServiceUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -70,7 +70,7 @@ public class TaskServices { public void auditAddAAIInventory() throws Exception { for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient(); - client.subscribe("InventoryAddAudit").lockDuration(externalTaskServiceUtils.getLockDuration()) + client.subscribe("InventoryAddAudit").lockDuration(externalTaskServiceUtils.getLockDurationLong()) .handler(auditCreateStack::executeExternalTask).open(); } } @@ -79,7 +79,7 @@ public class TaskServices { public void auditDeleteAAIInventory() throws Exception { for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient(); - client.subscribe("InventoryDeleteAudit").lockDuration(externalTaskServiceUtils.getLockDuration()) + client.subscribe("InventoryDeleteAudit").lockDuration(externalTaskServiceUtils.getLockDurationLong()) .handler(auditDeleteStack::executeExternalTask).open(); } } @@ -94,10 +94,10 @@ public class TaskServices { } @PostConstruct - public void auditAAIInventory() throws Exception { + public void createtAAIInventory() throws Exception { for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient(); - client.subscribe("InventoryCreate").lockDuration(externalTaskServiceUtils.getLockDuration()) + client.subscribe("InventoryCreate").lockDuration(externalTaskServiceUtils.getLongLockDuration()) .handler(createInventory::executeExternalTask).open(); } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java index 2f7155bffc..8cdd37d43f 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java @@ -21,7 +21,6 @@ package org.onap.so.adapters.tasks.audit; -import java.util.Optional; import org.onap.so.objects.audit.AAIObjectAudit; import org.onap.so.objects.audit.AAIObjectAuditList; import org.onap.so.utils.ExternalTaskUtils; @@ -37,8 +36,6 @@ public abstract class AbstractAuditService extends ExternalTaskUtils { private static final Logger logger = LoggerFactory.getLogger(AbstractAuditService.class); - - protected static final String UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI = "Unable to find all VServers and L-Interaces in A&AI"; @@ -52,29 +49,27 @@ public abstract class AbstractAuditService extends ExternalTaskUtils { } /** - * @param auditHeatStackFailed * @param auditList * @return */ - protected boolean didCreateAuditFail(Optional<AAIObjectAuditList> auditList) { - if (auditList.get().getAuditList() != null && !auditList.get().getAuditList().isEmpty()) { + protected boolean didCreateAuditFail(AAIObjectAuditList auditList) { + if (isAuditListNotNullAndNotEmpty(auditList)) { if (logger.isInfoEnabled()) { - logger.info("Audit Results: {}", auditList.get().toString()); + logger.info("Audit Results: {}", auditList.toString()); } - return auditList.get().getAuditList().stream().filter(auditObject -> !auditObject.isDoesObjectExist()) - .findFirst().map(v -> true).orElse(false); + return auditList.getAuditList().stream().filter(auditObject -> !auditObject.isDoesObjectExist()).findFirst() + .map(v -> true).orElse(false); } else { return false; } } /** - * @param auditHeatStackFailed * @param auditList * @return */ protected boolean didDeleteAuditFail(AAIObjectAuditList auditList) { - if (auditList.getAuditList() != null && !auditList.getAuditList().isEmpty()) { + if (isAuditListNotNullAndNotEmpty(auditList)) { if (logger.isInfoEnabled()) { logger.info("Audit Results: {}", auditList.toString()); } @@ -84,4 +79,9 @@ public abstract class AbstractAuditService extends ExternalTaskUtils { return false; } } + + private boolean isAuditListNotNullAndNotEmpty(AAIObjectAuditList auditList) { + return auditList != null && auditList.getAuditList() != null && !auditList.getAuditList().isEmpty(); + } + } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java index 010475c87a..a4afcf1378 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java @@ -59,7 +59,7 @@ public class AuditCreateStackService extends AbstractAuditService { boolean success = false; try { Integer retryCount = externalTask.getRetries(); - logger.info("Executing External Task Audit Inventory, Retry Number: {} \n {}", auditInventory, retryCount); + logger.info("Executing External Task Audit Inventory, Retry Number: {} \n {}", retryCount, auditInventory); Optional<AAIObjectAuditList> auditListOpt = heatStackAudit.auditHeatStack(auditInventory.getCloudRegion(), auditInventory.getCloudOwner(), auditInventory.getTenantId(), auditInventory.getHeatStackName()); if (auditListOpt.isPresent()) { @@ -67,7 +67,7 @@ public class AuditCreateStackService extends AbstractAuditService { auditListOpt.get().setHeatStackName(auditInventory.getHeatStackName()); GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider(); variables.put("auditInventoryResult", objectMapper.getMapper().writeValueAsString(auditListOpt.get())); - success = !didCreateAuditFail(auditListOpt); + success = !didCreateAuditFail(auditListOpt.get()); } } catch (Exception e) { logger.error("Error during audit of stack", e); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java index 4e8443bf45..200f6375ea 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java @@ -17,6 +17,8 @@ import com.fasterxml.jackson.databind.JsonMappingException; @Component public class AuditDataService { + private static final String AUDIT_STACK_DATA = "AuditStackData"; + @Autowired private RequestsDbClient requestsDbClient; @@ -30,7 +32,7 @@ public class AuditDataService { throws JsonProcessingException { List<RequestProcessingData> requestProcessingDataList = requestsDbClient.getRequestProcessingDataByGroupingIdAndNameAndTag(auditInventory.getVfModuleId(), - auditInventory.getHeatStackName(), "AuditStackData"); + auditInventory.getHeatStackName(), AUDIT_STACK_DATA); if (requestProcessingDataList.isEmpty()) { GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider(); String auditListString = objectMapper.getMapper().writeValueAsString(auditList);; @@ -39,7 +41,7 @@ public class AuditDataService { requestProcessingData.setSoRequestId(auditInventory.getMsoRequestId()); requestProcessingData.setGroupingId(auditInventory.getVfModuleId()); requestProcessingData.setName(auditInventory.getHeatStackName()); - requestProcessingData.setTag("AuditStackData"); + requestProcessingData.setTag(AUDIT_STACK_DATA); requestProcessingData.setValue(auditListString); requestsDbClient.saveRequestProcessingData(requestProcessingData); @@ -53,12 +55,11 @@ public class AuditDataService { * @throws JsonMappingException * @throws JsonParseException */ - public Optional<AAIObjectAuditList> getStackDataFromRequestDb(AuditInventory auditInventory) - throws JsonParseException, JsonMappingException, IOException { + public Optional<AAIObjectAuditList> getStackDataFromRequestDb(AuditInventory auditInventory) throws IOException { List<RequestProcessingData> requestProcessingDataList = requestsDbClient.getRequestProcessingDataByGroupingIdAndNameAndTag(auditInventory.getVfModuleId(), - auditInventory.getHeatStackName(), "AuditStackData"); + auditInventory.getHeatStackName(), AUDIT_STACK_DATA); if (!requestProcessingDataList.isEmpty()) { RequestProcessingData requestProcessingData = requestProcessingDataList.get(0); String auditListString = requestProcessingData.getValue(); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java index eab0451aa6..12751f8c27 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java @@ -35,6 +35,7 @@ import org.openstack4j.model.compute.Flavor; import org.openstack4j.model.compute.Image; import org.openstack4j.model.compute.Server; import org.openstack4j.model.heat.Resource; +import org.openstack4j.model.network.Network; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -72,6 +73,10 @@ public class CreateAAIInventory { List<Resource> stackResources = heatBridgeClient.queryNestedHeatStackResources(cloudInformation.getTemplateInstanceId()); + List<Network> osNetworks = heatBridgeClient.getAllOpenstackProviderNetworks(stackResources); + heatBridgeClient.buildAddNetworksToAaiAction(cloudInformation.getVnfId(), cloudInformation.getVfModuleId(), + osNetworks); + List<Server> osServers = heatBridgeClient.getAllOpenstackServers(stackResources); heatBridgeClient.createPserversAndPinterfacesIfNotPresentInAai(stackResources); @@ -108,7 +113,8 @@ public class CreateAAIInventory { if (!CollectionUtils.isEmpty(oobMgtNetNames)) { oobMgtNetIds = heatBridgeClient.extractNetworkIds(oobMgtNetNames); } - heatBridgeClient.buildAddVserverLInterfacesToAaiAction(stackResources, oobMgtNetIds); + heatBridgeClient.buildAddVserverLInterfacesToAaiAction(stackResources, oobMgtNetIds, + cloudInformation.getOwner()); logger.debug( "Successfully queried neutron resources and built AAI actions to add l-interfaces to vservers."); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTask.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTask.java index 317dae61b9..2202e97e71 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTask.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTask.java @@ -64,8 +64,8 @@ public class CreateInventoryTask extends ExternalTaskUtils { if (cloudInformation != null) { Integer retryCount = externalTask.getRetries(); try { - logger.info("Executing External Task Create Inventory, Retry Number: {} \n {}", cloudInformation, - retryCount); + logger.info("Executing External Task Create Inventory, Retry Number: {} \n {}", retryCount, + cloudInformation.toString()); createInventory.heatbridge(cloudInformation); } catch (Exception e) { logger.error("Error during inventory of stack", e); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java index d0ca87df95..a4e6cccc06 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java @@ -38,6 +38,7 @@ import org.openstack4j.model.compute.Flavor; import org.openstack4j.model.compute.Image; import org.openstack4j.model.compute.Server; import org.openstack4j.model.heat.Resource; +import org.openstack4j.model.network.Network; /** * Defines the contract to extract Heat Stack Resources from Openstack and inventory it to AAI. This API is used only to @@ -88,6 +89,14 @@ public interface HeatBridgeApi { List<Server> getAllOpenstackServers(List<Resource> stackResources); /** + * Query the Openstack provider network objects from the list of stack resources + * + * @param stackResources A list of stack based resources + * @return A list of Openstack Network objects + */ + List<Network> getAllOpenstackProviderNetworks(final List<Resource> stackResources); + + /** * Extract Openstack Image objects from a a list of Server objects * * @param servers A list of Openstack Server objects @@ -104,6 +113,15 @@ public interface HeatBridgeApi { List<Flavor> extractOpenstackFlavorsFromServers(List<Server> servers); /** + * Query and build AAI actions for Openstack Compute resources to AAI's l3-network objects with its subnets + * + * @param genericVnfId AAI generic-vnf-id + * @param vfModuleId AAI vf-module-id + * @param networks Openstack Network list + */ + void buildAddNetworksToAaiAction(final String genericVnfId, final String vfModuleId, List<Network> networks); + + /** * Query and build AAI actions for Openstack Image resources to AAI's image objects * * @param images List of Openstack Image objects @@ -134,8 +152,10 @@ public interface HeatBridgeApi { * * @param stackResources Openstack Heat stack resource list * @param oobMgtNetIds List of OOB network IDs list + * @param cloudOwner */ - void buildAddVserverLInterfacesToAaiAction(List<Resource> stackResources, List<String> oobMgtNetIds); + void buildAddVserverLInterfacesToAaiAction(List<Resource> stackResources, List<String> oobMgtNetIds, + String cloudOwner); /** * Query and build AAI actions for Openstack Compute resources to AAI's pserver and pinterface objects diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java index bbabd7fab8..ef2577d6fe 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java @@ -42,24 +42,28 @@ import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collectors; import javax.annotation.Nonnull; +import javax.ws.rs.NotFoundException; import javax.ws.rs.WebApplicationException; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.validator.routines.InetAddressValidator; import org.onap.aai.domain.yang.Flavor; import org.onap.aai.domain.yang.Image; import org.onap.aai.domain.yang.L3InterfaceIpv4AddressList; +import org.onap.aai.domain.yang.L3Network; import org.onap.aai.domain.yang.LInterface; import org.onap.aai.domain.yang.PInterface; import org.onap.aai.domain.yang.Pserver; +import org.onap.aai.domain.yang.Relationship; +import org.onap.aai.domain.yang.RelationshipList; import org.onap.aai.domain.yang.SriovPf; import org.onap.aai.domain.yang.SriovPfs; +import org.onap.aai.domain.yang.Subnets; import org.onap.aai.domain.yang.SriovVf; import org.onap.aai.domain.yang.SriovVfs; import org.onap.aai.domain.yang.VfModule; import org.onap.aai.domain.yang.Vlan; import org.onap.aai.domain.yang.Vlans; import org.onap.aai.domain.yang.Vserver; -import org.onap.logging.filter.base.ErrorCode; import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.AAIResourcesClient; import org.onap.aaiclient.client.aai.AAISingleTransactionClient; @@ -67,8 +71,10 @@ import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; import org.onap.aaiclient.client.aai.entities.Relationships; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.aaiclient.client.graphinventory.entities.uri.Depth; import org.onap.aaiclient.client.graphinventory.exceptions.BulkProcessFailed; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.ServerType; import org.onap.so.heatbridge.constants.HeatBridgeConstants; @@ -79,17 +85,21 @@ import org.onap.so.heatbridge.openstack.factory.OpenstackClientFactoryImpl; import org.onap.so.heatbridge.utils.HeatBridgeUtils; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; +import org.onap.so.spring.SpringContextHelper; import org.openstack4j.model.compute.Server; import org.openstack4j.model.heat.Resource; import org.openstack4j.model.network.IP; import org.openstack4j.model.network.Network; import org.openstack4j.model.network.NetworkType; import org.openstack4j.model.network.Port; +import org.openstack4j.model.network.Subnet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.core.env.Environment; import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; +import inet.ipaddr.IPAddressString; /** * This class provides an implementation of {@link HeatBridgeApi} @@ -109,6 +119,8 @@ public class HeatBridgeImpl implements HeatBridgeApi { private String tenantId; private AaiHelper aaiHelper = new AaiHelper(); private CloudIdentity cloudIdentity; + private Environment env; + public HeatBridgeImpl(AAIResourcesClient resourcesClient, final CloudIdentity cloudIdentity, @Nonnull final String cloudOwner, @Nonnull final String cloudRegionId, @Nonnull final String regionId, @@ -124,7 +136,10 @@ public class HeatBridgeImpl implements HeatBridgeApi { this.regionId = regionId; this.tenantId = tenantId; this.resourcesClient = resourcesClient; - this.transaction = resourcesClient.beginSingleTransaction(); + if (resourcesClient != null) + this.transaction = resourcesClient.beginSingleTransaction(); + if (SpringContextHelper.getAppContext() != null) + this.env = SpringContextHelper.getAppContext().getEnvironment(); } public HeatBridgeImpl() { @@ -145,7 +160,7 @@ public class HeatBridgeImpl implements HeatBridgeApi { logger.trace("Keystone Version: {} ", keystoneVersion); this.osClient = new MsoCloudClientFactoryImpl(new OpenstackClientFactoryImpl()).getOpenstackClient( cloudIdentity.getIdentityUrl(), cloudIdentity.getMsoId(), cloudIdentity.getMsoPass(), regionId, - tenantId, keystoneVersion); + tenantId, keystoneVersion, cloudIdentity.getUserDomainName(), cloudIdentity.getProjectDomainName()); logger.trace("Successfully authenticated with keystone for tenant: {} and region: {}", tenantId, regionId); return osClient; } @@ -187,6 +202,16 @@ public class HeatBridgeImpl implements HeatBridgeApi { } @Override + public List<Network> getAllOpenstackProviderNetworks(final List<Resource> stackResources) { + Objects.requireNonNull(osClient, ERR_MSG_NULL_OS_CLIENT); + // Filter Openstack Compute resources + List<String> providerNetworkIds = + extractStackResourceIdsByResourceType(stackResources, HeatBridgeConstants.OS_NEUTRON_PROVIDERNET); + return providerNetworkIds.stream().map(providerNetworkId -> osClient.getNetworkById(providerNetworkId)) + .collect(Collectors.toList()); + } + + @Override public List<org.openstack4j.model.compute.Image> extractOpenstackImagesFromServers(final List<Server> servers) { Objects.requireNonNull(osClient, ERR_MSG_NULL_OS_CLIENT); return servers.stream().map(Server::getImage) @@ -200,6 +225,27 @@ public class HeatBridgeImpl implements HeatBridgeApi { .filter(distinctByProperty(org.openstack4j.model.compute.Flavor::getId)).collect(Collectors.toList()); } + public void buildAddNetworksToAaiAction(final String genericVnfId, final String vfModuleId, + List<Network> networks) { + networks.forEach(network -> { + L3Network l3Network = aaiHelper.buildNetwork(network); + if (l3Network != null) { + l3Network.setSubnets(buildSunets(network)); + + RelationshipList relationshipList = new RelationshipList(); + List<Relationship> relationships = relationshipList.getRelationship(); + + relationships.add(aaiHelper.getRelationshipToVfModule(genericVnfId, vfModuleId)); + relationships.add(aaiHelper.getRelationshipToTenant(cloudOwner, cloudRegionId, tenantId)); + + l3Network.setRelationshipList(relationshipList); + transaction.createIfNotExists( + AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3Network.getNetworkId()), + Optional.of(l3Network)); + } + }); + } + @Override public void buildAddImagesToAaiAction(final List<org.openstack4j.model.compute.Image> images) throws HeatBridgeException { @@ -246,24 +292,25 @@ public class HeatBridgeImpl implements HeatBridgeApi { // Build vserver relationships to: image, flavor, pserver, vf-module vserver.setRelationshipList( aaiHelper.getVserverRelationshipList(cloudOwner, cloudRegionId, genericVnfId, vfModuleId, server)); - transaction.create(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, cloudRegionId, - tenantId, vserver.getVserverId()), vserver); + transaction.createIfNotExists(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, + cloudRegionId, tenantId, vserver.getVserverId()), Optional.of(vserver)); }); } @Override public void buildAddVserverLInterfacesToAaiAction(final List<Resource> stackResources, - final List<String> oobMgtNetIds) { + final List<String> oobMgtNetIds, String cloudOwner) { Objects.requireNonNull(osClient, ERR_MSG_NULL_OS_CLIENT); List<String> portIds = extractStackResourceIdsByResourceType(stackResources, HeatBridgeConstants.OS_PORT_RESOURCE_TYPE); for (String portId : portIds) { Port port = osClient.getPortById(portId); + Network network = osClient.getNetworkById(port.getNetworkId()); LInterface lIf = new LInterface(); lIf.setInterfaceId(port.getId()); lIf.setInterfaceName(port.getName()); lIf.setMacaddr(port.getMacAddress()); - lIf.setNetworkName((String) port.getProfile().get("physical_network")); + lIf.setNetworkName(network.getName()); lIf.setIsPortMirrored(false); lIf.setIsIpUnnumbered(false); lIf.setInMaint(false); @@ -280,12 +327,16 @@ public class HeatBridgeImpl implements HeatBridgeApi { } } lIf.setL2Multicasting(isL2Multicast); + + transaction.createIfNotExists(AAIUriFactory.createResourceUri(AAIObjectType.L_INTERFACE, cloudOwner, + cloudRegionId, tenantId, port.getDeviceId(), lIf.getInterfaceName()), Optional.of(lIf)); + updateLInterfaceIps(port, lIf); - updateLInterfaceVlan(port, lIf); + if (cloudOwner.equals(env.getProperty("mso.cloudOwner.included", ""))) { + updateLInterfaceVlan(port, lIf); + } - // Update l-interface to the vserver - transaction.create(AAIUriFactory.createResourceUri(AAIObjectType.L_INTERFACE, cloudOwner, cloudRegionId, - tenantId, port.getDeviceId(), lIf.getInterfaceName()), lIf); + updateSriovPfToPserver(port, lIf); } } @@ -322,6 +373,20 @@ public class HeatBridgeImpl implements HeatBridgeApi { return pserverMap; } + private Subnets buildSunets(Network network) { + Subnets aaiSubnets = new Subnets(); + List<String> subnetIds = network.getSubnets(); + + subnetIds.forEach(subnetId -> { + Subnet subnet = osClient.getSubnetById(subnetId); + org.onap.aai.domain.yang.Subnet aaiSubnet = aaiHelper.buildSubnet(subnet); + if (aaiSubnet != null) { + aaiSubnets.getSubnet().add(aaiSubnet); + } + }); + return aaiSubnets; + } + private void createPServerIfNotExists(Map<String, Pserver> serverHostnames) { for (Pserver pserver : serverHostnames.values()) { AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, pserver.getHostname()); @@ -339,38 +404,35 @@ public class HeatBridgeImpl implements HeatBridgeApi { Vlan vlan = new Vlan(); Network network = osClient.getNetworkById(port.getNetworkId()); if (network.getNetworkType() != null && network.getNetworkType().equals(NetworkType.VLAN)) { - vlan.setVlanInterface(network.getName() + network.getProviderSegID()); - + vlan.setVlanInterface(port.getName() + network.getProviderSegID()); vlan.setVlanIdOuter(Long.parseLong(network.getProviderSegID())); vlan.setVlanIdInner(0L); vlan.setInMaint(false); vlan.setIsIpUnnumbered(false); vlan.setIsPrivate(false); - Vlans vlans = new Vlans(); - List<Vlan> vlanList = vlans.getVlan(); - vlanList.add(vlan); - lIf.setVlans(vlans); + + transaction + .createIfNotExists( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId()) + .lInterface(lIf.getInterfaceName()).vlan(vlan.getVlanInterface())), + Optional.of(vlan)); } - // Build sriov-vf to the l-interface + if (port.getvNicType() != null && port.getvNicType().equalsIgnoreCase(HeatBridgeConstants.OS_SRIOV_PORT_TYPE)) { - SriovVfs sriovVfs = new SriovVfs(); - // JAXB does not generate setters for list, however getter ensures its creation. - // Thus, all list manipulations must be made on live list. - List<SriovVf> sriovVfList = sriovVfs.getSriovVf(); SriovVf sriovVf = new SriovVf(); sriovVf.setPciId(port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString()); sriovVf.setNeutronNetworkId(port.getNetworkId()); - if (port.getVifDetails() != null) { - sriovVf.setVfVlanFilter((String) port.getVifDetails().get(HeatBridgeConstants.OS_VLAN_NETWORK_KEY)); - } + sriovVf.setVfVlanFilter("0"); sriovVf.setVfVlanAntiSpoofCheck(false); sriovVf.setVfMacAntiSpoofCheck(false); - sriovVfList.add(sriovVf); - - lIf.setSriovVfs(sriovVfs); - // For the given port create sriov-pf for host pserver/p-interface if absent - updateSriovPfToPserver(port, lIf); + transaction + .createIfNotExists( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId()) + .lInterface(lIf.getInterfaceName()).sriovVf(sriovVf.getPciId())), + Optional.of(sriovVf)); } } @@ -384,63 +446,82 @@ public class HeatBridgeImpl implements HeatBridgeApi { * @param lIf AAI l-interface object */ private void updateSriovPfToPserver(final Port port, final LInterface lIf) { - if (port.getProfile() == null || Strings - .isNullOrEmpty(port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString())) { - logger.debug("The SRIOV port:" + port.getName() + " is missing physical-network-id, cannot update " - + "sriov-pf object for host pserver: " + port.getHostId()); - return; - } - Optional<String> matchingPifName = HeatBridgeUtils.getMatchingPserverPifName( - port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString()); - if (matchingPifName.isPresent()) { - // Update l-interface description - String pserverHostName = port.getHostId(); - lIf.setInterfaceDescription("Attached to SR-IOV port: " + pserverHostName + "::" + matchingPifName.get()); - try { - Optional<PInterface> matchingPIf = resourcesClient.get(PInterface.class, - AAIUriFactory - .createResourceUri(AAIObjectType.P_INTERFACE, pserverHostName, matchingPifName.get()) - .depth(Depth.ONE)); - if (matchingPIf.isPresent()) { - SriovPfs pIfSriovPfs = matchingPIf.get().getSriovPfs(); - if (pIfSriovPfs == null) { - pIfSriovPfs = new SriovPfs(); - } - // Extract PCI-ID from OS port object - String pfPciId = port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString(); - - List<SriovPf> existingSriovPfs = pIfSriovPfs.getSriovPf(); - if (CollectionUtils.isEmpty(existingSriovPfs) || existingSriovPfs.stream() - .noneMatch(existingSriovPf -> existingSriovPf.getPfPciId().equals(pfPciId))) { - // Add sriov-pf object with PCI-ID to AAI - SriovPf sriovPf = new SriovPf(); - sriovPf.setPfPciId(pfPciId); - logger.debug("Queuing AAI command to update sriov-pf object to pserver: " + pserverHostName - + "/" + matchingPifName.get()); - transaction.create(AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF, pserverHostName, - matchingPifName.get(), sriovPf.getPfPciId()), sriovPf); + if (port.getvNicType().equalsIgnoreCase(HeatBridgeConstants.OS_SRIOV_PORT_TYPE)) { + if (port.getProfile() == null || Strings + .isNullOrEmpty(port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString())) { + logger.debug("The SRIOV port:" + port.getName() + " is missing physical-network-id, cannot update " + + "sriov-pf object for host pserver: " + port.getHostId()); + return; + } + Optional<String> matchingPifName = HeatBridgeUtils.getMatchingPserverPifName( + port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString()); + if (matchingPifName.isPresent()) { + // Update l-interface description + String pserverHostName = port.getHostId(); + lIf.setInterfaceDescription( + "Attached to SR-IOV port: " + pserverHostName + "::" + matchingPifName.get()); + try { + Optional<PInterface> matchingPIf = resourcesClient.get(PInterface.class, AAIUriFactory + .createResourceUri(AAIObjectType.P_INTERFACE, pserverHostName, matchingPifName.get()) + .depth(Depth.ONE)); + if (matchingPIf.isPresent()) { + SriovPfs pIfSriovPfs = matchingPIf.get().getSriovPfs(); + if (pIfSriovPfs == null) { + pIfSriovPfs = new SriovPfs(); + } + // Extract PCI-ID from OS port object + String pfPciId = port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString(); + + List<SriovPf> existingSriovPfs = pIfSriovPfs.getSriovPf(); + if (CollectionUtils.isEmpty(existingSriovPfs) || existingSriovPfs.stream() + .noneMatch(existingSriovPf -> existingSriovPf.getPfPciId().equals(pfPciId))) { + // Add sriov-pf object with PCI-ID to AAI + SriovPf sriovPf = new SriovPf(); + sriovPf.setPfPciId(pfPciId); + logger.debug("Queuing AAI command to update sriov-pf object to pserver: " + pserverHostName + + "/" + matchingPifName.get()); + + AAIResourceUri sriovPfUri = AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF, + pserverHostName, matchingPifName.get(), sriovPf.getPfPciId()); + + if (!resourcesClient.exists(sriovPfUri)) { + transaction.create(sriovPfUri, sriovPf); + + AAIResourceUri sriovVfUri = AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_VF, + cloudOwner, cloudRegionId, tenantId, port.getDeviceId(), lIf.getInterfaceName(), + port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString()); + + transaction.connect(sriovPfUri, sriovVfUri); + } + } } + } catch (WebApplicationException e) { + // Silently log that we failed to update the Pserver p-interface with PCI-ID + logger.error(LoggingAnchor.NINE, MessageEnum.GENERAL_EXCEPTION, pserverHostName, + matchingPifName.get(), cloudOwner, tenantId, "OpenStack", "Heatbridge", + ErrorCode.DataError.getValue(), "Exception - Failed to add sriov-pf object to pserver", e); } - } catch (WebApplicationException e) { - // Silently log that we failed to update the Pserver p-interface with PCI-ID - logger.error(LoggingAnchor.NINE, MessageEnum.GENERAL_EXCEPTION, pserverHostName, matchingPifName.get(), - cloudOwner, tenantId, "OpenStack", "Heatbridge", ErrorCode.DataError.getValue(), - "Exception - Failed to add sriov-pf object to pserver", e); } } } private void updateLInterfaceIps(final Port port, final LInterface lIf) { - List<L3InterfaceIpv4AddressList> lInterfaceIps = lIf.getL3InterfaceIpv4AddressList(); for (IP ip : port.getFixedIps()) { String ipAddress = ip.getIpAddress(); if (InetAddressValidator.getInstance().isValidInet4Address(ipAddress)) { + Subnet subnet = osClient.getSubnetById(ip.getSubnetId()); + IPAddressString cidr = new IPAddressString(subnet.getCidr()); L3InterfaceIpv4AddressList lInterfaceIp = new L3InterfaceIpv4AddressList(); lInterfaceIp.setL3InterfaceIpv4Address(ipAddress); lInterfaceIp.setNeutronNetworkId(port.getNetworkId()); lInterfaceIp.setNeutronSubnetId(ip.getSubnetId()); - lInterfaceIp.setL3InterfaceIpv4PrefixLength(32L); - lInterfaceIps.add(lInterfaceIp); + lInterfaceIp.setL3InterfaceIpv4PrefixLength(Long.parseLong(cidr.getNetworkPrefixLength().toString())); + + transaction.createIfNotExists( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId()) + .lInterface(lIf.getInterfaceName()).l3InterfaceIpv4AddressList(ipAddress)), + Optional.of(lInterfaceIp)); } } } @@ -462,27 +543,48 @@ public class HeatBridgeImpl implements HeatBridgeApi { Objects.requireNonNull(vnfId, "Null vnf-id!"); Objects.requireNonNull(vfModuleId, "Null vf-module-id!"); try { - Optional<VfModule> vfModule = resourcesClient.get(VfModule.class, - AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId).depth(Depth.ONE)); - logger.debug("vfModule is present: {}", vfModule.isPresent()); - if (vfModule.isPresent()) { - - AAIResultWrapper resultWrapper = new AAIResultWrapper(vfModule.get()); - Optional<Relationships> relationships = resultWrapper.getRelationships(); - logger.debug("relationships is present: {}", relationships.isPresent()); - if (relationships.isPresent()) { - List<AAIResourceUri> vserverUris = relationships.get().getRelatedUris(AAIObjectType.VSERVER); - logger.debug("vserverList isEmpty: {}", vserverUris.isEmpty()); - createTransactionToDeleteSriovPfFromPserver(vserverUris); - - if (!vserverUris.isEmpty()) { - for (AAIResourceUri vserverUri : vserverUris) { - logger.debug("Deleting Vservers: {}", vserverUri.toString()); + Optional<VfModule> vfModule = resourcesClient + .get(AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId).depth(Depth.ONE), + NotFoundException.class) + .asBean(VfModule.class); + + AAIResultWrapper resultWrapper = new AAIResultWrapper(vfModule.get()); + Optional<Relationships> relationships = resultWrapper.getRelationships(); + logger.debug("VfModule contains relationships in AAI: {}", relationships.isPresent()); + if (relationships.isPresent()) { + + List<AAIResourceUri> l3NetworkUris = relationships.get().getRelatedUris(AAIObjectType.L3_NETWORK); + logger.debug("L3Network contains {} relationships in AAI", l3NetworkUris.size()); + + if (!l3NetworkUris.isEmpty()) { + for (AAIResourceUri l3NetworkUri : l3NetworkUris) { + if (env.getProperty("heatBridgeDryrun", Boolean.class, true)) { + logger.debug("Would delete L3Network: {}", l3NetworkUri.build().toString()); + } else { + resourcesClient.delete(l3NetworkUri); + } + } + } + + List<AAIResourceUri> vserverUris = relationships.get().getRelatedUris(AAIObjectType.VSERVER); + logger.debug("VServer contains {} relationships in AAI", vserverUris.size()); + createTransactionToDeleteSriovPfFromPserver(vserverUris); + + if (!vserverUris.isEmpty()) { + for (AAIResourceUri vserverUri : vserverUris) { + if (env.getProperty("heatBridgeDryrun", Boolean.class, true)) { + logger.debug("Would delete Vserver: {}", vserverUri.build().toString()); + } else { resourcesClient.delete(vserverUri); } } } } + + } catch (NotFoundException e) { + String msg = "Failed to commit delete heatbridge data transaction"; + logger.debug(msg + " with error: " + e); + throw new HeatBridgeException(msg, e); } catch (Exception e) { String msg = "Failed to commit delete heatbridge data transaction"; logger.debug(msg + " with error: " + e); @@ -505,8 +607,16 @@ public class HeatBridgeImpl implements HeatBridgeApi { if (pciIds.contains(sriovPf.getPfPciId())) { logger.debug("creating transaction to delete SR-IOV PF: " + pIf.getInterfaceName() + " from PServer: " + pserverName); - resourcesClient.delete(AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF, - pserverName, pIf.getInterfaceName(), sriovPf.getPfPciId())); + if (env.getProperty("heatBridgeDryrun", Boolean.class, true)) { + logger.debug("Would delete Sriov Pf: {}", + AAIUriFactory + .createResourceUri(AAIObjectType.SRIOV_PF, pserverName, + pIf.getInterfaceName(), sriovPf.getPfPciId()) + .build().toString()); + } else { + resourcesClient.delete(AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF, + pserverName, pIf.getInterfaceName(), sriovPf.getPfPciId())); + } } })); } @@ -523,9 +633,10 @@ public class HeatBridgeImpl implements HeatBridgeApi { Vserver vserver = vserverWrapper.asBean(Vserver.class).get(); List<String> pciIds = HeatBridgeUtils.extractPciIdsFromVServer(vserver); if (CollectionUtils.isNotEmpty(pciIds)) { - List<String> matchingPservers = vserverRelationships.get().getRelatedLinks(AAIObjectType.PSERVER); + List<AAIResourceUri> matchingPservers = + vserverRelationships.get().getRelatedUris(AAIObjectType.PSERVER); if (matchingPservers != null && matchingPservers.size() == 1) { - pserverToPciIdMap.put(matchingPservers.get(0), pciIds); + pserverToPciIdMap.put(matchingPservers.get(0).getURIKeys().get("hostname"), pciIds); } } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java index fdf7ce38f1..71c6a96cd6 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java @@ -40,6 +40,7 @@ public class HeatBridgeConstants { public static final Integer OS_DEFAULT_HEAT_NESTING = 5; public static final String OS_SERVER_RESOURCE_TYPE = "OS::Nova::Server"; public static final String OS_PORT_RESOURCE_TYPE = "OS::Neutron::Port"; + public static final String OS_NEUTRON_PROVIDERNET = "OS::Neutron::ProviderNet"; public static final String OS_SRIOV_PORT_TYPE = "direct"; public static final String OS_PCI_SLOT_KEY = "pci_slot"; public static final String OS_PHYSICAL_NETWORK_KEY = "physical_network"; @@ -64,6 +65,8 @@ public class HeatBridgeConstants { public static final String AAI_VF_MODULE_ID = "vf-module.vf-module-id"; public static final String AAI_IMAGE = "image"; public static final String AAI_IMAGE_ID = "image.image-id"; + public static final String AAI_TENANT = "tenant"; + public static final String AAI_TENANT_ID = "tenant.tenant-id"; public static final String AAI_CLOUD_OWNER = "cloud-region.cloud-owner"; public static final String AAI_CLOUD_REGION_ID = "cloud-region.cloud-region-id"; public static final String AAI_FLAVOR = "flavor"; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java index a9a63b312d..3c209314f3 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java @@ -55,5 +55,5 @@ public interface MsoCloudClientFactory { OpenstackClient getOpenstackClient(String url, String msoId, String msoPass, String regionId, String tenantId, - String keystoneVersion) throws HeatBridgeException; + String keystoneVersion, String userDomainName, String projectDomainName) throws HeatBridgeException; } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java index 88a7d3dbbc..e299f6ffb8 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java @@ -64,21 +64,26 @@ public class MsoCloudClientFactoryImpl implements MsoCloudClientFactory { @Override public OpenstackClient getOpenstackClient(@Nonnull String url, @Nonnull String msoId, @Nonnull String msoPass, - @Nonnull String regionId, @Nonnull String tenantId, @Nonnull String keystoneVersion) - throws HeatBridgeException { + @Nonnull String regionId, @Nonnull String tenantId, @Nonnull String keystoneVersion, String userDomainName, + String projectDomainName) throws HeatBridgeException { Objects.requireNonNull(url, "Null openstack url!"); Objects.requireNonNull(msoId, "Null openstack user id!"); Objects.requireNonNull(msoPass, "Null openstack password!"); Objects.requireNonNull(regionId, "Null regionId ID!"); Objects.requireNonNull(tenantId, "Null tenant ID!"); - Objects.requireNonNull(tenantId, "Null keystone version"); + Objects.requireNonNull(keystoneVersion, "Null keystone version"); + if (userDomainName == null) { + userDomainName = HeatBridgeConstants.OS_DEFAULT_DOMAIN_NAME; + } + if (projectDomainName == null) { + projectDomainName = HeatBridgeConstants.OS_DEFAULT_DOMAIN_NAME; + } try { final OpenstackAccess osAccess = new OpenstackAccessBuilder().setBaseUrl(url) // keystone URL .setUser(msoId) // keystone username .setPassword(CryptoUtils.decryptCloudConfigPassword(msoPass)) // keystone decrypted password .setRegion(regionId) // openstack region - .setDomainName(HeatBridgeConstants.OS_DEFAULT_DOMAIN_NAME) // hardcode to "default" - .setTenantId(tenantId) // tenantId + .setDomainName(userDomainName).setProjectName(projectDomainName).setTenantId(tenantId) // tenantId .build(); // Identify the Keystone version diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java index 6817be8c49..7d4e92d9ad 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java @@ -42,6 +42,7 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.onap.aai.domain.yang.Flavor; import org.onap.aai.domain.yang.Image; +import org.onap.aai.domain.yang.L3Network; import org.onap.aai.domain.yang.PInterface; import org.onap.aai.domain.yang.Pserver; import org.onap.aai.domain.yang.Relationship; @@ -54,7 +55,9 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.so.heatbridge.constants.HeatBridgeConstants; import org.openstack4j.model.compute.Server; +import org.openstack4j.model.network.Network; import org.openstack4j.model.network.Port; +import org.openstack4j.model.network.Subnet; import com.google.common.base.Preconditions; /** @@ -131,6 +134,49 @@ public class AaiHelper { return relationshipList; } + public Relationship getRelationshipToVfModule(String vnfId, String vfModuleId) { + return buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId)); + } + + public Relationship getRelationshipToTenant(String cloudOwner, String cloudRegionId, String tenantId) { + return buildRelationship( + AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudOwner, cloudRegionId, tenantId)); + } + + public org.onap.aai.domain.yang.Subnet buildSubnet(Subnet subnet) { + org.onap.aai.domain.yang.Subnet aaiSubnet = new org.onap.aai.domain.yang.Subnet(); + aaiSubnet.setSubnetId(subnet.getId()); + aaiSubnet.setDhcpEnabled(subnet.isDHCPEnabled()); + + aaiSubnet.setSubnetName(subnet.getName()); + aaiSubnet.setGatewayAddress(subnet.getGateway()); + aaiSubnet.setCidrMask(subnet.getCidr()); + aaiSubnet.setIpVersion(subnet.getIpVersion().name()); + return aaiSubnet; + } + + public L3Network buildNetwork(Network network) { + if (network.getId() == null) { + return null; + } + L3Network l3Network = new L3Network(); + l3Network.setNetworkId(network.getId()); + l3Network.setIsBoundToVpn(true); + l3Network.setIsProviderNetwork(true); + + // optional fields + l3Network.setIsSharedNetwork(network.isShared()); + l3Network.setIsExternalNetwork(network.isRouterExternal()); + l3Network.setOperationalStatus(String.valueOf(network.isAdminStateUp())); + if (network.getName() != null) { + l3Network.setNetworkName(network.getName()); + } + if (network.getProviderPhyNet() != null) { + l3Network.setPhysicalNetworkName(network.getProviderPhyNet()); + } + return l3Network; + } + /** * Transform Openstack Server object to AAI Vserver object * @@ -145,7 +191,6 @@ public class AaiHelper { vserver.setVserverId(serverId); vserver.setVserverName(server.getName()); vserver.setVserverName2(server.getName()); - vserver.setProvStatus(server.getStatus().value()); server.getLinks().stream().filter(link -> link.getRel().equals(HeatBridgeConstants.OS_RESOURCES_SELF_LINK_KEY)) .findFirst().ifPresent(link -> vserver.setVserverSelflink(link.getHref())); return vserver; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackAccess.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackAccess.java index 69c76fad84..d8f2ee7273 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackAccess.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackAccess.java @@ -88,6 +88,10 @@ public class OpenstackAccess { return projectName; } + public Identifier getProjectNameIdentifier() { + return Identifier.byName(projectName); + } + public static class OpenstackAccessBuilder { private String baseUrl; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClient.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClient.java index 7184ec1e93..8d47ff4ceb 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClient.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClient.java @@ -42,6 +42,7 @@ import org.openstack4j.model.compute.Server; import org.openstack4j.model.heat.Resource; import org.openstack4j.model.network.Network; import org.openstack4j.model.network.Port; +import org.openstack4j.model.network.Subnet; public interface OpenstackClient { @@ -92,4 +93,12 @@ public interface OpenstackClient { * @return List of filtered Network objects */ List<Network> listNetworksByFilter(Map<String, String> filterParams); + + /** + * Get a subnet object by subnet ID + * + * @param subnetId Unique UUID of the subnet. + * @return Subnet object. + */ + Subnet getSubnetById(String subnetId); } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientImpl.java index 5a2b0732dc..1505203d7c 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientImpl.java @@ -45,6 +45,7 @@ import org.openstack4j.model.compute.Server; import org.openstack4j.model.heat.Resource; import org.openstack4j.model.network.Network; import org.openstack4j.model.network.Port; +import org.openstack4j.model.network.Subnet; abstract class OpenstackClientImpl implements OpenstackClient { @Override @@ -78,6 +79,11 @@ abstract class OpenstackClientImpl implements OpenstackClient { return (List<Network>) getClient().networking().network().list(filterParams); } + @Override + public Subnet getSubnetById(String subnetId) { + return getClient().networking().subnet().get(subnetId); + } + /** * Retrieves the specific client to utilize. * diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactoryImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactoryImpl.java index bbcd54e6f8..e2fa89bf39 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactoryImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactoryImpl.java @@ -60,10 +60,11 @@ public class OpenstackClientFactoryImpl implements OpenstackClientFactory { OSClientV3 client; try { + OSFactory.enableHttpLoggingFilter(true); client = OSFactory.builderV3().endpoint(osAccess.getUrl()) .credentials(osAccess.getUser(), osAccess.getPassword(), osAccess.getDomainNameIdentifier()) - .scopeToProject(Identifier.byId(osAccess.getTenantId())).authenticate() - .useRegion(osAccess.getRegion()); + .scopeToProject(Identifier.byId(osAccess.getTenantId()), osAccess.getProjectNameIdentifier()) + .authenticate().useRegion(osAccess.getRegion()); return new OpenstackV3ClientImpl(client); } catch (AuthenticationException exception) { throw new OpenstackClientException("Failed to authenticate with Keystone-v3: " + osAccess.getUrl(), @@ -81,6 +82,7 @@ public class OpenstackClientFactoryImpl implements OpenstackClientFactory { OSClientV2 client; try { + OSFactory.enableHttpLoggingFilter(true); client = OSFactory.builderV2().endpoint(osAccess.getUrl()) .credentials(osAccess.getUser(), osAccess.getPassword()).tenantId(osAccess.getTenantId()) .authenticate().useRegion(osAccess.getRegion()); diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AbstractAuditServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AbstractAuditServiceTest.java new file mode 100644 index 0000000000..c70e60e9d3 --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AbstractAuditServiceTest.java @@ -0,0 +1,51 @@ +package org.onap.so.adapters.tasks.audit; + +import org.junit.Test; +import org.onap.so.objects.audit.AAIObjectAudit; +import org.onap.so.objects.audit.AAIObjectAuditList; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class AbstractAuditServiceTest extends AbstractAuditService { + + private AAIObjectAuditList getAuditListWithObjectWithExistenceStateOf(boolean existenceState) { + AAIObjectAudit auditObject = new AAIObjectAudit(); + AAIObjectAuditList auditList = new AAIObjectAuditList(); + + auditObject.setDoesObjectExist(existenceState); + auditList.getAuditList().add(auditObject); + + return auditList; + } + + @Test + public void didCreateAuditFail_shouldReturnFalse_whenGivenNull() { + assertFalse(didCreateAuditFail(null)); + } + + @Test + public void didCreateAuditFail_shouldReturnTrue_whenGivenNotExistingObject() { + assertTrue(didCreateAuditFail(getAuditListWithObjectWithExistenceStateOf(false))); + } + + @Test + public void didCreateAuditFail_shouldReturnFalse_whenGivenExistingObject() { + assertFalse(didCreateAuditFail(getAuditListWithObjectWithExistenceStateOf(true))); + } + + @Test + public void didDeleteAuditFail_shouldReturnFalse_whenGivenNull() { + assertFalse(didDeleteAuditFail(null)); + } + + @Test + public void didDeleteAuditFail_shouldReturnTrue_whenGivenExistingObject() { + assertTrue(didDeleteAuditFail(getAuditListWithObjectWithExistenceStateOf(true))); + } + + @Test + public void didDeleteAuditFail_shouldReturnFalse_whenGivenNotExistingObject() { + assertFalse(didDeleteAuditFail(getAuditListWithObjectWithExistenceStateOf(false))); + } + +} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java index fd36995f3d..76e5bbc47f 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java @@ -1,10 +1,9 @@ package org.onap.so.adapters.tasks.audit; -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; +import static org.assertj.core.api.Assertions.assertThat; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -13,7 +12,6 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.Vserver; -import org.onap.so.adapters.tasks.audit.AuditDataService; import org.onap.so.audit.beans.AuditInventory; import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider; import org.onap.so.db.request.beans.RequestProcessingData; @@ -22,6 +20,7 @@ import org.onap.so.objects.audit.AAIObjectAudit; import org.onap.so.objects.audit.AAIObjectAuditList; import com.fasterxml.jackson.core.JsonProcessingException; + @RunWith(MockitoJUnitRunner.Silent.class) public class AuditDataServiceTest { @@ -56,9 +55,8 @@ public class AuditDataServiceTest { vserver.setVserverId("testVserverId"); audit.setAaiObject(vserver); auditList.getAuditList().add(audit); - GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider(); - String auditListString = objectMapper.getMapper().writeValueAsString(auditList);; + String auditListString = objectMapper.getMapper().writeValueAsString(auditList); RequestProcessingData requestProcessingData = new RequestProcessingData(); requestProcessingData.setSoRequestId(auditInventory.getMsoRequestId()); @@ -99,4 +97,17 @@ public class AuditDataServiceTest { "testVnfModuleId", "testVfModuleName1", "AuditStackData"); } + @Test + public void testGetStackDataToRequestDbWhenRequestProcessingDataListIsEmpty() throws Exception { + + Mockito.doReturn(new ArrayList<RequestProcessingData>()).when(requestsDbClient) + .getRequestProcessingDataByGroupingIdAndNameAndTag(Mockito.any(), Mockito.any(), Mockito.any()); + Optional<AAIObjectAuditList> result = auditDataService.getStackDataFromRequestDb(auditInventory); + Mockito.verify(requestsDbClient, Mockito.times(1)).getRequestProcessingDataByGroupingIdAndNameAndTag( + "testVnfModuleId", "testVfModuleName1", "AuditStackData"); + assertThat(result).isEmpty(); + + } + + } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditStackServiceDataTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditStackServiceDataTest.java index a10ab4b7df..78dbcd94c2 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditStackServiceDataTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditStackServiceDataTest.java @@ -179,13 +179,13 @@ public class AuditStackServiceDataTest extends AuditCreateStackService { @Test public void determineAuditResult_Test() throws Exception { - boolean actual = auditStackService.didCreateAuditFail(auditListOptSuccess); + boolean actual = auditStackService.didCreateAuditFail(auditListOptSuccess.get()); assertEquals(false, actual); } @Test public void determineAuditResult_Failure_Test() throws Exception { - boolean actual = auditStackService.didCreateAuditFail(auditListOptFailure); + boolean actual = auditStackService.didCreateAuditFail(auditListOptFailure.get()); assertEquals(true, actual); } } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java index 464a17d2a5..8c21e3f7f7 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java @@ -42,15 +42,18 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static org.mockito.Mockito.doReturn; import java.io.File; import java.io.IOException; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Objects; import java.util.Optional; +import java.util.Set; import org.apache.commons.io.FileUtils; import org.junit.Assert; import org.junit.Before; @@ -58,12 +61,13 @@ import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; +import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.LInterface; import org.onap.aai.domain.yang.PInterface; import org.onap.aai.domain.yang.SriovPf; -import org.onap.aai.domain.yang.Vserver; import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.AAIResourcesClient; import org.onap.aaiclient.client.aai.AAISingleTransactionClient; @@ -80,11 +84,15 @@ import org.openstack4j.model.compute.Image; import org.openstack4j.model.compute.Server; import org.openstack4j.model.compute.Server.Status; import org.openstack4j.model.heat.Resource; +import org.openstack4j.model.network.IP; +import org.openstack4j.model.network.IPVersionType; import org.openstack4j.model.network.Network; import org.openstack4j.model.network.NetworkType; import org.openstack4j.model.network.Port; +import org.openstack4j.model.network.Subnet; import org.openstack4j.openstack.heat.domain.HeatResource; import org.openstack4j.openstack.heat.domain.HeatResource.Resources; +import org.springframework.core.env.Environment; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableMap; @@ -104,16 +112,20 @@ public class HeatBridgeImplTest { @Mock private AAIResourcesClient resourcesClient; + @Mock private AAISingleTransactionClient transaction; - private HeatBridgeImpl heatbridge; + @Mock + private Environment env; + + @InjectMocks + private HeatBridgeImpl heatbridge = + new HeatBridgeImpl(resourcesClient, cloudIdentity, CLOUD_OWNER, REGION_ID, REGION_ID, TENANT_ID); @Before public void setUp() throws HeatBridgeException, OpenstackClientException, BulkProcessFailed { - when(resourcesClient.beginSingleTransaction()).thenReturn(transaction); - heatbridge = new HeatBridgeImpl(resourcesClient, cloudIdentity, CLOUD_OWNER, REGION_ID, REGION_ID, TENANT_ID); } @Ignore @@ -252,7 +264,7 @@ public class HeatBridgeImplTest { // Assert ArgumentCaptor<AAIResourceUri> captor = ArgumentCaptor.forClass(AAIResourceUri.class); - verify(transaction, times(2)).create(captor.capture(), any(Vserver.class)); + verify(transaction, times(2)).createIfNotExists(captor.capture(), any(Optional.class)); List<AAIResourceUri> uris = captor.getAllValues(); assertEquals(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, CLOUD_OWNER, REGION_ID, TENANT_ID, @@ -296,7 +308,7 @@ public class HeatBridgeImplTest { // Assert ArgumentCaptor<AAIResourceUri> captor = ArgumentCaptor.forClass(AAIResourceUri.class); - verify(transaction, times(2)).create(captor.capture(), any(Vserver.class)); + verify(transaction, times(2)).createIfNotExists(captor.capture(), any(Optional.class)); List<AAIResourceUri> uris = captor.getAllValues(); assertEquals(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, CLOUD_OWNER, REGION_ID, TENANT_ID, @@ -396,7 +408,6 @@ public class HeatBridgeImplTest { verify(transaction, times(2)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class)); } - @Ignore @Test public void testUpdateVserverLInterfacesToAai() throws HeatBridgeException { // Arrange @@ -408,7 +419,113 @@ public class HeatBridgeImplTest { when(port.getMacAddress()).thenReturn("78:4f:43:68:e2:78"); when(port.getNetworkId()).thenReturn("890a203a-23gg-56jh-df67-731656a8f13a"); when(port.getDeviceId()).thenReturn("test-device-id"); - when(port.getVifDetails()).thenReturn(ImmutableMap.of(HeatBridgeConstants.OS_VLAN_NETWORK_KEY, "2345")); + String pfPciId = "0000:08:00.0"; + when(port.getProfile()).thenReturn(ImmutableMap.of(HeatBridgeConstants.OS_PCI_SLOT_KEY, pfPciId, + HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY, "physical_network_id")); + + Network network = mock(Network.class); + when(network.getId()).thenReturn("test-network-id"); + when(network.getNetworkType()).thenReturn(NetworkType.VLAN); + when(network.getProviderSegID()).thenReturn("2345"); + + when(osClient.getPortById("212a203a-9764-4f42-84ea-731536a8f13a")).thenReturn(port); + when(osClient.getPortById("387e3904-8948-43d1-8635-b6c2042b54da")).thenReturn(port); + when(osClient.getPortById("70a09dfd-f1c5-4bc8-bd8f-dc539b8d662a")).thenReturn(port); + when(osClient.getPortById("12f88b4d-c8a4-4fbd-bcb4-7e36af02430b")).thenReturn(port); + when(osClient.getPortById("c54b9f45-b413-4937-bbe4-3c8a5689cfc9")).thenReturn(port); + when(osClient.getNetworkById(anyString())).thenReturn(network); + + SriovPf sriovPf = new SriovPf(); + sriovPf.setPfPciId(pfPciId); + PInterface pIf = mock(PInterface.class); + when(pIf.getInterfaceName()).thenReturn("test-port-id"); + when(resourcesClient.get(eq(PInterface.class), any(AAIResourceUri.class))).thenReturn(Optional.of(pIf)); + when(env.getProperty("mso.cloudOwner.included", "")).thenReturn("CloudOwner"); + + // Act + heatbridge.buildAddVserverLInterfacesToAaiAction(stackResources, Arrays.asList("1", "2"), "CloudOwner"); + + // Assert + verify(transaction, times(15)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class)); + verify(osClient, times(5)).getPortById(anyString()); + verify(osClient, times(10)).getNetworkById(anyString()); + } + + @Test + public void testUpdateNetworksToAai() throws HeatBridgeException { + + Subnet subnet1 = mock(Subnet.class); + when(subnet1.getId()).thenReturn("test-subnet1-id"); + when(subnet1.getName()).thenReturn("test-subnet1-name"); + when(subnet1.isDHCPEnabled()).thenReturn(true); + when(subnet1.getGateway()).thenReturn("test-subnet1-gateway"); + when(subnet1.getCidr()).thenReturn("test-subnet1-gateway"); + when(subnet1.getIpVersion()).thenReturn(IPVersionType.V4); + + Subnet subnet2 = mock(Subnet.class); + when(subnet2.getId()).thenReturn("test-subnet2-id"); + when(subnet2.getName()).thenReturn("test-subnet2-name"); + when(subnet2.isDHCPEnabled()).thenReturn(true); + when(subnet2.getGateway()).thenReturn("test-subnet1-gateway"); + when(subnet2.getCidr()).thenReturn("test-subnet1-gateway"); + when(subnet2.getIpVersion()).thenReturn(IPVersionType.V6); + + when(osClient.getSubnetById(subnet1.getId())).thenReturn(subnet1); + when(osClient.getSubnetById(subnet2.getId())).thenReturn(subnet2); + + List<String> subnetIds = Arrays.asList(subnet1.getId(), subnet2.getId()); + + // Arrange + Network network1 = mock(Network.class); + when(network1.getId()).thenReturn("test-network1-id"); + when(network1.isShared()).thenReturn(true); + when(network1.isRouterExternal()).thenReturn(true); + when(network1.isAdminStateUp()).thenReturn(true); + when(network1.getProviderPhyNet()).thenReturn("sriov-network1"); + when(network1.getName()).thenReturn("network1"); + when(network1.getSubnets()).thenReturn(subnetIds); + + Network network2 = mock(Network.class); + when(network2.getId()).thenReturn("test-network2-id"); + when(network2.isShared()).thenReturn(true); + when(network2.isRouterExternal()).thenReturn(true); + when(network2.isAdminStateUp()).thenReturn(true); + when(network2.getProviderPhyNet()).thenReturn("sriov-network2"); + when(network2.getName()).thenReturn("network2"); + when(network2.getSubnets()).thenReturn(subnetIds); + + String vnfId = "some-uuiid-of-the-vnf"; + String vfModuleId = "some-uuiid-of-the-vf-module"; + + Subnet subnet = mock(Subnet.class); + + List<Network> networks = Arrays.asList(network1, network2); + + // Act #1 + heatbridge.buildAddNetworksToAaiAction(vnfId, vfModuleId, networks); + + // Assert #1 + verify(transaction, times(2)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class)); + + // Act #2 + heatbridge.buildAddNetworksToAaiAction(vnfId, vfModuleId, networks); + + // Assert #2 + verify(transaction, times(4)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class)); + + } + + @Test + public void testUpdateVserverLInterfacesToAai_skipVlans() throws HeatBridgeException { + // Arrange + List<Resource> stackResources = (List<Resource>) extractTestStackResources(); + Port port = mock(Port.class); + when(port.getId()).thenReturn("test-port-id"); + when(port.getName()).thenReturn("test-port-name"); + when(port.getvNicType()).thenReturn(HeatBridgeConstants.OS_SRIOV_PORT_TYPE); + when(port.getMacAddress()).thenReturn("78:4f:43:68:e2:78"); + when(port.getNetworkId()).thenReturn("890a203a-23gg-56jh-df67-731656a8f13a"); + when(port.getDeviceId()).thenReturn("test-device-id"); String pfPciId = "0000:08:00.0"; when(port.getProfile()).thenReturn(ImmutableMap.of(HeatBridgeConstants.OS_PCI_SLOT_KEY, pfPciId, HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY, "physical_network_id")); @@ -432,10 +549,10 @@ public class HeatBridgeImplTest { when(resourcesClient.get(eq(PInterface.class), any(AAIResourceUri.class))).thenReturn(Optional.of(pIf)); // Act - heatbridge.buildAddVserverLInterfacesToAaiAction(stackResources, Arrays.asList("1", "2")); + heatbridge.buildAddVserverLInterfacesToAaiAction(stackResources, Arrays.asList("1", "2"), "CloudOwner"); // Assert - verify(transaction, times(5)).create(any(AAIResourceUri.class), any(LInterface.class)); + verify(transaction, times(5)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class)); verify(osClient, times(5)).getPortById(anyString()); verify(osClient, times(5)).getNetworkById(anyString()); } @@ -463,4 +580,6 @@ public class HeatBridgeImplTest { } return content; } + + } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java index 86400c2190..9b5e1e85cd 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java @@ -40,6 +40,8 @@ public class MsoCloudClientFactoryImplTest { private static final String ENCRYPTED_PASSWORD = CryptoUtils.encryptCloudConfigPassword("testPassword"); private static final String REGION_ID = "testCloudRegionId"; private static final String TENANT_ID = "testTenantId"; + private static final String USER_DOMAIN_NAME = "userDomainName"; + private static final String PROJECT_DOMAIN_NAME = "projectDomainName"; private MsoCloudClientFactoryImpl testedObject; private OpenstackClientFactory openstackClientFactoryMock; @@ -52,20 +54,21 @@ public class MsoCloudClientFactoryImplTest { @Test public void getOpenstackClientWithVersion2() throws Exception { - testedObject.getOpenstackClient(URL_V2, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID, "v2.0"); + testedObject.getOpenstackClient(URL_V2, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID, "v2.0", null, null); verify(openstackClientFactoryMock).createOpenstackV2Client(any(OpenstackAccess.class)); } @Test public void getOpenstackClientWithVersion3() throws Exception { - testedObject.getOpenstackClient(URL_V3, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID, "v3"); + testedObject.getOpenstackClient(URL_V3, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID, "v3", + USER_DOMAIN_NAME, PROJECT_DOMAIN_NAME); verify(openstackClientFactoryMock).createOpenstackV3Client(any(OpenstackAccess.class)); } @Test(expected = HeatBridgeException.class) public void getOpenstackClient_unsupportedVersion() throws Exception { testedObject.getOpenstackClient(URL_WITH_UNSUPPORTED_VERSION, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID, - "UNKNOWN"); + "UNKNOWN", USER_DOMAIN_NAME, PROJECT_DOMAIN_NAME); } } diff --git a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml index 42955c35c9..ac45f85711 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml +++ b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml @@ -64,8 +64,6 @@ mso: adapters: requestDb: endpoint: http://localhost:${wiremock.server.port} - audit: - lock-time: 240000 logPath: logs msb-ip: localhost msb-port: ${wiremock.server.port} diff --git a/adapters/mso-requests-db-adapter/.gitignore b/adapters/mso-requests-db-adapter/.gitignore index ae3c172604..9920c72893 100644 --- a/adapters/mso-requests-db-adapter/.gitignore +++ b/adapters/mso-requests-db-adapter/.gitignore @@ -1 +1,2 @@ /bin/ +/.apt_generated_tests/ diff --git a/adapters/mso-requests-db-adapter/pom.xml b/adapters/mso-requests-db-adapter/pom.xml index f9026d82c8..ca13895848 100644 --- a/adapters/mso-requests-db-adapter/pom.xml +++ b/adapters/mso-requests-db-adapter/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <groupId>org.onap.so.adapters</groupId> @@ -108,25 +108,58 @@ <artifactId>cxf-logging</artifactId> <version>${project.version}</version> </dependency> - </dependencies> + + </dependencies> + <pluginRepositories> + <pluginRepository> + <id>apache.snapshots</id> + <name>Maven Plugin Snapshots</name> + <url>http://repository.apache.org/snapshots/</url> + <snapshots> + <enabled>true</enabled> + </snapshots> + </pluginRepository> + </pluginRepositories> <build> <finalName>${project.artifactId}-${project.version}</finalName> <plugins> <plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-java2ws-plugin</artifactId> - <version>${cxf.version}</version> + <version>3.3.3</version> <dependencies> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> - <version>${cxf.version}</version> + <version>3.3.3</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-simple</artifactId> - <version>${cxf.version}</version> + <version>3.3.3</version> + </dependency> + + <dependency> + <groupId>com.sun.xml.ws</groupId> + <artifactId>jaxws-ri</artifactId> + <version>2.3.0</version> + <type>pom</type> + </dependency> + <dependency> + <groupId>javax.annotation</groupId> + <artifactId>javax.annotation-api</artifactId> + <version>1.3.2</version> + </dependency> + <dependency> + <groupId>javax.xml.bind</groupId> + <artifactId>jaxb-api</artifactId> + <version>2.4.0-b180725.0427</version> + </dependency> + <dependency> + <groupId>org.glassfish.jaxb</groupId> + <artifactId>jaxb-runtime</artifactId> + <version>2.4.0-b180725.0644</version> </dependency> </dependencies> <executions> @@ -137,6 +170,9 @@ <className>org.onap.so.adapters.requestsdb.MsoRequestsDbAdapter</className> <genWsdl>true</genWsdl> <verbose>true</verbose> + <ignoredDependencies> + <ignoredDependency>com.sun.xml.bind:jaxb-impl</ignoredDependency> + </ignoredDependencies> </configuration> <goals> <goal>java2ws</goal> @@ -169,9 +205,7 @@ <executions> <execution> <id>original</id> - <configuration> - <skip>false</skip> - </configuration> + <phase>package</phase> </execution> </executions> </plugin> @@ -181,6 +215,9 @@ <executions> <execution> <id>extract-docker-file</id> + <configuration> + <skip>false</skip> + </configuration> </execution> </executions> </plugin> @@ -243,7 +280,7 @@ </ignore> </action> </pluginExecution> - <pluginExecution> + <pluginExecution> <pluginExecutionFilter> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> diff --git a/adapters/mso-sdnc-adapter/.gitignore b/adapters/mso-sdnc-adapter/.gitignore new file mode 100644 index 0000000000..da7560e07f --- /dev/null +++ b/adapters/mso-sdnc-adapter/.gitignore @@ -0,0 +1 @@ +/.apt_generated_tests/ diff --git a/adapters/mso-sdnc-adapter/pom.xml b/adapters/mso-sdnc-adapter/pom.xml index f54c2ec568..808210389a 100644 --- a/adapters/mso-sdnc-adapter/pom.xml +++ b/adapters/mso-sdnc-adapter/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>mso-sdnc-adapter</artifactId> <properties> @@ -16,7 +16,7 @@ <build> <finalName>${project.artifactId}-${project.version}</finalName> - <pluginManagement> + <pluginManagement> <plugins> <plugin> <groupId>org.eclipse.m2e</groupId> @@ -70,9 +70,7 @@ <executions> <execution> <id>original</id> - <configuration> - <skip>false</skip> - </configuration> + <phase>package</phase> </execution> </executions> </plugin> @@ -86,6 +84,9 @@ <executions> <execution> <id>extract-docker-file</id> + <configuration> + <skip>false</skip> + </configuration> </execution> </executions> </plugin> @@ -133,6 +134,26 @@ <dependencies> <dependency> + <groupId>com.sun.activation</groupId> + <artifactId>javax.activation</artifactId> + <version>1.2.0</version> + </dependency> + <dependency> + <groupId>javax.xml.bind</groupId> + <artifactId>jaxb-api</artifactId> + <version>2.3.0</version> + </dependency> + <dependency> + <groupId>com.sun.xml.bind</groupId> + <artifactId>jaxb-core</artifactId> + <version>2.3.0</version> + </dependency> + <dependency> + <groupId>com.sun.xml.bind</groupId> + <artifactId>jaxb-impl</artifactId> + <version>2.3.0</version> + </dependency> + <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java index b8977f05d8..4ad32909b0 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java @@ -24,7 +24,6 @@ package org.onap.so.adapters.sdnc.impl; - import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.InputStream; @@ -65,7 +64,6 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; - @Component public class SDNCRestClient { @@ -153,10 +151,15 @@ public class SDNCRestClient { String basicAuth = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()); con.setRequestProperty("Authorization", basicAuth); con.setRequestMethod(rt.getReqMethod()); + String msoAction = rt.getMsoAction(); // Add request headers if ("POST".equals(rt.getReqMethod()) || "PUT".equals(rt.getReqMethod())) { - con.setRequestProperty("Content-type", "application/xml"); + if (Constants.MSO_ACTION_MDONS.equals(msoAction)) { + con.setRequestProperty("Content-type", "application/json"); + } else { + con.setRequestProperty("Content-type", "application/xml"); + } con.setRequestProperty("Content-length", String.valueOf(sdncReqBody.length())); con.setDoOutput(true); out = new DataOutputStream(con.getOutputStream()); diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/UtilsTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/UtilsTest.java deleted file mode 100644 index 4a3db26443..0000000000 --- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/UtilsTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.sdnc.impl; - -import static org.junit.Assert.assertEquals; -import java.io.File; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; -import org.junit.Test; -import org.onap.so.adapters.sdnc.SDNCAdapterRequest; -import org.w3c.dom.Document; -import org.w3c.dom.Node; - -public class UtilsTest { - - @Test - public final void testUnmarshal() { - - String expectedXml = - "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><feature-list xmlns=\"com:att:sdnctl:l3api\"><feature-type>FIREWALL-LITE</feature-type><feature-instance-id>mtjnj40evbc0eceb</feature-instance-id><feature-sub-type>SHARED</feature-sub-type><feature-instance-xpath>/restconf/config/Firewall-API:feature-model/feature-list/FIREWALL-LITE/mtjnj40evbc0eceb/</feature-instance-xpath> </feature-list>"; - - try { - - File file = new File("src/test/resources/sdncBpmnAdiodFirewallRequest.xml"); - JAXBContext jaxbContext = JAXBContext.newInstance(SDNCAdapterRequest.class); - - Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); - SDNCAdapterRequest request = (SDNCAdapterRequest) jaxbUnmarshaller.unmarshal(file); - - RequestTunables rt = new RequestTunables("0460ba40-60c8-4b07-8878-c8e8d87cde04-1527983610512", "", - "/L3SDN-API:services/layer3-service-list/MIS%2F1806%2F25057%2FSW_INTERNET/service-data/feature-list/FIREWALL-LITE/", - "put"); - - Node node = (Node) request.getRequestData(); - Document reqDoc = node.getOwnerDocument(); - String sdncReqBody = Utils.genSdncPutReq(reqDoc, rt); - assertEquals(sdncReqBody.replaceAll("[\\t\\n\\r]+", ""), expectedXml); - - } catch (JAXBException e) { - e.printStackTrace(); - } - - } - -} diff --git a/adapters/mso-vfc-adapter/pom.xml b/adapters/mso-vfc-adapter/pom.xml index 451831f966..a86dc94cf2 100644 --- a/adapters/mso-vfc-adapter/pom.xml +++ b/adapters/mso-vfc-adapter/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <groupId>org.onap.so.adapters</groupId> <artifactId>mso-vfc-adapter</artifactId> diff --git a/adapters/pom.xml b/adapters/pom.xml index 76b4a58af6..05d8b38dac 100644 --- a/adapters/pom.xml +++ b/adapters/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>so</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>adapters</artifactId> @@ -22,7 +22,6 @@ <module>mso-vfc-adapter</module> <module>mso-openstack-adapters</module> <module>etsi-sol003-adapter</module> - <module>etsi-sol002-adapter</module> <module>mso-nssmf-adapter</module> <module>so-appc-orchestrator</module> </modules> @@ -46,5 +45,11 @@ <artifactId>aai-client</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>com.sun.xml.ws</groupId> + <artifactId>jaxws-ri</artifactId> + <version>2.3.0</version> + <type>pom</type> + </dependency> </dependencies> </project> diff --git a/adapters/so-appc-orchestrator/pom.xml b/adapters/so-appc-orchestrator/pom.xml index f8d8fabcf7..2229c1a60b 100644 --- a/adapters/so-appc-orchestrator/pom.xml +++ b/adapters/so-appc-orchestrator/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <groupId>org.onap.so.adapters</groupId> @@ -13,7 +13,6 @@ <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - <java.version>1.8</java.version> </properties> <name>so-appc-orchestrator</name> <description>MSO APPC-C Orchestrator</description> @@ -40,6 +39,9 @@ <executions> <execution> <id>extract-docker-file</id> + <configuration> + <skip>false</skip> + </configuration> </execution> </executions> </plugin> @@ -54,19 +56,6 @@ </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>3.3</version> - <configuration> - <source>1.8</source> - <target>1.8</target> - <fork>true</fork> - <compilerArgs> - <arg>-parameters</arg> - </compilerArgs> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <executions> <execution> diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java index 20093be6a4..1da6fc096f 100644 --- a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java @@ -52,7 +52,6 @@ import org.onap.appc.client.lcm.model.ZULU; @Component public class ApplicationControllerClient { - @Autowired public Environment env; @@ -117,6 +116,7 @@ public class ApplicationControllerClient { controllerType = DEFAULT_CONTROLLER_TYPE; } controllerType = controllerType.toUpperCase(); + return AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class) .createLifeCycleManagerStateful(new ApplicationContext(), getLCMProperties(controllerType)); } catch (AppcClientException e) { @@ -128,7 +128,7 @@ public class ApplicationControllerClient { } public Status vnfCommand(Action action, String requestId, String vnfId, Optional<String> vserverId, - Optional<String> request, String controllerType, ApplicationControllerCallback listener) + Optional<String> request, String controllerType, ApplicationControllerCallback listener, String requestorId) throws ApplicationControllerOrchestratorException { this.setControllerType(controllerType); Status status; @@ -142,7 +142,7 @@ public class ApplicationControllerClient { payload = new Payload(request.get()); } - status = runCommand(action, actionIdentifiers, payload, requestId, listener); + status = runCommand(action, actionIdentifiers, payload, requestId, listener, requestorId); if (appCSupport.getCategoryOf(status).equals(StatusCategory.ERROR)) { throw new ApplicationControllerOrchestratorException(status.getMessage(), status.getCode()); } else { @@ -152,11 +152,11 @@ public class ApplicationControllerClient { public Status runCommand(Action action, org.onap.appc.client.lcm.model.ActionIdentifiers actionIdentifiers, - org.onap.appc.client.lcm.model.Payload payload, String requestID, ApplicationControllerCallback listener) - throws ApplicationControllerOrchestratorException { + org.onap.appc.client.lcm.model.Payload payload, String requestID, ApplicationControllerCallback listener, + String requestorId) throws ApplicationControllerOrchestratorException { Status status; Object requestObject; - requestObject = createRequest(action, actionIdentifiers, payload, requestID); + requestObject = createRequest(action, actionIdentifiers, payload, requestID, requestorId); appCSupport.logLCMMessage(requestObject); LifeCycleManagerStateful client = getAppCClient(); Method lcmMethod = appCSupport.getAPIMethod(action.name(), client, true); @@ -194,12 +194,13 @@ public class ApplicationControllerClient { return properties; } - public Object createRequest(Action action, ActionIdentifiers identifier, Payload payload, String requestId) { + public Object createRequest(Action action, ActionIdentifiers identifier, Payload payload, String requestId, + String requestorId) { Object requestObject = appCSupport.getInput(action.name()); try { - CommonHeader commonHeader = buildCommonHeader(requestId); + CommonHeader commonHeader = buildCommonHeader(requestId, requestorId); requestObject.getClass().getDeclaredMethod("setCommonHeader", CommonHeader.class).invoke(requestObject, commonHeader); requestObject.getClass().getDeclaredMethod("setAction", Action.class).invoke(requestObject, action); @@ -215,12 +216,13 @@ public class ApplicationControllerClient { return requestObject; } - private CommonHeader buildCommonHeader(String requestId) { + private CommonHeader buildCommonHeader(String requestId, String requestorId) { CommonHeader commonHeader = new CommonHeader(); commonHeader.setApiVer(API_VER); commonHeader.setOriginatorId(ORIGINATOR_ID); commonHeader.setRequestId(requestId == null ? UUID.randomUUID().toString() : requestId); commonHeader.setSubRequestId(UUID.randomUUID().toString()); + commonHeader.setXOnapRequestorid(requestorId); Flags flags = new Flags(); String flagsMode = "NORMAL"; Mode mode = Mode.valueOf(flagsMode); diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java index 8e38935441..e61053d043 100644 --- a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java @@ -111,7 +111,7 @@ public class ApplicationControllerTaskImpl { status = appcClient.vnfCommand(request.getAction(), msoRequestId, request.getApplicationControllerVnf().getVnfId(), vserverId, payload, request.getControllerType(), - listener); + listener, request.getRequestorId()); return status; } diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java index 82b0695ed9..cac8e9e16a 100644 --- a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java +++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java @@ -63,6 +63,7 @@ public class ApplicationControllerTaskImplITTest { @Before public void setup() { request = new ApplicationControllerTaskRequest(); + request.setRequestorId("testRequestorId"); request.setBookName("testBookName"); request.setControllerType("testControllerType"); request.setFileParameters("testFileParams"); diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java index ff979acf7b..fe2b4f84b5 100644 --- a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java +++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java @@ -52,6 +52,7 @@ public class ApplicationControllerTaskImplTest { request.setNewSoftwareVersion("2.0"); request.setExistingSoftwareVersion("1.0"); request.setOperationsTimeout("30"); + request.setRequestorId("testRequestorId"); Map<String, String> reqConfigParams = new HashMap<>(); reqConfigParams.put("name1", "value1"); reqConfigParams.put("name2", "value2"); @@ -77,13 +78,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(Action.HealthCheck, "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(Action.HealthCheck, "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @@ -99,13 +100,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -118,13 +119,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -133,13 +134,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), Optional.empty(), - "testControllerType", listener)).thenReturn(new Status()); + "testControllerType", listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), Optional.empty(), - "testControllerType", listener); + "testControllerType", listener, "testRequestorId"); } @Test @@ -154,13 +155,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -179,13 +180,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -204,13 +205,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -224,13 +225,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -251,13 +252,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test diff --git a/asdc-controller/.gitignore b/asdc-controller/.gitignore new file mode 100644 index 0000000000..da7560e07f --- /dev/null +++ b/asdc-controller/.gitignore @@ -0,0 +1 @@ +/.apt_generated_tests/ diff --git a/asdc-controller/pom.xml b/asdc-controller/pom.xml index e7e95481aa..1bd0389cba 100644 --- a/asdc-controller/pom.xml +++ b/asdc-controller/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>so</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <groupId>org.onap.so</groupId> @@ -15,7 +15,6 @@ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <antlr.version>4.7.1</antlr.version> - <java.version>1.8</java.version> <sdc.tosca.version>1.6.5</sdc.tosca.version> <jtosca.version>1.5.1</jtosca.version> </properties> @@ -54,7 +53,6 @@ <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> - <version>0.7.7.201606060606</version> <configuration> <excludes> <exclude>**/resource-examples/**</exclude> @@ -148,6 +146,9 @@ <executions> <execution> <id>extract-docker-file</id> + <configuration> + <skip>false</skip> + </configuration> </execution> </executions> </plugin> @@ -166,9 +167,7 @@ <executions> <execution> <id>original</id> - <configuration> - <skip>false</skip> - </configuration> + <phase>package</phase> </execution> </executions> </plugin> @@ -323,5 +322,9 @@ <artifactId>aai-client</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>javax.xml.ws</groupId> + <artifactId>jaxws-api</artifactId> + </dependency> </dependencies> </project> diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/WorkflowResourceTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/WorkflowResourceTest.java index 5a736217b7..4e8824344d 100644 --- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/WorkflowResourceTest.java +++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/WorkflowResourceTest.java @@ -124,6 +124,7 @@ public class WorkflowResourceTest extends BaseTest { workflow.setWorkflowActivitySpecSequence(wfss); workflowRepo.save(workflow); + assertNotNull(workflow); } diff --git a/bpmn/MSOCommonBPMN/pom.xml b/bpmn/MSOCommonBPMN/pom.xml index ec8ad3127c..c1c5bf0170 100644 --- a/bpmn/MSOCommonBPMN/pom.xml +++ b/bpmn/MSOCommonBPMN/pom.xml @@ -5,23 +5,17 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>bpmn</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>MSOCommonBPMN</artifactId> <name>MSOCommonBPMN</name> <packaging>jar</packaging> - <properties> - <maven.compiler.target>1.8</maven.compiler.target> - <maven.compiler.source>1.8</maven.compiler.source> - </properties> - <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>3.8.0</version> <configuration> <compilerId>groovy-eclipse-compiler</compilerId> </configuration> @@ -35,7 +29,7 @@ <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-eclipse-batch</artifactId> - <version>2.4.19-01</version> + <version>2.5.8-03</version> </dependency> </dependencies> </plugin> @@ -129,12 +123,13 @@ [1.3,) </versionRange> <goals> - <goal>run</goal> + <goal>execute</goal> </goals> </pluginExecutionFilter> <action> - <ignore> - </ignore> + <execute> + <runOnIncremental>true</runOnIncremental> + </execute> </action> </pluginExecution> </pluginExecutions> @@ -187,7 +182,7 @@ <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> - <version>1.9.3</version> + <version>1.9.4</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> @@ -205,7 +200,24 @@ </dependency> <dependency> <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-all</artifactId> + <artifactId>groovy</artifactId> + </dependency> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-xml</artifactId> + </dependency> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-json</artifactId> + </dependency> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-jsr223</artifactId> + </dependency> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-test</artifactId> + <scope>test</scope> </dependency> <dependency> <groupId>org.onap.so</groupId> @@ -318,7 +330,7 @@ <dependency> <groupId>uk.co.blackpepper.bowman</groupId> <artifactId>bowman-client</artifactId> - <version>0.3.0</version> + <version>${bowman.client.version}</version> </dependency> <dependency> <groupId>pl.pragmatists</groupId> diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericUtils.groovy index cc261a2750..bd713af006 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericUtils.groovy @@ -24,7 +24,6 @@ import org.apache.commons.lang3.StringUtils; class GenericUtils extends StringUtils{ - @Override public static boolean isBlank(final CharSequence cs) { int strLen; if (cs == null || (strLen = cs.length()) == 0 || cs.equals("null")) { diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy index d307a4e7bc..69dfacd9bc 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy @@ -56,7 +56,6 @@ import org.slf4j.LoggerFactory import javax.ws.rs.core.MediaType import javax.ws.rs.core.Response import javax.ws.rs.core.UriBuilder -import javax.xml.ws.http.HTTPException import static org.onap.so.bpmn.common.scripts.GenericUtils.* diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VidUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VidUtils.groovy index 1960cafb0f..14aefe1601 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VidUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VidUtils.groovy @@ -31,7 +31,6 @@ import org.onap.so.bpmn.core.xml.XmlTool import org.slf4j.Logger import org.slf4j.LoggerFactory - class VidUtils { private static final Logger logger = LoggerFactory.getLogger( VidUtils.class); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java index 3a4df68f02..963210b993 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java @@ -109,16 +109,20 @@ public class InstanceResourceList { } // check if the resource contains vf-module - if (vnfResource != null && vnfResource.getVfModules() != null) { + if (isVnfResourceWithVfModule(vnfResource)) { sequencedResourceList.addAll(vnfResource.getVfModules()); } return sequencedResourceList; } + private static boolean isVnfResourceWithVfModule(VnfResource vnfResource) { + return vnfResource != null && vnfResource.getVfModules() != null; + } + private static List<Resource> getGroupResourceInstanceList(VnfResource vnfResource, JsonObject vfObj) { List<Resource> sequencedResourceList = new ArrayList<>(); - if (vnfResource.getGroupOrder() != null && !StringUtils.isEmpty(vnfResource.getGroupOrder())) { + if (isVnfGroupOrderFilled(vnfResource)) { String[] grpSequence = vnfResource.getGroupOrder().split(","); for (String grpType : grpSequence) { for (GroupResource gResource : vnfResource.getGroups()) { @@ -150,4 +154,8 @@ public class InstanceResourceList { } return sequencedResourceList; } + + private static boolean isVnfGroupOrderFilled(VnfResource vnfResource) { + return vnfResource.getGroupOrder() != null && !StringUtils.isEmpty(vnfResource.getGroupOrder()); + } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/BuildingBlockBase.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/BuildingBlockBase.java new file mode 100644 index 0000000000..5be06f9be2 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/BuildingBlockBase.java @@ -0,0 +1,101 @@ +package org.onap.so.bpmn.servicedecomposition.entities; + +import java.io.Serializable; +import org.onap.so.serviceinstancebeans.RequestDetails; + +public abstract class BuildingBlockBase<T extends BuildingBlockBase<T>> implements Serializable { + + private static final long serialVersionUID = 4671883098039479717L; + + private Boolean aLaCarte; + private String apiVersion; + private Boolean isResume; + private String resourceId; + private String requestId; + private String requestAction; + private RequestDetails requestDetails; + private WorkflowResourceIds workflowResourceIds; + private String vnfType; + + public T setaLaCarte(Boolean aLaCarte) { + this.aLaCarte = aLaCarte; + return (T) this; + } + + public T setApiVersion(String apiVersion) { + this.apiVersion = apiVersion; + return (T) this; + } + + public T setResume(Boolean resume) { + isResume = resume; + return (T) this; + } + + public T setResourceId(String resourceId) { + this.resourceId = resourceId; + return (T) this; + } + + public T setRequestId(String requestId) { + this.requestId = requestId; + return (T) this; + } + + public T setRequestAction(String requestAction) { + this.requestAction = requestAction; + return (T) this; + } + + public T setRequestDetails(RequestDetails requestDetails) { + this.requestDetails = requestDetails; + return (T) this; + } + + public T setWorkflowResourceIds(WorkflowResourceIds workflowResourceIds) { + this.workflowResourceIds = workflowResourceIds; + return (T) this; + } + + public T setVnfType(String vnfType) { + this.vnfType = vnfType; + return (T) this; + } + + public Boolean isResume() { + return isResume; + } + + public String getRequestId() { + return requestId; + } + + public String getApiVersion() { + return apiVersion; + } + + public String getResourceId() { + return resourceId; + } + + public String getRequestAction() { + return requestAction; + } + + public Boolean isaLaCarte() { + return aLaCarte; + } + + public String getVnfType() { + return vnfType; + } + + public WorkflowResourceIds getWorkflowResourceIds() { + return workflowResourceIds; + } + + public RequestDetails getRequestDetails() { + return requestDetails; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java index abd301fa4d..e45811117c 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java @@ -23,20 +23,13 @@ package org.onap.so.bpmn.servicedecomposition.entities; import java.io.Serializable; import org.onap.so.serviceinstancebeans.RequestDetails; -public class ExecuteBuildingBlock implements Serializable { +public class ExecuteBuildingBlock extends BuildingBlockBase<ExecuteBuildingBlock> implements Serializable { - private static final long serialVersionUID = 2L; private BuildingBlock buildingBlock; - private String requestId; - private String apiVersion; - private String resourceId; - private String requestAction; - private String vnfType; - private Boolean aLaCarte; - private Boolean homing = false; - private WorkflowResourceIds workflowResourceIds; - private RequestDetails requestDetails; private ConfigurationResourceKeys configurationResourceKeys; + private Boolean homing = false; + private String oldVolumeGroupName; + private static final long serialVersionUID = 3L; public BuildingBlock getBuildingBlock() { return buildingBlock; @@ -47,60 +40,6 @@ public class ExecuteBuildingBlock implements Serializable { return this; } - public String getRequestId() { - return requestId; - } - - public ExecuteBuildingBlock setRequestId(String requestId) { - this.requestId = requestId; - return this; - } - - public String getApiVersion() { - return apiVersion; - } - - public ExecuteBuildingBlock setApiVersion(String apiVersion) { - this.apiVersion = apiVersion; - return this; - } - - public String getResourceId() { - return resourceId; - } - - public ExecuteBuildingBlock setResourceId(String resourceId) { - this.resourceId = resourceId; - return this; - } - - public String getRequestAction() { - return requestAction; - } - - public ExecuteBuildingBlock setRequestAction(String requestAction) { - this.requestAction = requestAction; - return this; - } - - public Boolean isaLaCarte() { - return aLaCarte; - } - - public ExecuteBuildingBlock setaLaCarte(Boolean aLaCarte) { - this.aLaCarte = aLaCarte; - return this; - } - - public String getVnfType() { - return vnfType; - } - - public ExecuteBuildingBlock setVnfType(String vnfType) { - this.vnfType = vnfType; - return this; - } - public Boolean isHoming() { return homing; } @@ -110,30 +49,21 @@ public class ExecuteBuildingBlock implements Serializable { return this; } - public WorkflowResourceIds getWorkflowResourceIds() { - return workflowResourceIds; - } - - public ExecuteBuildingBlock setWorkflowResourceIds(WorkflowResourceIds workflowResourceIds) { - this.workflowResourceIds = workflowResourceIds; - return this; - } - - public RequestDetails getRequestDetails() { - return requestDetails; + public ConfigurationResourceKeys getConfigurationResourceKeys() { + return configurationResourceKeys; } - public ExecuteBuildingBlock setRequestDetails(RequestDetails requestDetails) { - this.requestDetails = requestDetails; + public ExecuteBuildingBlock setConfigurationResourceKeys(ConfigurationResourceKeys configurationResourceKeys) { + this.configurationResourceKeys = configurationResourceKeys; return this; } - public ConfigurationResourceKeys getConfigurationResourceKeys() { - return configurationResourceKeys; + public String getOldVolumeGroupName() { + return oldVolumeGroupName; } - public ExecuteBuildingBlock setConfigurationResourceKeys(ConfigurationResourceKeys configurationResourceKeys) { - this.configurationResourceKeys = configurationResourceKeys; + public ExecuteBuildingBlock setOldVolumeGroupName(String oldVolumeGroupName) { + this.oldVolumeGroupName = oldVolumeGroupName; return this; } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java index e8be2734cc..508709e12c 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java @@ -41,14 +41,33 @@ public class WorkflowResourceIds implements Serializable { private String configurationId; private String instanceGroupId; + + public WorkflowResourceIds() { + super(); + } + + public WorkflowResourceIds(WorkflowResourceIds workflowResourceIds) { + this.serviceInstanceId = workflowResourceIds.serviceInstanceId; + this.pnfId = workflowResourceIds.pnfId; + this.vnfId = workflowResourceIds.vnfId; + this.networkId = workflowResourceIds.networkId; + this.volumeGroupId = workflowResourceIds.volumeGroupId; + this.vfModuleId = workflowResourceIds.vfModuleId; + this.networkCollectionId = workflowResourceIds.networkCollectionId; + this.configurationId = workflowResourceIds.configurationId; + this.instanceGroupId = workflowResourceIds.instanceGroupId; + } + + @Override public String toString() { return new ToStringBuilder(this).append("serviceInstanceId", serviceInstanceId).append("pnfId", pnfId) .append("vnfId", vnfId).append("networkId", networkId).append("volumeGroupId", volumeGroupId) .append("vfModuleId", vfModuleId).append("networkCollectionId", networkCollectionId) - .append("configurationId", configurationId).toString(); + .append("configurationId", configurationId).append("instanceGroupId", instanceGroupId).toString(); } + public String getServiceInstanceId() { return serviceInstanceId; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index bfa77212c4..e237462a1d 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -62,6 +62,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding; import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys; @@ -750,6 +751,10 @@ public class BBInputSetup implements JavaDelegate { parameter.getInstanceName(), generatedVnfType, parameter.getInstanceParams()); vnf.getVolumeGroups().add(volumeGroup); if (parameter.getIsReplace()) { + if (parameter.getExecuteBB().getOldVolumeGroupName() != null + && !parameter.getExecuteBB().getOldVolumeGroupName().isEmpty()) { + volumeGroup.setVolumeGroupName(parameter.getExecuteBB().getOldVolumeGroupName()); + } mapCatalogVolumeGroup(volumeGroup, parameter.getModelInfo(), parameter.getServiceModel().getNewService(), replaceVnfModelCustomizationUUID); } else { @@ -1547,7 +1552,7 @@ public class BBInputSetup implements JavaDelegate { } parameter.setApplicationId(applicationId); this.populateGenericVnf(parameter); - } else if (bbName.contains(PNF)) { + } else if (bbName.contains(PNF) || bbName.equals("ControllerExecutionBB")) { String pnfId = lookupKeyMap.get(ResourceKey.PNF); resources.getPnfs().stream() .filter(pnfs -> Objects.equals(key, pnfs.getModelInfo().getModelCustomizationId())).findFirst() @@ -1699,20 +1704,8 @@ public class BBInputSetup implements JavaDelegate { && bbName.equalsIgnoreCase(AssignFlows.SERVICE_INSTANCE.toString())) { throw new Exception("Request invalid missing: RequestInfo:InstanceName"); } else { - org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = null; - if (aLaCarte && bbName.equalsIgnoreCase(AssignFlows.SERVICE_INSTANCE.toString())) { - serviceInstanceAAI = bbInputSetupUtils - .getAAIServiceInstanceByName(requestDetails.getRequestInfo().getInstanceName(), customer); - } - if (serviceInstanceId != null && serviceInstanceAAI == null) { - if (customer != null && customer.getServiceSubscription() != null) { - serviceInstanceAAI = - bbInputSetupUtils.getAAIServiceInstanceByIdAndCustomer(customer.getGlobalCustomerId(), - customer.getServiceSubscription().getServiceType(), serviceInstanceId); - } else { - serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId); - } - } + org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI; + serviceInstanceAAI = getServiceInstanceAAI(requestDetails, customer, serviceInstanceId, aLaCarte, bbName); if (serviceInstanceAAI != null) { lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstanceId); return this.getExistingServiceInstance(serviceInstanceAAI); @@ -1722,6 +1715,25 @@ public class BBInputSetup implements JavaDelegate { } } + private org.onap.aai.domain.yang.ServiceInstance getServiceInstanceAAI(RequestDetails requestDetails, + Customer customer, String serviceInstanceId, boolean aLaCarte, String bbName) throws Exception { + org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = null; + if (aLaCarte && bbName.equalsIgnoreCase(AssignFlows.SERVICE_INSTANCE.toString())) { + serviceInstanceAAI = bbInputSetupUtils + .getAAIServiceInstanceByName(requestDetails.getRequestInfo().getInstanceName(), customer); + } + if (serviceInstanceId != null && serviceInstanceAAI == null) { + if (customer != null && customer.getServiceSubscription() != null) { + serviceInstanceAAI = + bbInputSetupUtils.getAAIServiceInstanceByIdAndCustomer(customer.getGlobalCustomerId(), + customer.getServiceSubscription().getServiceType(), serviceInstanceId); + } else { + serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId); + } + } + return serviceInstanceAAI; + } + protected ServiceInstance createServiceInstance(RequestDetails requestDetails, Project project, OwningEntity owningEntity, Map<ResourceKey, String> lookupKeyMap, String serviceInstanceId) { ServiceInstance serviceInstance = new ServiceInstance(); @@ -1833,17 +1845,17 @@ public class BBInputSetup implements JavaDelegate { AAIResultWrapper serviceInstanceWrapper = new AAIResultWrapper( new AAICommonObjectMapperProvider().getMapper().writeValueAsString(serviceInstanceAAI)); Optional<Relationships> relationshipsOp = serviceInstanceWrapper.getRelationships(); - Relationships relationships = null; if (relationshipsOp.isPresent()) { - relationships = relationshipsOp.get(); - } else { - return; + mapRelationship(serviceInstance, relationshipsOp.get()); } + } + private void mapRelationship(ServiceInstance serviceInstance, Relationships relationships) { this.mapProject(relationships.getByType(AAIObjectType.PROJECT), serviceInstance); this.mapOwningEntity(relationships.getByType(AAIObjectType.OWNING_ENTITY), serviceInstance); this.mapL3Networks(relationships.getRelatedAAIUris(AAIObjectType.L3_NETWORK), serviceInstance.getNetworks()); this.mapGenericVnfs(relationships.getRelatedAAIUris(AAIObjectType.GENERIC_VNF), serviceInstance.getVnfs()); + this.mapPnfs(relationships.getRelatedAAIUris(AAIObjectType.PNF), serviceInstance.getPnfs()); this.mapCollection(relationships.getByType(AAIObjectType.COLLECTION), serviceInstance); this.mapConfigurations(relationships.getRelatedAAIUris(AAIObjectType.CONFIGURATION), serviceInstance.getConfigurations()); @@ -1895,6 +1907,19 @@ public class BBInputSetup implements JavaDelegate { return genericVnf; } + protected void mapPnfs(List<AAIResourceUri> list, List<Pnf> pnfs) { + for (AAIResourceUri aaiResourceUri : list) { + pnfs.add(this.mapPnf(aaiResourceUri)); + } + } + + protected Pnf mapPnf(AAIResourceUri aaiResourceUri) { + AAIResultWrapper aaiPnfWrapper = this.bbInputSetupUtils.getAAIResourceDepthOne(aaiResourceUri); + Optional<org.onap.aai.domain.yang.Pnf> aaiPnfWrapperOp = + aaiPnfWrapper.asBean(org.onap.aai.domain.yang.Pnf.class); + return aaiPnfWrapperOp.map(pnf -> this.mapperLayer.mapAAIPnfIntoPnf(pnf)).orElse(null); + } + protected List<InstanceGroup> mapInstanceGroups(List<AAIResultWrapper> instanceGroups) { List<InstanceGroup> instanceGroupsList = new ArrayList<>(); for (AAIResultWrapper volumeGroupWrapper : instanceGroups) { @@ -1945,14 +1970,10 @@ public class BBInputSetup implements JavaDelegate { AAIResultWrapper lineOfBusinessWrapper = lineOfBusinesses.get(0); Optional<org.onap.aai.domain.yang.LineOfBusiness> aaiLineOfBusinessOp = lineOfBusinessWrapper.asBean(org.onap.aai.domain.yang.LineOfBusiness.class); - org.onap.aai.domain.yang.LineOfBusiness aaiLineOfBusiness = null; - if (!aaiLineOfBusinessOp.isPresent()) { - return; + if (aaiLineOfBusinessOp.isPresent()) { + LineOfBusiness lineOfBusiness = this.mapperLayer.mapAAILineOfBusiness(aaiLineOfBusinessOp.get()); + genericVnf.setLineOfBusiness(lineOfBusiness); } - aaiLineOfBusiness = aaiLineOfBusinessOp.get(); - - LineOfBusiness lineOfBusiness = this.mapperLayer.mapAAILineOfBusiness(aaiLineOfBusiness); - genericVnf.setLineOfBusiness(lineOfBusiness); } } @@ -1961,14 +1982,10 @@ public class BBInputSetup implements JavaDelegate { AAIResultWrapper platformWrapper = platforms.get(0); Optional<org.onap.aai.domain.yang.Platform> aaiPlatformOp = platformWrapper.asBean(org.onap.aai.domain.yang.Platform.class); - org.onap.aai.domain.yang.Platform aaiPlatform = null; - if (!aaiPlatformOp.isPresent()) { - return; + if (aaiPlatformOp.isPresent()) { + Platform platform = this.mapperLayer.mapAAIPlatform(aaiPlatformOp.get()); + genericVnf.setPlatform(platform); } - aaiPlatform = aaiPlatformOp.get(); - - Platform platform = this.mapperLayer.mapAAIPlatform(aaiPlatform); - genericVnf.setPlatform(platform); } } @@ -1977,34 +1994,36 @@ public class BBInputSetup implements JavaDelegate { AAIResultWrapper collectionWrapper = collections.get(0); Optional<org.onap.aai.domain.yang.Collection> aaiCollectionOp = collectionWrapper.asBean(org.onap.aai.domain.yang.Collection.class); - org.onap.aai.domain.yang.Collection aaiCollection = null; - if (!aaiCollectionOp.isPresent()) { - return; - } - aaiCollection = aaiCollectionOp.get(); - - Collection collection = this.mapperLayer.mapAAICollectionIntoCollection(aaiCollection); - NetworkCollectionResourceCustomization collectionResourceCust = bbInputSetupUtils - .getCatalogNetworkCollectionResourceCustByID(aaiCollection.getCollectionCustomizationId()); - collection.setModelInfoCollection(mapperLayer.mapCatalogCollectionToCollection(collectionResourceCust, - collectionResourceCust.getCollectionResource())); - Optional<Relationships> relationshipsOp = collectionWrapper.getRelationships(); - Relationships relationships = null; - if (relationshipsOp.isPresent()) { - relationships = relationshipsOp.get(); - } else { - serviceInstance.setCollection(collection); - return; - } - List<InstanceGroup> instanceGroupsList = - mapInstanceGroups(relationships.getByType(AAIObjectType.INSTANCE_GROUP)); - if (!instanceGroupsList.isEmpty()) { - collection.setInstanceGroup(instanceGroupsList.get(0)); - } - serviceInstance.setCollection(collection); + aaiCollectionOp.ifPresent( + collection -> serviceInstanceSetCollection(serviceInstance, collectionWrapper, collection)); } } + private void serviceInstanceSetCollection(ServiceInstance serviceInstance, AAIResultWrapper collectionWrapper, + org.onap.aai.domain.yang.Collection aaiCollection) { + Collection collection = getCollection(aaiCollection); + Optional<Relationships> relationshipsOp = collectionWrapper.getRelationships(); + relationshipsOp.ifPresent(relationships -> setInstanceGroupForCollection(collection, relationships)); + serviceInstance.setCollection(collection); + } + + private void setInstanceGroupForCollection(Collection collection, Relationships relationships) { + List<InstanceGroup> instanceGroupsList = + mapInstanceGroups(relationships.getByType(AAIObjectType.INSTANCE_GROUP)); + if (!instanceGroupsList.isEmpty()) { + collection.setInstanceGroup(instanceGroupsList.get(0)); + } + } + + private Collection getCollection(org.onap.aai.domain.yang.Collection aaiCollection) { + Collection collection = this.mapperLayer.mapAAICollectionIntoCollection(aaiCollection); + NetworkCollectionResourceCustomization collectionResourceCust = bbInputSetupUtils + .getCatalogNetworkCollectionResourceCustByID(aaiCollection.getCollectionCustomizationId()); + collection.setModelInfoCollection(mapperLayer.mapCatalogCollectionToCollection(collectionResourceCust, + collectionResourceCust.getCollectionResource())); + return collection; + } + protected void mapL3Networks(List<AAIResourceUri> list, List<L3Network> l3Networks) { for (AAIResourceUri aaiResourceUri : list) { l3Networks.add(this.mapL3Network(aaiResourceUri)); @@ -2080,14 +2099,10 @@ public class BBInputSetup implements JavaDelegate { AAIResultWrapper owningEntityWrapper = owningEntities.get(0); Optional<org.onap.aai.domain.yang.OwningEntity> aaiOwningEntityOp = owningEntityWrapper.asBean(org.onap.aai.domain.yang.OwningEntity.class); - org.onap.aai.domain.yang.OwningEntity aaiOwningEntity = null; - if (!aaiOwningEntityOp.isPresent()) { - return; + if (aaiOwningEntityOp.isPresent()) { + OwningEntity owningEntity = this.mapperLayer.mapAAIOwningEntity(aaiOwningEntityOp.get()); + serviceInstance.setOwningEntity(owningEntity); } - aaiOwningEntity = aaiOwningEntityOp.get(); - - OwningEntity owningEntity = this.mapperLayer.mapAAIOwningEntity(aaiOwningEntity); - serviceInstance.setOwningEntity(owningEntity); } } @@ -2096,14 +2111,10 @@ public class BBInputSetup implements JavaDelegate { AAIResultWrapper projectWrapper = projects.get(0); Optional<org.onap.aai.domain.yang.Project> aaiProjectOp = projectWrapper.asBean(org.onap.aai.domain.yang.Project.class); - org.onap.aai.domain.yang.Project aaiProject = null; - if (!aaiProjectOp.isPresent()) { - return; + if (aaiProjectOp.isPresent()) { + Project project = this.mapperLayer.mapAAIProject(aaiProjectOp.get()); + serviceInstance.setProject(project); } - aaiProject = aaiProjectOp.get(); - - Project project = this.mapperLayer.mapAAIProject(aaiProject); - serviceInstance.setProject(project); } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java index 67d073d7b6..2bb383e4ec 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java @@ -52,6 +52,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; @@ -323,6 +324,10 @@ public class BBInputSetupMapperLayer { return genericVnf; } + protected Pnf mapAAIPnfIntoPnf(org.onap.aai.domain.yang.Pnf aaiPnf) { + return modelMapper.map(aaiPnf, Pnf.class); + } + protected void mapAllLicensesIntoGenericVnf(org.onap.aai.domain.yang.GenericVnf aaiGenericVnf, GenericVnf genericVnf) { if (aaiGenericVnf.getLicenses() != null) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupPnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupPnf.java index 4379864bfe..68161a8dd5 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupPnf.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupPnf.java @@ -23,6 +23,7 @@ package org.onap.so.bpmn.servicedecomposition.tasks; import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf; import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.onap.so.serviceinstancebeans.Pnfs; @@ -36,6 +37,10 @@ final class BBInputSetupPnf { Pnf pnf = new Pnf(); pnf.setPnfId(pnfId); pnf.setPnfName(pnfs.getInstanceName()); + pnf.setModelInfoPnf(new ModelInfoPnf()); + pnf.getModelInfoPnf().setModelCustomizationUuid(pnfs.getModelInfo().getModelCustomizationId()); + pnf.getModelInfoPnf().setModelInvariantUuid(pnfs.getModelInfo().getModelInvariantId()); + pnf.getModelInfoPnf().setModelUuid(pnfs.getModelInfo().getModelVersionId()); pnf.setOrchestrationStatus(OrchestrationStatus.PRECREATED); serviceInstance.getPnfs().add(pnf); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java index 5a52e3a49d..4206596c94 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java @@ -104,7 +104,7 @@ public class ExecuteBuildingBlockRainyDay { handlingCode = "Abort"; } else { try { - if (gBBInput.getCustomer().getServiceSubscription() != null) { + if (gBBInput.getCustomer() != null && gBBInput.getCustomer().getServiceSubscription() != null) { serviceType = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0) .getModelInfoServiceInstance().getServiceType(); } @@ -119,7 +119,7 @@ public class ExecuteBuildingBlockRainyDay { String vnfType = ASTERISK; String vnfName = ASTERISK; try { - if (gBBInput.getCustomer().getServiceSubscription() != null) { + if (gBBInput.getCustomer() != null && gBBInput.getCustomer().getServiceSubscription() != null) { for (GenericVnf vnf : gBBInput.getCustomer().getServiceSubscription().getServiceInstances() .get(0).getVnfs()) { if (vnf.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { @@ -173,7 +173,7 @@ public class ExecuteBuildingBlockRainyDay { String serviceRole = ASTERISK; try { - if (gBBInput.getCustomer().getServiceSubscription() != null) { + if (gBBInput.getCustomer() != null && gBBInput.getCustomer().getServiceSubscription() != null) { serviceRole = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0) .getModelInfoServiceInstance().getServiceRole(); } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/CDSPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/CDSPropertiesImpl.java index 64c45653e1..2efd74ddc5 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/CDSPropertiesImpl.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/CDSPropertiesImpl.java @@ -80,4 +80,14 @@ public class CDSPropertiesImpl implements CDSProperties { public int getTimeout() { return Integer.parseInt(Objects.requireNonNull(UrnPropertiesReader.getVariable(TIMEOUT))); } + + @Override + public boolean getUseSSL() { + return false; + } + + @Override + public boolean getUseBasicAuth() { + return true; + } } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/InstnaceResourceListTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/InstnaceResourceListTest.java index f3233f2350..19e678d6b7 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/InstnaceResourceListTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/InstnaceResourceListTest.java @@ -8,6 +8,7 @@ import org.onap.so.bpmn.core.domain.Resource; import org.onap.so.bpmn.core.domain.ResourceType; import org.onap.so.bpmn.core.domain.VnfResource; import org.onap.so.bpmn.core.domain.VnfcResource; +import org.onap.so.bpmn.core.domain.ModuleResource; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; @@ -24,7 +25,7 @@ public class InstnaceResourceListTest { String uuiRequest = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "InstanceResourceList" + ".json"))); List<Resource> instanceResourceList = InstanceResourceList.getInstanceResourceList(createResourceSequence(), uuiRequest); - Assert.assertEquals(7, instanceResourceList.size()); + Assert.assertEquals(9, instanceResourceList.size()); Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(0).getResourceType()); Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(1).getResourceType()); Assert.assertEquals("device", instanceResourceList.get(1).getModelInfo().getModelName()); @@ -32,9 +33,12 @@ public class InstnaceResourceListTest { Assert.assertEquals("sitewan", instanceResourceList.get(2).getModelInfo().getModelName()); Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(3).getResourceType()); Assert.assertEquals("sitewan", instanceResourceList.get(3).getModelInfo().getModelName()); - Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(4).getResourceType()); - Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(5).getResourceType()); + Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(4).getResourceType()); + Assert.assertEquals("dummy", instanceResourceList.get(4).getModelInfo().getModelName()); + Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(5).getResourceType()); Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(6).getResourceType()); + Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(7).getResourceType()); + Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(8).getResourceType()); } // Test when PK is empty @@ -48,6 +52,63 @@ public class InstnaceResourceListTest { Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(0).getResourceType()); } + @Test + public void testSimpleVFResourceWithGroup() throws IOException { + String uuiRequest = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "InstanceResourceList" + ".json"))); + VnfResource vnfResource = new VnfResource(); + vnfResource.setResourceInput("{\"a\":\"ipaddress|127.0.0.1\"}"); + + createGroupKeyResource(vnfResource); + + List<Resource> instanceResourceList = InstanceResourceList.getInstanceResourceList(vnfResource, uuiRequest); + Assert.assertEquals(2, instanceResourceList.size()); + Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(0).getResourceType()); + Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(1).getResourceType()); + Assert.assertEquals("wan", instanceResourceList.get(1).getModelInfo().getModelName()); + } + + @Test + public void testVFResourceWithEmptyGroup() throws IOException { + String uuiRequest = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "InstanceResourceList" + ".json"))); + VnfResource vnfResource = new VnfResource(); + vnfResource.setResourceInput("{\"a\":\"[emptygroup_list2,INDEX,name]\"}"); + + List<Resource> instanceResourceList = InstanceResourceList.getInstanceResourceList(vnfResource, uuiRequest); + Assert.assertEquals(1, instanceResourceList.size()); + Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(0).getResourceType()); + } + + @Test + public void testVFResourceWithModule() throws IOException { + String uuiRequest = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "InstanceResourceList" + ".json"))); + VnfResource vnfResource = new VnfResource(); + vnfResource.setResourceInput("{\"a\":\"ipaddress|127.0.0.1\"}"); + + // Come from package org.onap.so.bpmn.core.domain.VnfResourceTest + List<ModuleResource> moduleResources; + moduleResources = new ArrayList<>(); + ModuleResource moduleresource = getModuleResource(); + moduleResources.add(moduleresource); + vnfResource.setModules(moduleResources); + + List<Resource> instanceResourceList = InstanceResourceList.getInstanceResourceList(vnfResource, uuiRequest); + Assert.assertEquals(2, instanceResourceList.size()); + Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(0).getResourceType()); + Assert.assertEquals(ResourceType.MODULE, instanceResourceList.get(1).getResourceType()); + } + + private ModuleResource getModuleResource() { + ModuleResource moduleresource = new ModuleResource(); + moduleresource.setVfModuleName("vfModuleName"); + moduleresource.setHeatStackId("heatStackId"); + moduleresource.setIsBase(true); + moduleresource.setVfModuleLabel("vfModuleLabel"); + moduleresource.setInitialCount(0); + moduleresource.setVfModuleType("vfModuleType"); + moduleresource.setHasVolumeGroup(true); + return moduleresource; + } + // Test when PK is not empty and PK does not contain any groups @Test public void testVFWithEmptyGroupResource() throws IOException { @@ -66,16 +127,7 @@ public class InstnaceResourceListTest { VnfResource vnfResource = new VnfResource(); vnfResource.setResourceInput("{\"a\":\"[emptygroup_list,INDEX,name]\"}"); - VnfcResource vnfcResource = new VnfcResource(); - vnfcResource.setResourceInput("{\"a\":\"test|default_value\"}"); - GroupResource groupResource = new GroupResource(); - groupResource.setVnfcs(Arrays.asList(vnfcResource)); - ModelInfo wanModel = new ModelInfo(); - wanModel.setModelName("wan"); - groupResource.setModelInfo(wanModel); - - vnfResource.setGroupOrder("wan"); - vnfResource.setGroups(Arrays.asList(groupResource)); + createGroupKeyResource(vnfResource); List<Resource> instanceResourceList = InstanceResourceList.getInstanceResourceList(vnfResource, uuiRequest); Assert.assertEquals(2, instanceResourceList.size()); @@ -84,29 +136,34 @@ public class InstnaceResourceListTest { Assert.assertEquals("wan", instanceResourceList.get(1).getModelInfo().getModelName()); } + private void createGroupKeyResource(VnfResource vnfResource) { + GroupResource groupResource = prepareGroupResource("{\"a\":\"test|default_value\"}", "wan"); + + vnfResource.setGroupOrder("wan"); + vnfResource.setGroups(Arrays.asList(groupResource)); + } + private VnfResource createResourceSequence() { VnfResource vnfResource = new VnfResource(); vnfResource.setResourceInput("{\"a\":\"[sdwansiteresource_list,INDEX,sdwansiteresource_list]\"}"); - VnfcResource vnfcResource = new VnfcResource(); - vnfcResource.setResourceInput("{\"a\":\"[sdwansitewan_list,INDEX,test]\"}"); + GroupResource groupResource = prepareGroupResource("{\"a\":\"[sdwansitewan_list,INDEX,test]\"}", "sitewan"); + GroupResource groupResource2 = prepareGroupResource("{\"a\":\"[sdwandevice_list,INDEX,test]\"}", "device"); + GroupResource groupDummyResource = prepareGroupResource("{\"a\":\"[dummy,INDEX,test]\"}", "dummy"); - GroupResource groupResource = new GroupResource(); - groupResource.setVnfcs(Arrays.asList(vnfcResource)); - ModelInfo wanModel = new ModelInfo(); - wanModel.setModelName("sitewan"); - groupResource.setModelInfo(wanModel); + vnfResource.setGroupOrder("device,sitewan,dummy"); + vnfResource.setGroups(Arrays.asList(groupResource, groupResource2, groupDummyResource)); + return vnfResource; + } + private GroupResource prepareGroupResource(String sourceInput, String modelName) { VnfcResource vnfcDeviceResource = new VnfcResource(); - vnfcDeviceResource.setResourceInput("{\"a\":\"[sdwandevice_list,INDEX,test]\"}"); - GroupResource groupResource2 = new GroupResource(); - groupResource2.setVnfcs(Arrays.asList(vnfcDeviceResource)); + vnfcDeviceResource.setResourceInput(sourceInput); + GroupResource groupResource = new GroupResource(); + groupResource.setVnfcs(Arrays.asList(vnfcDeviceResource)); ModelInfo deviceModel = new ModelInfo(); - deviceModel.setModelName("device"); - groupResource2.setModelInfo(deviceModel); - - vnfResource.setGroupOrder("device,sitewan"); - vnfResource.setGroups(Arrays.asList(groupResource, groupResource2)); - return vnfResource; + deviceModel.setModelName(modelName); + groupResource.setModelInfo(deviceModel); + return groupResource; } } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java index 13d2b7d3d3..4755e58582 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java @@ -39,6 +39,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; @@ -75,7 +76,6 @@ import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; -import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.VnfcCustomization; import org.onap.so.serviceinstancebeans.CloudConfiguration; import org.onap.so.serviceinstancebeans.RequestDetails; @@ -422,6 +422,17 @@ public class BBInputSetupMapperLayerTest { } @Test + public void testMapAAIPnfIntoPnf() throws IOException { + Pnf expected = mapper.readValue(new File(RESOURCE_PATH + "PnfExpected.json"), Pnf.class); + org.onap.aai.domain.yang.Pnf aaiPnf = + mapper.readValue(new File(RESOURCE_PATH + "aaiPnfInput.json"), org.onap.aai.domain.yang.Pnf.class); + + Pnf actual = bbInputSetupMapperLayer.mapAAIPnfIntoPnf(aaiPnf); + + assertThat(actual, sameBeanAs(expected)); + } + + @Test public void testMapAAICollectionIntoCollection() throws JsonParseException, JsonMappingException, IOException { org.onap.aai.domain.yang.Collection aaiCollection = mapper .readValue(new File(RESOURCE_PATH + "CollectionInput.json"), org.onap.aai.domain.yang.Collection.class); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupPnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupPnfTest.java index 0eef9cccd8..aa9943b9b1 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupPnfTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupPnfTest.java @@ -29,6 +29,7 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.db.catalog.beans.OrchestrationStatus; +import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.Pnfs; import static org.mockito.Mockito.doReturn; @@ -38,11 +39,22 @@ public class BBInputSetupPnfTest { @Mock private Pnfs pnfs; + @Mock + private ModelInfo modelInfo; + @Test public void populatePnfShouldSetRequiredFields() { final String pnfId = "PNF_id1"; final String pnfName = "PNF_name1"; + final String modelCustomizationId = "8421fe03-fd1b-4bf7-845a-c3fe91edb031"; + final String modelInvariantId = "3360a2a5-22ff-44c7-8935-08c8e5ecbd06"; + final String modelVersionId = "b80c3a52-abd4-436c-a22e-9c5da768781a"; + + doReturn(modelCustomizationId).when(modelInfo).getModelCustomizationId(); + doReturn(modelInvariantId).when(modelInfo).getModelInvariantId(); + doReturn(modelVersionId).when(modelInfo).getModelVersionId(); doReturn(pnfName).when(pnfs).getInstanceName(); + doReturn(modelInfo).when(pnfs).getModelInfo(); ServiceInstance serviceInstance = new ServiceInstance(); BBInputSetupPnf.populatePnfToServiceInstance(pnfs, pnfId, serviceInstance); @@ -53,6 +65,9 @@ public class BBInputSetupPnfTest { assertEquals(pnfId, pnf.getPnfId()); assertEquals(pnfName, pnf.getPnfName()); + assertEquals(modelCustomizationId, pnf.getModelInfoPnf().getModelCustomizationUuid()); + assertEquals(modelInvariantId, pnf.getModelInfoPnf().getModelInvariantUuid()); + assertEquals(modelVersionId, pnf.getModelInfoPnf().getModelUuid()); assertEquals(OrchestrationStatus.PRECREATED, pnf.getOrchestrationStatus()); } } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java index 458919c48e..dd79d2772f 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java @@ -69,6 +69,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; @@ -815,6 +816,26 @@ public class BBInputSetupTest { assertThat(actual, sameBeanAs(expected)); } + @Test + public void testGetServiceInstanceHelperCreateScenarioExistingWithName() throws Exception { + RequestDetails requestDetails = new RequestDetails(); + RequestInfo requestInfo = new RequestInfo(); + requestDetails.setRequestInfo(requestInfo); + ServiceSubscription serviceSub = new ServiceSubscription(); + Customer customer = new Customer(); + customer.setServiceSubscription(serviceSub); + ServiceInstance expected = new ServiceInstance(); + expected.setServiceInstanceId("serviceInstanceId"); + org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = new org.onap.aai.domain.yang.ServiceInstance(); + serviceInstanceAAI.setServiceInstanceId("serviceInstanceId"); + + doReturn(serviceInstanceAAI).when(SPY_bbInputSetupUtils).getAAIServiceInstanceByIdAndCustomer(Mockito.any(), + Mockito.any(), Mockito.any()); + ServiceInstance actual = SPY_bbInputSetup.getServiceInstanceHelper(requestDetails, customer, null, null, + new HashMap<>(), "SharansInstanceId", false, new Service(), "ActivateServiceInstanceBB"); + assertThat(actual, sameBeanAs(expected)); + } + @Test(expected = Exception.class) public void testGetServiceInstanceHelperCreateScenarioExistingNoNameButWithIdExceptionThrown() throws Exception { RequestDetails requestDetails = new RequestDetails(); @@ -1795,6 +1816,29 @@ public class BBInputSetupTest { } @Test + public void testMapPnfs() throws JsonProcessingException { + org.onap.aai.domain.yang.Pnf expectedAAI = new org.onap.aai.domain.yang.Pnf(); + org.onap.aai.domain.yang.RelationshipList relationshipList = new org.onap.aai.domain.yang.RelationshipList(); + org.onap.aai.domain.yang.Relationship relationship = new org.onap.aai.domain.yang.Relationship(); + relationshipList.getRelationship().add(relationship); + expectedAAI.setRelationshipList(relationshipList); + + Pnf expected = new Pnf(); + AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.PNF, "pnfId"); + AAIResultWrapper pnfWrapper = + new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI)); + + doReturn(pnfWrapper).when(SPY_bbInputSetupUtils).getAAIResourceDepthOne(aaiResourceUri); + doReturn(expected).when(bbInputSetupMapperLayer).mapAAIPnfIntoPnf(isA(org.onap.aai.domain.yang.Pnf.class)); + + List<Pnf> pnfs = new ArrayList<>(); + + SPY_bbInputSetup.mapPnfs(Arrays.asList(aaiResourceUri), pnfs); + + assertEquals(expected, pnfs.get(0)); + } + + @Test public void testMapVolumeGroups() throws JsonProcessingException { org.onap.aai.domain.yang.VolumeGroup expectedAAI = new org.onap.aai.domain.yang.VolumeGroup(); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/avpn/dmaap/beans/AVPNDmaapBeansTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/avpn/dmaap/beans/AVPNDmaapBeansTest.java index cb0d31b8ff..61a006f3f0 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/avpn/dmaap/beans/AVPNDmaapBeansTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/avpn/dmaap/beans/AVPNDmaapBeansTest.java @@ -45,6 +45,7 @@ public class AVPNDmaapBeansTest extends BaseTest { public void ensureExpectedPojoCount() { List<PojoClass> pojoClasses = PojoClassFactory.getPojoClasses(POJO_PACKAGE, new FilterPackageInfo()); Affirm.affirmEquals("Classes added / removed?", EXPECTED_CLASS_COUNT, pojoClasses.size()); + assertNotNull(pojoClasses); } @Test diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/PnfExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/PnfExpected.json new file mode 100644 index 0000000000..460f72aa31 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/PnfExpected.json @@ -0,0 +1,8 @@ +{ + "pnf-id":"pnfId", + "pnf-name":"pnfName", + "nf-role":"gNB", + "orchestration-status":"INVENTORIED", + "cloud-region":null, + "model-info-pnf":null +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiPnfInput.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiPnfInput.json new file mode 100644 index 0000000000..da0039c923 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiPnfInput.json @@ -0,0 +1,38 @@ +{ + "pnfName":"pnfName", + "pnfName2":null, + "selflink":null, + "pnfName2Source":null, + "pnfId":"pnfId", + "nfNamingCode":null, + "equipType":null, + "equipVendor":null, + "equipModel":null, + "managementOption":null, + "orchestrationStatus":"INVENTORIED", + "ipaddressV4Oam":null, + "swVersion":null, + "inMaint":null, + "frameId":null, + "serialNumber":null, + "ipaddressV4Loopback0":null, + "ipaddressV6Loopback0":null, + "ipaddressV4Aim":null, + "ipaddressV6Aim":null, + "ipaddressV6Oam":null, + "invStatus":null, + "resourceVersion":null, + "provStatus":null, + "nfRole":"gNB", + "adminStatus":null, + "operationalStatus":null, + "modelCustomizationId":null, + "modelInvariantId":null, + "modelVersionId":null, + "pnfIpv4Address":null, + "pnfIpv6Address":null, + "softwareVersions":null, + "relationshipList":null, + "lagInterfaces":null, + "vrfs":null +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/InstanceResourceList/InstanceResourceList.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/InstanceResourceList/InstanceResourceList.json index a111ae2646..cf0f2d1933 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/InstanceResourceList/InstanceResourceList.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/InstanceResourceList/InstanceResourceList.json @@ -80,6 +80,9 @@ "portNumer":"0/0/1" } ], + "emptygroup_list2": [ + + ], "sdwanvpnresource_list":[ { "sdwanvpn_topology":"hub_spoke", @@ -155,7 +158,8 @@ "class":"VNF", "systemIp":"20.20.20.1" } - ] + ], + "dummy":"" }, { "sdwansite_emails":"chenchuanyu@huawei.com", @@ -192,7 +196,8 @@ "class":"PNF", "systemIp":"20.20.20.2" } - ] + ], + "dummy":"" } ] } diff --git a/bpmn/MSOCoreBPMN/pom.xml b/bpmn/MSOCoreBPMN/pom.xml index 47254e75f2..5285e4e79f 100644 --- a/bpmn/MSOCoreBPMN/pom.xml +++ b/bpmn/MSOCoreBPMN/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>bpmn</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>MSOCoreBPMN</artifactId> @@ -76,11 +76,6 @@ <version>${camunda.version}</version> </dependency> <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-all</artifactId> - <scope>compile</scope> - </dependency> - <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>test</scope> diff --git a/bpmn/mso-infrastructure-bpmn/.gitignore b/bpmn/mso-infrastructure-bpmn/.gitignore new file mode 100644 index 0000000000..da7560e07f --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/.gitignore @@ -0,0 +1 @@ +/.apt_generated_tests/ diff --git a/bpmn/mso-infrastructure-bpmn/pom.xml b/bpmn/mso-infrastructure-bpmn/pom.xml index a3d0dd50b3..b621853f2b 100644 --- a/bpmn/mso-infrastructure-bpmn/pom.xml +++ b/bpmn/mso-infrastructure-bpmn/pom.xml @@ -3,7 +3,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>bpmn</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>mso-infrastructure-bpmn</artifactId> @@ -131,9 +131,7 @@ </execution> <execution> <id>original</id> - <configuration> - <skip>false</skip> - </configuration> + <phase>package</phase> </execution> </executions> </plugin> @@ -158,6 +156,9 @@ <executions> <execution> <id>extract-docker-file</id> + <configuration> + <skip>false</skip> + </configuration> </execution> </executions> </plugin> @@ -335,12 +336,16 @@ <dependency> <groupId>org.onap.aaf.authz</groupId> <artifactId>aaf-cadi-aaf</artifactId> - <version>2.1.9</version> + <version>${aaf.cadi.version}</version> <exclusions> <exclusion> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> </exclusion> + <exclusion> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + </exclusion> </exclusions> </dependency> </dependencies> diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationService.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationService.java new file mode 100644 index 0000000000..58d0c6d374 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationService.java @@ -0,0 +1,111 @@ +package org.onap.so.bpmn.common.workflow.service; + +import java.util.ArrayList; +import java.util.List; +import org.camunda.bpm.engine.ProcessEngine; +import org.camunda.bpm.engine.RepositoryService; +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.migration.MigrationInstruction; +import org.camunda.bpm.engine.migration.MigrationPlan; +import org.camunda.bpm.engine.migration.MigrationPlanExecutionBuilder; +import org.camunda.bpm.engine.repository.ProcessDefinition; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.camunda.bpm.engine.runtime.ProcessInstanceQuery; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.event.EventListener; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Service; + +@Service +public class AutoProcessInstanceMigrationService { + + private static Logger logger = LoggerFactory.getLogger(AutoProcessInstanceMigrationService.class); + + @Autowired + private Environment env; + @Autowired + protected ProcessEngine processEngine; + + @Value("${migration.autoMigrationEnabled:false}") + private boolean autoMigrationEnabled; + + private RuntimeService runtimeService; + private RepositoryService repositoryService; + private List<String> processDefinitionKeys; + + @EventListener(ApplicationReadyEvent.class) + protected void executeAutoProcessInstanceMigrations() { + if (autoMigrationEnabled) { + runtimeService = processEngine.getRuntimeService(); + repositoryService = processEngine.getRepositoryService(); + for (ProcessDefinition definition : getProcessDefinitions()) { + for (ProcessDefinition procDefOld : getOldProcessDefinitions(definition.getKey(), + definition.getVersion())) { + migrate(procDefOld.getId(), definition.getId()); + } + } + } + } + + protected List<ProcessDefinition> getProcessDefinitions() { + + List<ProcessDefinition> processDefinitions = new ArrayList<ProcessDefinition>(); + processDefinitionKeys = env.getProperty("migration.processDefinitionKeys", List.class, new ArrayList<String>()); + for (String key : processDefinitionKeys) { + processDefinitions.add(repositoryService.createProcessDefinitionQuery().processDefinitionKey(key) + .latestVersion().singleResult()); + } + return processDefinitions; + } + + private void migrate(String sourceProcessDefinitionId, String targetProcessDefinitionId) { + MigrationPlan migrationPlan = + runtimeService.createMigrationPlan(sourceProcessDefinitionId, targetProcessDefinitionId) + .mapEqualActivities().updateEventTriggers().build(); + List<String> activityIds = new ArrayList<>(); + + for (MigrationInstruction instruction : migrationPlan.getInstructions()) { + activityIds.add(instruction.getSourceActivityId()); + } + for (String activityId : activityIds) { + ProcessInstanceQuery activeProcessInstancesQuery = runtimeService.createProcessInstanceQuery() + .processDefinitionId(sourceProcessDefinitionId).activityIdIn(activityId).active(); + if (!activeProcessInstancesQuery.list().isEmpty()) { + logger.info("Migrating {} process instance(s) from {} to {}", + Long.valueOf(activeProcessInstancesQuery.count()), sourceProcessDefinitionId, + targetProcessDefinitionId); + MigrationPlanExecutionBuilder migration = + runtimeService.newMigration(migrationPlan).processInstanceQuery(activeProcessInstancesQuery); + migration.executeAsync(); + } + } + suspendEmptyProcessDefinition(sourceProcessDefinitionId); + } + + private void suspendEmptyProcessDefinition(String sourceProcessDefinitionId) { + List<ProcessInstance> activeProcessInstances = runtimeService.createProcessInstanceQuery() + .processDefinitionId(sourceProcessDefinitionId).active().list(); + if (activeProcessInstances.isEmpty()) { + repositoryService.suspendProcessDefinitionById(sourceProcessDefinitionId); + } else { + logger.info("Unable to migrate {} process instance(s) from {}", + Integer.valueOf(activeProcessInstances.size()), sourceProcessDefinitionId); + } + } + + protected List<ProcessDefinition> getOldProcessDefinitions(String key, int version) { + List<ProcessDefinition> processDefinitions = + repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).list(); + List<ProcessDefinition> oldProcessDefinitions = new ArrayList<>(); + for (ProcessDefinition processDef : processDefinitions) { + if (!processDef.isSuspended() && (processDef.getVersion() != version)) { + oldProcessDefinitions.add(processDef); + } + } + return oldProcessDefinitions; + } +} diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java index 4fb63651eb..2d41eb4e26 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java @@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.core.env.Environment; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -68,6 +69,7 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { private static final WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance(); long workflowPollInterval = 1000; + private static final String ASYNC_WAIT_TIME = "mso.workflow.async.waitTime"; @Autowired private WorkflowProcessor processor; @@ -75,6 +77,9 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { @Autowired private WorkflowContextHolder workflowContext; + @Autowired + private Environment env; + public void setProcessor(WorkflowProcessor processor) { this.processor = processor; } @@ -119,7 +124,7 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { protected WorkflowResponse waitForResponse(Map<String, Object> inputVariables) throws Exception { String requestId = getRequestId(inputVariables); long currentWaitTime = 0; - long waitTime = getWaitTime(inputVariables); + long waitTime = getWaitTime(); logger.debug("WorkflowAsyncResource.waitForResponse using timeout: " + waitTime); while (waitTime > currentWaitTime) { Thread.sleep(workflowPollInterval); @@ -185,18 +190,8 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { * @param inputVariables * @return */ - private long getWaitTime(Map<String, Object> inputVariables) { - String timeout = inputVariables.get("mso-service-request-timeout") == null ? null - : inputVariables.get("mso-service-request-timeout").toString(); - - if (timeout != null) { - try { - return Long.parseLong(timeout) * 1000; - } catch (NumberFormatException nex) { - logger.debug("Invalid input for mso-service-request-timeout"); - } - } - return DEFAULT_WAIT_TIME; + private long getWaitTime() { + return env.getProperty(ASYNC_WAIT_TIME, Long.class, new Long(DEFAULT_WAIT_TIME)); } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml b/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml index 1ad95b3ab9..e08cf0f578 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml +++ b/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml @@ -5,6 +5,7 @@ server: mso: infra: auditInventory: false + camundaAuth: AE2E9BE6EF9249085AF98689C4EE087736A5500629A72F35068FFB88813A023581DD6E765071F1C04075B36EA4213A spring: datasource: hikari: @@ -42,3 +43,9 @@ management: prometheus: enabled: true # Whether exporting of metrics to Prometheus is enabled. step: 1m # Step size (i.e. reporting frequency) to use. +org: + onap: + so: + adapters: + network: + encryptionKey: 07a7159d3bf51a0e53be7a8f89699be7 diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingIT.java index c128f58103..089d034efc 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingIT.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingIT.java @@ -20,6 +20,7 @@ package org.onap.so.bpmn.common; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.onap.so.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogDataByModelUuid; @@ -530,6 +531,7 @@ public class OofHomingIT extends BaseIntegrationTest { .contains("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback " + "Response contains error: Unable to find any candidate for demand *** Response:"); assert (errorMatch); + assertNotNull(businessKey); } @Test diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationServiceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationServiceTest.java new file mode 100644 index 0000000000..36e828448d --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationServiceTest.java @@ -0,0 +1,124 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.common.workflow.service; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.doReturn; +import java.util.ArrayList; +import java.util.List; +import org.camunda.bpm.engine.ProcessEngine; +import org.camunda.bpm.engine.RepositoryService; +import org.camunda.bpm.engine.repository.ProcessDefinition; +import org.camunda.bpm.engine.repository.ProcessDefinitionQuery; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.springframework.core.env.Environment; + +@RunWith(MockitoJUnitRunner.class) +public class AutoProcessInstanceMigrationServiceTest { + + @Mock + private ProcessEngine processEngine; + + @Mock + private ProcessDefinition outdated; + + @Mock + private ProcessDefinition newDef; + + @Mock + private ProcessDefinition key; + + @Mock + private ProcessDefinition testKey; + + @Mock + private ProcessDefinition suspendedDef; + + @Mock + private RepositoryService repositoryService; + + @Mock + private ProcessDefinitionQuery query; + + @Mock + private ProcessDefinitionQuery keyQuery; + + @Mock + private Environment env; + + @Spy + @InjectMocks + private AutoProcessInstanceMigrationService migrationService; + + + @Test + public void getOldProcessDefinitionsTest() { + List<ProcessDefinition> expectedList = new ArrayList<>(); + expectedList.add(outdated); + + List<ProcessDefinition> defList = new ArrayList<>(); + defList.add(outdated); + defList.add(newDef); + defList.add(suspendedDef); + + + doReturn(query).when(repositoryService).createProcessDefinitionQuery(); + doReturn(query).when(query).processDefinitionKey("test"); + doReturn(defList).when(query).list(); + doReturn(3).when(outdated).getVersion(); + doReturn(4).when(newDef).getVersion(); + doReturn(true).when(suspendedDef).isSuspended(); + List<ProcessDefinition> outdatedList = migrationService.getOldProcessDefinitions("test", 4); + + assertEquals(expectedList, outdatedList); + } + + @Test + public void getProcessDefinitionsTest() { + List<ProcessDefinition> expected = new ArrayList<ProcessDefinition>(); + expected.add(testKey); + expected.add(key); + + List<String> processDefinitionKeys = new ArrayList<String>(); + processDefinitionKeys.add("testKey"); + processDefinitionKeys.add("key"); + + doReturn(processDefinitionKeys).when(env).getProperty("migration.processDefinitionKeys", List.class, + new ArrayList<String>()); + + doReturn(query).when(repositoryService).createProcessDefinitionQuery(); + doReturn(query).when(query).processDefinitionKey("testKey"); + doReturn(query).when(query).latestVersion(); + doReturn(testKey).when(query).singleResult(); + + doReturn(keyQuery).when(query).processDefinitionKey("key"); + doReturn(keyQuery).when(keyQuery).latestVersion(); + doReturn(key).when(keyQuery).singleResult(); + + List<ProcessDefinition> actualProcessDefinitions = migrationService.getProcessDefinitions(); + + assertEquals(expected, actualProcessDefinitions); + } +} diff --git a/bpmn/pom.xml b/bpmn/pom.xml index 36fb17c9b4..4193ba1287 100644 --- a/bpmn/pom.xml +++ b/bpmn/pom.xml @@ -6,7 +6,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>so</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>bpmn</artifactId> @@ -19,7 +19,7 @@ <camunda.bpm.assert.version>1.2</camunda.bpm.assert.version> <camunda.bpm.webapp.artifact>camunda-webapp-jboss-standalone</camunda.bpm.webapp.artifact> <h2.version>1.4.196</h2.version> - <groovy.version>2.4.8</groovy.version> + <groovy.version>2.5.3</groovy.version> <saxon.version>9.5.1-8</saxon.version> <xmlunit.version>2.4.0</xmlunit.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> @@ -42,11 +42,6 @@ <dependencyManagement> <dependencies> <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-all</artifactId> - <version>${groovy.version}</version> - </dependency> - <dependency> <groupId>net.sf.saxon</groupId> <artifactId>Saxon-HE</artifactId> <version>${saxon.version}</version> diff --git a/bpmn/so-bpmn-building-blocks/pom.xml b/bpmn/so-bpmn-building-blocks/pom.xml index 52c5502b32..5c4cd6d2fa 100644 --- a/bpmn/so-bpmn-building-blocks/pom.xml +++ b/bpmn/so-bpmn-building-blocks/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>bpmn</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>so-bpmn-building-blocks</artifactId> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn index f2c0ba7dee..01caf38610 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.1.2"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.0"> <bpmn:process id="ActivateVfModuleBB" name="ActivateVfModuleBB" isExecutable="true"> <bpmn:startEvent id="ActivateVfModuleBB_Start"> <bpmn:outgoing>SequenceFlow_0ieafii</bpmn:outgoing> @@ -70,10 +70,23 @@ </bpmn:inclusiveGateway> <bpmn:inclusiveGateway id="ExclusiveGateway_0sqvzll"> <bpmn:incoming>SequenceFlow_07ybdik</bpmn:incoming> - <bpmn:incoming>SequenceFlow_0l8684g</bpmn:incoming> + <bpmn:incoming>Flow_1c5mrjc</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1b63lv4</bpmn:outgoing> </bpmn:inclusiveGateway> - <bpmn:sequenceFlow id="SequenceFlow_0l8684g" sourceRef="Audit_AAI_Inventory" targetRef="ExclusiveGateway_0sqvzll" /> + <bpmn:sequenceFlow id="SequenceFlow_0l8684g" sourceRef="Audit_AAI_Inventory" targetRef="Gateway_1518atw" /> + <bpmn:exclusiveGateway id="Gateway_1518atw" name="Audit Failed?" default="Flow_1c5mrjc"> + <bpmn:incoming>SequenceFlow_0l8684g</bpmn:incoming> + <bpmn:outgoing>Flow_1c5mrjc</bpmn:outgoing> + <bpmn:outgoing>Flow_02xnvmz</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_1c5mrjc" sourceRef="Gateway_1518atw" targetRef="ExclusiveGateway_0sqvzll" /> + <bpmn:sequenceFlow id="Flow_02xnvmz" sourceRef="Gateway_1518atw" targetRef="Event_1ubxkat"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("auditIsSuccessful") == false}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:endEvent id="Event_1ubxkat"> + <bpmn:incoming>Flow_02xnvmz</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0qq1s4r" errorRef="Error_1s3kxze" /> + </bpmn:endEvent> </bpmn:process> <bpmn:error id="Error_0q258vt" errorCode="7000" /> <bpmn:error id="Error_0zgccif" name="org.onap.so.adapters.inventory.create.InventoryException" errorCode="org.onap.so.adapters.inventory.create.InventoryException" /> @@ -81,150 +94,167 @@ <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ActivateVfModuleBB"> <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="ActivateVfModuleBB_Start"> - <dc:Bounds x="156" y="180" width="36" height="36" /> + <dc:Bounds x="156" y="260" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="58" y="270" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0ieafii_di" bpmnElement="SequenceFlow_0ieafii"> - <di:waypoint x="192" y="198" /> - <di:waypoint x="272" y="198" /> + <di:waypoint x="192" y="278" /> + <di:waypoint x="272" y="278" /> <bpmndi:BPMNLabel> <dc:Bounds x="116" y="231" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_1v967li_di" bpmnElement="ActivateVfModuleBB_End"> - <dc:Bounds x="1475" y="181" width="36" height="36" /> + <dc:Bounds x="1475" y="261" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="1235" y="275" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0hawa84_di" bpmnElement="ActivateVfModule"> - <dc:Bounds x="1029" y="158" width="100" height="80" /> + <dc:Bounds x="1029" y="238" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_175e9ul_di" bpmnElement="UpdateVfModuleActiveStatus"> - <dc:Bounds x="1285" y="158" width="100" height="80" /> + <dc:Bounds x="1285" y="238" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0xsp0pv_di" bpmnElement="SequenceFlow_0xsp0pv"> - <di:waypoint x="1385" y="198" /> - <di:waypoint x="1475" y="199" /> + <di:waypoint x="1385" y="278" /> + <di:waypoint x="1475" y="279" /> <bpmndi:BPMNLabel> <dc:Bounds x="1314" y="231.5" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_03jkesd_di" bpmnElement="CallActivity_sdncHandler"> - <dc:Bounds x="1157" y="158" width="100" height="80" /> + <dc:Bounds x="1157" y="238" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1a495wm_di" bpmnElement="SequenceFlow_1a495wm"> - <di:waypoint x="1129" y="198" /> - <di:waypoint x="1157" y="198" /> + <di:waypoint x="1129" y="278" /> + <di:waypoint x="1157" y="278" /> <bpmndi:BPMNLabel> <dc:Bounds x="1027" y="231" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1j4x1ej_di" bpmnElement="SequenceFlow_1j4x1ej"> - <di:waypoint x="1257" y="198" /> - <di:waypoint x="1285" y="198" /> + <di:waypoint x="1257" y="278" /> + <di:waypoint x="1285" y="278" /> <bpmndi:BPMNLabel> <dc:Bounds x="1155" y="231" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0xndboi_di" bpmnElement="SequenceFlow_0xndboi"> - <di:waypoint x="589" y="121" /> - <di:waypoint x="680" y="121" /> + <di:waypoint x="589" y="201" /> + <di:waypoint x="630" y="201" /> <bpmndi:BPMNLabel> <dc:Bounds x="457" y="153.5" width="90" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0krf1ur_di" bpmnElement="Setup_AAI_Inventory_Audit"> - <dc:Bounds x="489" y="81" width="100" height="80" /> + <dc:Bounds x="489" y="161" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_08rxjeb_di" bpmnElement="Audit_AAI_Inventory"> - <dc:Bounds x="680" y="81" width="100" height="80" /> + <dc:Bounds x="630" y="161" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_07ybdik_di" bpmnElement="SequenceFlow_07ybdik"> - <di:waypoint x="426" y="223" /> - <di:waypoint x="426" y="261" /> - <di:waypoint x="952" y="261" /> - <di:waypoint x="952" y="223" /> + <di:waypoint x="426" y="303" /> + <di:waypoint x="426" y="341" /> + <di:waypoint x="952" y="341" /> + <di:waypoint x="952" y="303" /> <bpmndi:BPMNLabel> - <dc:Bounds x="435" y="240" width="15" height="14" /> + <dc:Bounds x="435" y="320" width="15" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0ghzwlo_di" bpmnElement="SequenceFlow_0ghzwlo"> - <di:waypoint x="426" y="173" /> - <di:waypoint x="426" y="121" /> - <di:waypoint x="489" y="121" /> + <di:waypoint x="426" y="253" /> + <di:waypoint x="426" y="201" /> + <di:waypoint x="489" y="201" /> <bpmndi:BPMNLabel> - <dc:Bounds x="434" y="131" width="18" height="14" /> + <dc:Bounds x="434" y="211" width="18" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_1eg5ryx_di" bpmnElement="CheckAuditVariable"> - <dc:Bounds x="272" y="158" width="100" height="80" /> + <dc:Bounds x="272" y="238" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1xqyur9_di" bpmnElement="SequenceFlow_1xqyur9"> - <di:waypoint x="372" y="198" /> - <di:waypoint x="401" y="198" /> + <di:waypoint x="372" y="278" /> + <di:waypoint x="401" y="278" /> <bpmndi:BPMNLabel> <dc:Bounds x="270.5" y="230.5" width="90" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1b63lv4_di" bpmnElement="SequenceFlow_1b63lv4"> - <di:waypoint x="977" y="198" /> - <di:waypoint x="1029" y="198" /> + <di:waypoint x="977" y="278" /> + <di:waypoint x="1029" y="278" /> <bpmndi:BPMNLabel> <dc:Bounds x="887" y="231" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="SubProcess_0mbkb7v_di" bpmnElement="SubProcess_0bpsptg" isExpanded="true"> - <dc:Bounds x="364" y="395" width="350" height="200" /> + <dc:Bounds x="364" y="475" width="350" height="200" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="StartEvent_12r96di_di" bpmnElement="catchInventoryException"> - <dc:Bounds x="395" y="478" width="36" height="36" /> + <dc:Bounds x="395" y="558" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="341.15269461077844" y="571.6127744510978" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_067jv1n_di" bpmnElement="EndEvent_067jv1n"> - <dc:Bounds x="643" y="478" width="36" height="36" /> + <dc:Bounds x="643" y="558" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="590.1526946107784" y="572" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_19gbhlj_di" bpmnElement="SequenceFlow_19gbhlj"> - <di:waypoint x="431" y="496" /> - <di:waypoint x="486" y="496" /> + <di:waypoint x="431" y="576" /> + <di:waypoint x="486" y="576" /> <bpmndi:BPMNLabel> <dc:Bounds x="387.5" y="529" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0l4jzc5_di" bpmnElement="SequenceFlow_0l4jzc5"> - <di:waypoint x="586" y="496" /> - <di:waypoint x="643" y="496" /> + <di:waypoint x="586" y="576" /> + <di:waypoint x="643" y="576" /> <bpmndi:BPMNLabel> <dc:Bounds x="543.5" y="529" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_08xffml_di" bpmnElement="processAuditException"> - <dc:Bounds x="486" y="456" width="100" height="80" /> + <dc:Bounds x="486" y="536" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="InclusiveGateway_03pi9y4_di" bpmnElement="ExclusiveGateway_1v8bmbu"> - <dc:Bounds x="401" y="173" width="50" height="50" /> + <dc:Bounds x="401" y="253" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="453" y="192" width="75" height="14" /> + <dc:Bounds x="454" y="272" width="74" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="InclusiveGateway_16ap4e3_di" bpmnElement="ExclusiveGateway_0sqvzll"> - <dc:Bounds x="927" y="173" width="50" height="50" /> + <dc:Bounds x="927" y="253" width="50" height="50" /> <bpmndi:BPMNLabel> <dc:Bounds x="836" y="281" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0l8684g_di" bpmnElement="SequenceFlow_0l8684g"> - <di:waypoint x="780" y="121" /> - <di:waypoint x="952" y="121" /> - <di:waypoint x="952" y="173" /> + <di:waypoint x="730" y="201" /> + <di:waypoint x="785" y="201" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Gateway_1518atw_di" bpmnElement="Gateway_1518atw" isMarkerVisible="true"> + <dc:Bounds x="785" y="176" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="780" y="233" width="64" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_1c5mrjc_di" bpmnElement="Flow_1c5mrjc"> + <di:waypoint x="835" y="201" /> + <di:waypoint x="952" y="201" /> + <di:waypoint x="952" y="253" /> </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_02xnvmz_di" bpmnElement="Flow_02xnvmz"> + <di:waypoint x="810" y="176" /> + <di:waypoint x="810" y="118" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_133vsyh_di" bpmnElement="Event_1ubxkat"> + <dc:Bounds x="792" y="82" width="36" height="36" /> + </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn index 1e67ea33ec..1229c86d64 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn @@ -218,4 +218,4 @@ </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions>
\ No newline at end of file +</bpmn:definitions> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeactivatePnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeactivatePnfBB.bpmn new file mode 100644 index 0000000000..f01f81073b --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeactivatePnfBB.bpmn @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1a52v2f" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.0.0"> + <bpmn:collaboration id="Collaboration_0go8wi3"> + <bpmn:participant id="Participant_1dwc5st" name="SO Deactivate PNF" processRef="DeactivatePnfBB" /> + <bpmn:participant id="Participant_0gycee4" name="AAI" /> + <bpmn:messageFlow id="MessageFlow_0xh6bkn" sourceRef="UpdatePnfOrchestrationStatusToInventoried" targetRef="Participant_0gycee4" /> + </bpmn:collaboration> + <bpmn:process id="DeactivatePnfBB" name="DeactivatePnfBB" isExecutable="true"> + <bpmn:sequenceFlow id="SequenceFlow_0l6rtzy" sourceRef="UpdatePnfOrchestrationStatusToInventoried" targetRef="PnfInventoried" /> + <bpmn:sequenceFlow id="SequenceFlow_1fu9o4x" sourceRef="DeactivatePnf_StartEvent" targetRef="UpdatePnfOrchestrationStatusToInventoried" /> + <bpmn:endEvent id="PnfInventoried" name="Pnf Inventoried"> + <bpmn:incoming>SequenceFlow_0l6rtzy</bpmn:incoming> + </bpmn:endEvent> + <bpmn:serviceTask id="UpdatePnfOrchestrationStatusToInventoried" name="Update Pnf Orchestration Status to Inventoried" camunda:expression="${AAIUpdateTasks.updateOrchestrationStatusInventoriedPnf(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_1fu9o4x</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0l6rtzy</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:startEvent id="DeactivatePnf_StartEvent"> + <bpmn:outgoing>SequenceFlow_1fu9o4x</bpmn:outgoing> + </bpmn:startEvent> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_0go8wi3"> + <bpmndi:BPMNShape id="Participant_1dwc5st_di" bpmnElement="Participant_1dwc5st" isHorizontal="true"> + <dc:Bounds x="160" y="80" width="646" height="391" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1fu9o4x_di" bpmnElement="SequenceFlow_1fu9o4x"> + <di:waypoint x="255" y="287" /> + <di:waypoint x="461" y="287" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0l6rtzy_di" bpmnElement="SequenceFlow_0l6rtzy"> + <di:waypoint x="561" y="287" /> + <di:waypoint x="722" y="287" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_1wfgsdz_di" bpmnElement="PnfInventoried"> + <dc:Bounds x="722" y="269" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="705" y="312" width="74" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1ix8822_di" bpmnElement="UpdatePnfOrchestrationStatusToInventoried"> + <dc:Bounds x="461" y="247" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="StartEvent_1g3euow_di" bpmnElement="DeactivatePnf_StartEvent"> + <dc:Bounds x="219" y="269" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Participant_0gycee4_di" bpmnElement="Participant_0gycee4" isHorizontal="true"> + <dc:Bounds x="260" y="567" width="502" height="60" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="MessageFlow_0xh6bkn_di" bpmnElement="MessageFlow_0xh6bkn"> + <di:waypoint x="511" y="327" /> + <di:waypoint x="511" y="567" /> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/activity/DeployActivitySpecsTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/activity/DeployActivitySpecsTest.java index 64c0e54a10..27ae7ba050 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/activity/DeployActivitySpecsTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/activity/DeployActivitySpecsTest.java @@ -49,6 +49,7 @@ public class DeployActivitySpecsTest extends BaseBPMNTest { when(clientMock.execute(any(HttpPost.class))).thenReturn(response); String[] args = new String[] {HOSTNAME}; DeployActivitySpecs.main(args); + assertNotNull(HOSTNAME); } @Test diff --git a/bpmn/so-bpmn-infrastructure-common/pom.xml b/bpmn/so-bpmn-infrastructure-common/pom.xml index f4e173dc6f..28e3ffe8c3 100644 --- a/bpmn/so-bpmn-infrastructure-common/pom.xml +++ b/bpmn/so-bpmn-infrastructure-common/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>bpmn</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>so-bpmn-infrastructure-common</artifactId> @@ -35,7 +35,6 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>3.8.0</version> <configuration> <compilerId>groovy-eclipse-compiler</compilerId> </configuration> @@ -49,14 +48,14 @@ <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-eclipse-batch</artifactId> - <version>2.4.19-01</version> + <version>2.5.8-03</version> </dependency> </dependencies> </plugin> </plugins> <pluginManagement> <plugins> - <plugin> + <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> <version>1.0.0</version> @@ -170,10 +169,6 @@ <artifactId>java-uuid-generator</artifactId> </dependency> <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-all</artifactId> - </dependency> - <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> </dependency> @@ -286,6 +281,11 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.camunda.bpm.extension.mockito</groupId> <artifactId>camunda-bpm-mockito</artifactId> </dependency> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy index 21fc50c9b6..0a7753e9e5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy @@ -450,6 +450,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { execution.setVariable("serviceModelInfo", serviceDecomposition.getModelInfo()) List<Resource> deleteResourceList = serviceDecomposition.getServiceResources() + List<ImmutablePair<Resource, List<Resource>>> deleteRealResourceList = new ArrayList<ImmutablePair<Resource, List<Resource>>>() if (serviceDecomposition.getServiceType().equals("MDONS_OTN")){ for (Resource resource : deleteResourceList) { String serviceName = execution.getVariable("serviceInstanceName") @@ -469,7 +470,6 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { relationShipList = jsonSlurper.parseText(serviceRelationShip) } - List<ImmutablePair<Resource, List<Resource>>> deleteRealResourceList = new ArrayList<ImmutablePair<Resource, List<Resource>>>() //Set the real resource instance id to the decomosed resource list //reset the resource instance id , because in the decompose flow ,its a random one. diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/GenericPnfTaskProcessor.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/GenericPnfTaskProcessor.groovy new file mode 100644 index 0000000000..727a7508c4 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/GenericPnfTaskProcessor.groovy @@ -0,0 +1,127 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.workflow.context.WorkflowContext +import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder +import org.onap.so.bpmn.core.WorkflowException +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.REQUEST_ID + +class GenericPnfTaskProcessor extends AbstractServiceTaskProcessor { + private static final Logger logger = LoggerFactory.getLogger(GenericPnfTaskProcessor.class) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + String prefix = "Generic_" + + @Override + void preProcessRequest(DelegateExecution execution) { + } + + void sendResponse(DelegateExecution execution) { + def requestId = execution.getVariable(REQUEST_ID) + def instanceId = execution.getVariable(PNF_CORRELATION_ID) + logger.debug("Send response for requestId: {}, instanceId: {}", requestId, instanceId) + + String response = """{"requestReferences":{"requestId":"${requestId}", "instanceId":"${instanceId}"}}""".trim() + sendWorkflowResponse(execution, 200, response) + } + + static WorkflowContext getWorkflowContext(DelegateExecution execution) { + String requestId = execution.getVariable(REQUEST_ID) + return WorkflowContextHolder.getInstance().getWorkflowContext(requestId) + } + + void prepareCompletion(DelegateExecution execution) { + try { + String requestId = execution.getVariable(REQUEST_ID) + logger.debug("Prepare Completion of PNF for requestId: {}", requestId) + + String msoCompletionRequest = + """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" + xmlns:ns="http://org.onap/so/request/types/v1"> + <request-info xmlns="http://org.onap/so/infra/vnf-request/v1"> + <request-id>${MsoUtils.xmlEscape(requestId)}</request-id> + <action>UPDATE</action> + <source>VID</source> + </request-info> + <aetgt:status-message>Activity is successful.</aetgt:status-message> + <aetgt:mso-bpel-name>${execution.getProcessDefinitionId()}</aetgt:mso-bpel-name> + </aetgt:MsoCompletionRequest>""" + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + execution.setVariable(prefix + "CompleteMsoProcessRequest", xmlMsoCompletionRequest) + + logger.debug("CompleteMsoProcessRequest of PNF - " + "\n" + xmlMsoCompletionRequest) + } catch (Exception e) { + String msg = "Prepare Completion error for PNF - " + e.getMessage() + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + } + + void prepareFalloutHandler(DelegateExecution execution) { + WorkflowContext workflowContext = getWorkflowContext(execution) + if (workflowContext == null) { + logger.debug("Error occurred before sending response to API handler, and send it now") + sendResponse(execution) + } + + try { + String requestId = execution.getVariable(REQUEST_ID) + logger.debug("Prepare FalloutHandler of PNF for requestId: {}", requestId) + + WorkflowException workflowException = execution.getVariable("WorkflowException") + String errorCode = String.valueOf(workflowException.getErrorCode()) + String errorMessage = workflowException.getErrorMessage() + String falloutHandlerRequest = + """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" + xmlns:ns="http://org.onap/so/request/types/v1"> + <request-info xmlns="http://org.onap/so/infra/vnf-request/v1"> + <request-id>${MsoUtils.xmlEscape(requestId)}</request-id> + <action>UPDATE</action> + <source>VID</source> + </request-info> + <aetgt:WorkflowException xmlns:aetgt="http://org.onap/so/workflow/schema/v1"> + <aetgt:ErrorMessage>${MsoUtils.xmlEscape(errorMessage)}</aetgt:ErrorMessage> + <aetgt:ErrorCode>${MsoUtils.xmlEscape(errorCode)}</aetgt:ErrorCode> + </aetgt:WorkflowException> + </aetgt:FalloutHandlerRequest>""" + String xmlFalloutHandlerRequest = utils.formatXml(falloutHandlerRequest) + + execution.setVariable(prefix + "FalloutHandlerRequest", xmlFalloutHandlerRequest) + + logger.debug("FalloutHandlerRequest of PNF - " + "\n" + xmlFalloutHandlerRequest) + } catch (Exception e) { + String msg = "Prepare FalloutHandler error for PNF - " + e.getMessage() + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/pom.xml b/bpmn/so-bpmn-infrastructure-flows/pom.xml index 1d6fa9e924..e6eb284199 100644 --- a/bpmn/so-bpmn-infrastructure-flows/pom.xml +++ b/bpmn/so-bpmn-infrastructure-flows/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>bpmn</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>so-bpmn-infrastructure-flows</artifactId> @@ -223,13 +223,8 @@ <artifactId>java-uuid-generator</artifactId> </dependency> <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-all</artifactId> - </dependency> - <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> - <version>3.4</version> </dependency> <dependency> <groupId>org.onap.so</groupId> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfHealthCheck.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfHealthCheck.bpmn new file mode 100644 index 0000000000..1722137056 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfHealthCheck.bpmn @@ -0,0 +1,203 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1yd8m0g" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.0.0"> + <bpmn:process id="GenericPnfHealthCheck" name="GenericPnfHealthCheck" isExecutable="true"> + <bpmn:startEvent id="pnfHealthCheck_startEvent" name="Start Flow"> + <bpmn:outgoing>SequenceFlow_1ng4b6l</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:serviceTask id="ServiceTask_042uz7m" name="PNF Request Dispatcher" camunda:delegateExpression="${GenericPnfDispatcher}"> + <bpmn:incoming>SequenceFlow_1ng4b6l</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_12ejx4m</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_12ejx4m" sourceRef="ServiceTask_042uz7m" targetRef="ScriptTask_10klpg9" /> + <bpmn:endEvent id="pnfHealthCheck_endEvent" name="End"> + <bpmn:incoming>SequenceFlow_0tle5zb</bpmn:incoming> + <bpmn:terminateEventDefinition /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_1ng4b6l" sourceRef="pnfHealthCheck_startEvent" targetRef="ServiceTask_042uz7m" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_0x6h0yi" default="SequenceFlow_0piri91"> + <bpmn:incoming>SequenceFlow_0j26xlx</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0piri91</bpmn:outgoing> + <bpmn:outgoing>Flow_015z1h4</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="EndEvent_180lm4y"> + <bpmn:incoming>SequenceFlow_0piri91</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0fm5he7" errorRef="Error_12cpov5" /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_0piri91" name="Failure" sourceRef="ExclusiveGateway_0x6h0yi" targetRef="EndEvent_180lm4y" /> + <bpmn:scriptTask id="ScriptTask_10klpg9" name="Send Response" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_12ejx4m</bpmn:incoming> + <bpmn:outgoing>Flow_12uv2m0</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def taskProcessor = new GenericPnfTaskProcessor() +taskProcessor.sendResponse(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_1igtc83" name="Prepare Completion" scriptFormat="groovy"> + <bpmn:incoming>Flow_015z1h4</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0ipc3nt</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def taskProcessor = new GenericPnfTaskProcessor() +taskProcessor.prepareCompletion(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0ipc3nt" sourceRef="ScriptTask_1igtc83" targetRef="CallActivity_0o1mi8u" /> + <bpmn:callActivity id="CallActivity_0o1mi8u" name="Complete Process" calledElement="CompleteMsoProcess"> + <bpmn:extensionElements> + <camunda:in source="PnfSwUpgrade_CompleteMsoProcessRequest" target="CompleteMsoProcessRequest" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0ipc3nt</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0tle5zb</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="SequenceFlow_0tle5zb" sourceRef="CallActivity_0o1mi8u" targetRef="pnfHealthCheck_endEvent" /> + <bpmn:subProcess id="SubProcess_02p6q4s" name="Subprocess for FalloutHandler" triggeredByEvent="true"> + <bpmn:startEvent id="StartEvent_149ecdm" name="Catch All Errors"> + <bpmn:outgoing>SequenceFlow_05haut5</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1" /> + </bpmn:startEvent> + <bpmn:scriptTask id="ScriptTask_0gov132" name="Prepare FalloutHandler" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_05haut5</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_09y0mpc</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def pnfSwUpgrade = new PNFSoftwareUpgrade() +pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="CallActivity_00psvtk" name="Call FalloutHandler" calledElement="FalloutHandler"> + <bpmn:extensionElements> + <camunda:in source="PnfSwUpgrade_FalloutHandlerRequest" target="FalloutHandlerRequest" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_09y0mpc</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1tcjlty</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:endEvent id="EndEvent_1vq2glg" name="End"> + <bpmn:incoming>SequenceFlow_1tcjlty</bpmn:incoming> + <bpmn:terminateEventDefinition id="TerminateEventDefinition_0994ojb" /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_05haut5" sourceRef="StartEvent_149ecdm" targetRef="ScriptTask_0gov132" /> + <bpmn:sequenceFlow id="SequenceFlow_09y0mpc" sourceRef="ScriptTask_0gov132" targetRef="CallActivity_00psvtk" /> + <bpmn:sequenceFlow id="SequenceFlow_1tcjlty" sourceRef="CallActivity_00psvtk" targetRef="EndEvent_1vq2glg" /> + </bpmn:subProcess> + <bpmn:serviceTask id="ServiceTask_0slpaht" name="HealthCheck" camunda:delegateExpression="${ControllerExecutionDE}"> + <bpmn:extensionElements> + <camunda:inputOutput> + <camunda:inputParameter name="action">healthCheck</camunda:inputParameter> + <camunda:inputParameter name="scope">pnf</camunda:inputParameter> + <camunda:inputParameter name="mode">async</camunda:inputParameter> + </camunda:inputOutput> + </bpmn:extensionElements> + <bpmn:incoming>Flow_12uv2m0</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0j26xlx</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0j26xlx" sourceRef="ServiceTask_0slpaht" targetRef="ExclusiveGateway_0x6h0yi" /> + <bpmn:sequenceFlow id="Flow_015z1h4" name="Success" sourceRef="ExclusiveGateway_0x6h0yi" targetRef="ScriptTask_1igtc83"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_12uv2m0" sourceRef="ScriptTask_10klpg9" targetRef="ServiceTask_0slpaht" /> + </bpmn:process> + <bpmn:error id="Error_12cpov5" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="GenericPnfHealthCheck"> + <bpmndi:BPMNEdge id="Flow_12uv2m0_di" bpmnElement="Flow_12uv2m0"> + <di:waypoint x="530" y="120" /> + <di:waypoint x="590" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_015z1h4_di" bpmnElement="Flow_015z1h4"> + <di:waypoint x="825" y="120" /> + <di:waypoint x="900" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="842" y="102" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0j26xlx_di" bpmnElement="SequenceFlow_0j26xlx"> + <di:waypoint x="690" y="120" /> + <di:waypoint x="775" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0tle5zb_di" bpmnElement="SequenceFlow_0tle5zb"> + <di:waypoint x="1180" y="120" /> + <di:waypoint x="1262" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0ipc3nt_di" bpmnElement="SequenceFlow_0ipc3nt"> + <di:waypoint x="1000" y="120" /> + <di:waypoint x="1080" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0piri91_di" bpmnElement="SequenceFlow_0piri91"> + <di:waypoint x="800" y="145" /> + <di:waypoint x="800" y="202" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="793" y="145" width="35" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ng4b6l_di" bpmnElement="SequenceFlow_1ng4b6l"> + <di:waypoint x="178" y="120" /> + <di:waypoint x="270" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_12ejx4m_di" bpmnElement="SequenceFlow_12ejx4m"> + <di:waypoint x="370" y="120" /> + <di:waypoint x="430" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="pnfHealthCheck_startEvent"> + <dc:Bounds x="142" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="137" y="145" width="51" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_042uz7n_di" bpmnElement="ServiceTask_042uz7m"> + <dc:Bounds x="270" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1w3jv30_di" bpmnElement="pnfHealthCheck_endEvent"> + <dc:Bounds x="1262" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1271" y="145" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_0x6h0ni_di" bpmnElement="ExclusiveGateway_0x6h0yi" isMarkerVisible="true"> + <dc:Bounds x="775" y="95" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_180lm4y_di" bpmnElement="EndEvent_180lm4y"> + <dc:Bounds x="782" y="202" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_10klpg8_di" bpmnElement="ScriptTask_10klpg9"> + <dc:Bounds x="430" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1igtc83_di" bpmnElement="ScriptTask_1igtc83"> + <dc:Bounds x="900" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_0o1mi8u_di" bpmnElement="CallActivity_0o1mi8u"> + <dc:Bounds x="1080" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="SubProcess_02p6q4s_di" bpmnElement="SubProcess_02p6q4s" isExpanded="true"> + <dc:Bounds x="370" y="430" width="650" height="190" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1tcjlty_di" bpmnElement="SequenceFlow_1tcjlty"> + <di:waypoint x="810" y="530" /> + <di:waypoint x="882" y="530" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_09y0mpc_di" bpmnElement="SequenceFlow_09y0mpc"> + <di:waypoint x="640" y="530" /> + <di:waypoint x="710" y="530" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_05haut5_di" bpmnElement="SequenceFlow_05haut5"> + <di:waypoint x="478" y="530" /> + <di:waypoint x="540" y="530" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_1r4h504_di" bpmnElement="StartEvent_149ecdm"> + <dc:Bounds x="442" y="512" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="421" y="553" width="78" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0gov132_di" bpmnElement="ScriptTask_0gov132"> + <dc:Bounds x="540" y="490" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_00psvtk_di" bpmnElement="CallActivity_00psvtk"> + <dc:Bounds x="710" y="490" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1vq2glg_di" bpmnElement="EndEvent_1vq2glg"> + <dc:Bounds x="882" y="512" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="891" y="555" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0slpahe_di" bpmnElement="ServiceTask_0slpaht"> + <dc:Bounds x="590" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java index 05839c1a3a..a03da25248 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java @@ -23,6 +23,7 @@ package org.onap.so.bpmn.infrastructure.process; import com.google.protobuf.Struct; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; @@ -54,6 +55,7 @@ import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.as /** * Basic Integration test for createVcpeResCustService_Simplified.bpmn workflow. */ +@Ignore public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { private Logger logger = LoggerFactory.getLogger(getClass()); diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSoftwareUpgradeTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSoftwareUpgradeTest.java index 22cf72b262..0bf14d7443 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSoftwareUpgradeTest.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSoftwareUpgradeTest.java @@ -1,7 +1,6 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2020 Nordix Foundation. - * Modifications Copyright (C) 2020 Huawei Technologies Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PnfHealthCheckTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PnfHealthCheckTest.java new file mode 100644 index 0000000000..2423ad8465 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PnfHealthCheckTest.java @@ -0,0 +1,234 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.process; + +import com.google.protobuf.Struct; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.Before; +import org.junit.Test; +import org.onap.aaiclient.client.aai.AAIVersion; +import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; +import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; +import org.onap.so.BaseBPMNTest; +import org.onap.so.GrpcNettyServer; +import org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames; +import org.onap.so.bpmn.mock.FileUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import static com.github.tomakehurst.wiremock.client.WireMock.*; +import static org.assertj.core.api.Assertions.fail; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; + +/** + * Basic Integration test for GenericPnfHealthCheck.bpmn workflow. + */ +public class PnfHealthCheckTest extends BaseBPMNTest { + + private final Logger logger = LoggerFactory.getLogger(getClass()); + + private static final long WORKFLOW_WAIT_TIME = 1000L; + + private static final String TEST_PROCESSINSTANCE_KEY = "GenericPnfHealthCheck"; + private static final AAIVersion VERSION = AAIVersion.LATEST; + private static final Map<String, Object> executionVariables = new HashMap<>(); + private static final String REQUEST_ID = "50ae41ad-049c-4fe2-9950-539f111120f5"; + private static final String ACTION_NAME = "healthCheck"; + private final String CLASS_NAME = getClass().getSimpleName(); + private String requestObject; + private String responseObject; + + @Autowired + private GrpcNettyServer grpcNettyServer; + + @Before + public void setUp() { + executionVariables.clear(); + grpcNettyServer.getDetailedMessages().clear(); + + requestObject = FileUtil.readResourceFile("request/" + CLASS_NAME + ".json"); + responseObject = FileUtil.readResourceFile("response/" + CLASS_NAME + ".json"); + + executionVariables.put("bpmnRequest", requestObject); + executionVariables.put("requestId", REQUEST_ID); + + /** + * This variable indicates that the flow was invoked asynchronously. It's injected by {@link WorkflowProcessor}. + */ + executionVariables.put("isAsyncProcess", "true"); + executionVariables.put(ExecutionVariableNames.PRC_CUSTOMIZATION_UUID, "38dc9a92-214c-11e7-93ae-92361f002680"); + + /** + * Temporary solution to add pnfCorrelationId to context. this value is getting from the request to SO api + * handler and then convert to CamundaInput + */ + executionVariables.put(ExecutionVariableNames.PNF_CORRELATION_ID, "PNFDemo"); + } + + + @Test + public void workflow_validInput_expectedOutput() throws InterruptedException { + + mockCatalogDb(); + mockRequestDb(); + mockAai(); + + final String msoRequestId = UUID.randomUUID().toString(); + executionVariables.put(ExecutionVariableNames.MSO_REQUEST_ID, msoRequestId); + + final String testBusinessKey = UUID.randomUUID().toString(); + logger.info("Test the process instance: {} with business key: {}", TEST_PROCESSINSTANCE_KEY, testBusinessKey); + + ProcessInstance pi = + runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, executionVariables); + + int waitCount = 10; + while (!isProcessInstanceEnded() && waitCount >= 0) { + Thread.sleep(WORKFLOW_WAIT_TIME); + waitCount--; + } + + // Layout is to reflect the bpmn visual layout + assertThat(pi).isEnded().hasPassedInOrder("pnfHealthCheck_startEvent", "ServiceTask_042uz7m", + "ScriptTask_10klpg9", "ServiceTask_0slpaht", "ExclusiveGateway_0x6h0yi", "ScriptTask_1igtc83", + "CallActivity_0o1mi8u", "pnfHealthCheck_endEvent"); + + List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages(); + logger.debug("Size of detailedMessage is {}", detailedMessages.size()); + assertThat(detailedMessages.size() == 1).isTrue(); + int count = 0; + try { + for (ExecutionServiceInput eSI : detailedMessages) { + if (ACTION_NAME.equals(eSI.getActionIdentifiers().getActionName()) + && eSI.getCommonHeader().getRequestId().equals(msoRequestId)) { + checkWithActionName(eSI, ACTION_NAME); + count++; + } + } + } catch (Exception e) { + e.printStackTrace(); + fail("PNFHealthCheck request exception", e); + } + assertThat(count == 1).isTrue(); + } + + private boolean isProcessInstanceEnded() { + return runtimeService.createProcessInstanceQuery().processDefinitionKey(TEST_PROCESSINSTANCE_KEY) + .singleResult() == null; + } + + private void checkWithActionName(ExecutionServiceInput executionServiceInput, String action) { + + logger.info("Checking the " + action + " request"); + ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); + + /** + * the fields of actionIdentifiers should match the one in the response/PnfHealthCheck_catalogdb.json. + */ + assertThat(actionIdentifiers.getBlueprintName()).isEqualTo("test_pnf_health_check_restconf"); + assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo("1.0.0"); + assertThat(actionIdentifiers.getActionName()).isEqualTo(action); + assertThat(actionIdentifiers.getMode()).isEqualTo("async"); + + CommonHeader commonHeader = executionServiceInput.getCommonHeader(); + assertThat(commonHeader.getOriginatorId()).isEqualTo("SO"); + + Struct payload = executionServiceInput.getPayload(); + Struct requeststruct = payload.getFieldsOrThrow(action + "-request").getStructValue(); + + assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue()).isEqualTo("PNFDemo"); + Struct propertiesStruct = requeststruct.getFieldsOrThrow(action + "-properties").getStructValue(); + + assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).isEqualTo("PNFDemo"); + assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue()) + .isEqualTo("32daaac6-5017-4e1e-96c8-6a27dfbe1421"); + assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue()) + .isEqualTo("38dc9a92-214c-11e7-93ae-92361f002680"); + } + + private void mockAai() { + + String aaiPnfEntry = + "{ \n" + " \"pnf-name\":\"PNFDemo\",\n" + " \"pnf-id\":\"testtest\",\n" + " \"in-maint\":true,\n" + + " \"resource-version\":\"1541720264047\",\n" + " \"swVersion\":\"demo-1.1\",\n" + + " \"ipaddress-v4-oam\":\"1.1.1.1\",\n" + " \"ipaddress-v6-oam\":\"::/128\"\n" + "}"; + + /** + * PUT the PNF correlation ID to AAI. + */ + wireMockServer.stubFor(put(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo"))); + + /** + * Get the PNF entry from AAI. + */ + wireMockServer.stubFor( + get(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo")).willReturn(okJson(aaiPnfEntry))); + + /** + * Post the pnf to AAI + */ + wireMockServer.stubFor(post(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo"))); + } + + private void mockRequestDb() { + /** + * Update Request DB + */ + wireMockServer.stubFor(put(urlEqualTo("/infraActiveRequests/" + REQUEST_ID))); + + } + + /** + * Mock the catalobdb rest interface. + */ + private void mockCatalogDb() { + + String catalogdbClientResponse = FileUtil.readResourceFile("response/" + CLASS_NAME + "_catalogdb.json"); + + + /** + * Return valid json for the model UUID in the request file. + */ + wireMockServer + .stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=32daaac6-5017-4e1e-96c8-6a27dfbe1421")) + .willReturn(okJson(responseObject))); + + /** + * Return valid json for the service model InvariantUUID as specified in the request file. + */ + wireMockServer.stubFor( + get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=339b7a2f-9524-4dbf-9eee-f2e05521df3f")) + .willReturn(okJson(responseObject))); + + /** + * Return valid spring data rest json for the service model UUID as specified in the request file. + */ + wireMockServer.stubFor(get(urlEqualTo( + "/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=32daaac6-5017-4e1e-96c8-6a27dfbe1421")) + .willReturn(okJson(catalogdbClientResponse))); + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/PnfHealthCheckTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/PnfHealthCheckTest.json new file mode 100644 index 0000000000..7cfe9f5c9c --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/PnfHealthCheckTest.json @@ -0,0 +1,50 @@ +{ + "requestDetails":{ + "requestInfo":{ + "source":"VID", + "suppressRollback":false, + "requestorId":"demo", + "productFamilyId":"SWUPid" + }, + "modelInfo":{ + "modelType":"service", + "modelInvariantUuid":"339b7a2f-9524-4dbf-9eee-f2e05521df3f", + "modelInvariantId":"339b7a2f-9524-4dbf-9eee-f2e05521df3f", + "modelUuid":"32daaac6-5017-4e1e-96c8-6a27dfbe1421", + "modelName":"PNF_int_service_2", + "modelVersion":"1.0" + }, + "requestParameters":{ + "userParams":[ + { + "name":"aic_zone", + "value":"nova" + }, + { + "name":"pnfId", + "value":"PNFDemo" + }, + { + "name":"pnfName", + "value":"PNFDemo" + } + ], + "subscriptionServiceType":"SWUP", + "aLaCarte":false + }, + "cloudConfiguration":{ + "lcpCloudRegionId":"regionOne", + "tenantId":"09a63533072f4a579d5c99c3b8fe94c6" + }, + "subscriberInfo":{ + "globalSubscriberId":"ADemoCustomerInEric" + }, + "project":{ + "projectName":"Project-Demonstration" + }, + "owningEntity":{ + "owningEntityId":"5eae949c-1c50-4780-b8b5-7cbeb08856b4", + "owningEntityName":"OE-Demonstration" + } + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PnfHealthCheckTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PnfHealthCheckTest.json new file mode 100644 index 0000000000..32539844ba --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PnfHealthCheckTest.json @@ -0,0 +1,26 @@ +{ + "serviceResources":{ + "modelInfo":{ + "modelInvariantId":"439b7a2f-9524-4dbf-9eee-f2e05521df3f", + "modelUuid":"42daaac6-5017-4e1e-96c8-6a27dfbe1421", + "modelName":"PNF_int_service_2", + "modelVersion":"1.0" + }, + "serviceType":"NA", + "environmentContext":"Luna", + "serviceRole":"NA", + "workloadContext":"Oxygen", + "serviceVnfs":[ + + ], + "serviceNetworks":[ + + ], + "serviceAllottedResources":[ + + ], + "configResource":[ + + ] + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PnfHealthCheckTest_catalogdb.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PnfHealthCheckTest_catalogdb.json new file mode 100644 index 0000000000..fc9399d7cb --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PnfHealthCheckTest_catalogdb.json @@ -0,0 +1,39 @@ +{ + "_embedded": { + "pnfResourceCustomization": [ + { + "modelCustomizationUUID": "38dc9a92-214c-11e7-93ae-92361f002680", + "modelInstanceName": "PNF routing", + "created": "2019-03-08 12:00:29.000", + "nfFunction": "routing", + "nfType": "routing", + "nfRole": "routing", + "nfNamingCode": "routing", + "multiStageDesign": null, + "resourceInput": null, + "blueprintName": "test_pnf_health_check_restconf", + "blueprintVersion": "1.0.0", + "skipPostInstConf": false, + "softwareVersion": "1.0.0", + "creationTimestamp": "2019-03-08T12:00:29.000+0000", + "controllerActor": "cds", + "_links": { + "self": { + "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680" + }, + "pnfResourceCustomization": { + "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680" + }, + "pnfResources": { + "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680/pnfResources" + } + } + } + ] + }, + "_links": { + "self": { + "href": "http://localhost:41023/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=4df8b6de-2083-11e7-93ae-92361f002676" + } + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/pom.xml b/bpmn/so-bpmn-tasks/pom.xml index 2a9d7fa714..f7eb2c09c7 100644 --- a/bpmn/so-bpmn-tasks/pom.xml +++ b/bpmn/so-bpmn-tasks/pom.xml @@ -3,7 +3,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>bpmn</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>so-bpmn-tasks</artifactId> @@ -11,8 +11,6 @@ <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - <maven.compiler.target>1.8</maven.compiler.target> - <maven.compiler.source>1.8</maven.compiler.source> <grpc.version>1.17.1</grpc.version> </properties> <build> @@ -121,7 +119,7 @@ </execute> </action> </pluginExecution> - <pluginExecution> + <pluginExecution> <pluginExecutionFilter> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> @@ -134,7 +132,7 @@ <execute /> </action> </pluginExecution> - <pluginExecution> + <pluginExecution> <pluginExecutionFilter> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> @@ -204,17 +202,6 @@ <version>${project.version}</version> </dependency> <dependency> - <groupId>org.onap.sdnc.northbound</groupId> - <artifactId>generic-resource-api-client</artifactId> - <version>${sdnc.northbound.version}</version> - <exclusions> - <exclusion> - <groupId>javax.ws.rs</groupId> - <artifactId>jsr311-api</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> <groupId>ch.vorburger.mariaDB4j</groupId> <artifactId>mariaDB4j</artifactId> <version>2.2.3</version> @@ -246,5 +233,15 @@ <version>${grpc.version}</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>so-optimization-clients</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>so-sdn-clients</artifactId> + <version>${project.version}</version> + </dependency> </dependencies> </project> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java index f10b503ed3..71ea9fa719 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java @@ -440,7 +440,8 @@ public class SniroHomingV2 { if (!candidates.isEmpty()) { for (Candidate c : candidates) { org.onap.so.client.sniro.beans.Candidate can = new org.onap.so.client.sniro.beans.Candidate(); - can.setIdentifierType(c.getIdentifierType()); + can.setIdentifierType( + org.onap.so.client.sniro.beans.CandidateType.valueOf(c.getIdentifierType().name())); can.setIdentifiers(c.getIdentifiers()); can.setCloudOwner(c.getCloudOwner()); candidateList.add(can); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java index e3181c3e91..55edf0bb6c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java @@ -260,7 +260,7 @@ public class AAICreateTasks { public void createPnf(BuildingBlockExecution execution) { try { Pnf pnf = extractPojosForBB.extractByKey(execution, ResourceKey.PNF); - aaiPnfResources.checkIfPnfExistsInAaiAndCanBeUsed(pnf.getPnfName()); + aaiPnfResources.checkIfPnfExistsInAaiAndCanBeUsed(pnf); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); aaiPnfResources.createPnfAndConnectServiceInstance(pnf, serviceInstance); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java index cc630232c2..6c989093ab 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java @@ -90,6 +90,13 @@ public class AAIUpdateTasks { } /** + * BPMN access method to update status of Pnf to Inventoried in AAI + */ + public void updateOrchestrationStatusInventoriedPnf(BuildingBlockExecution execution) { + updateOrchestrationStatusForPnf(execution, OrchestrationStatus.INVENTORIED); + } + + /** * BPMN access method to update status of Pnf to Active in AAI */ public void updateOrchestrationStatusActivePnf(BuildingBlockExecution execution) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/SdncInputParametersProvider.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/SdncInputParametersProvider.java index 6831a656a8..92ed61df67 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/SdncInputParametersProvider.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/SdncInputParametersProvider.java @@ -50,11 +50,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; public class SdncInputParametersProvider extends AbstractInputParametersProvider<GenericVnf> { private static final Logger LOGGER = LoggerFactory.getLogger(SdncInputParametersProvider.class); - private static final String VNF_PARAMETERS_PATH = "$..vnf-parameters"; - private final SDNCClient sdncClient; - private final ObjectMapper mapper; @Autowired @@ -68,34 +65,12 @@ public class SdncInputParametersProvider extends AbstractInputParametersProvider final String vnfName = genericVnf.getVnfName(); final String vnfType = getVnfType(genericVnf); final String url = getPreloadVnfsUrl(vnfName, vnfType); + final InputParameter inputParameter = parseInputParametersUsingUrl(url); - try { - LOGGER.debug("Will query sdnc for input parameters using url: {}", url); - final String jsonResponse = sdncClient.get(url); - final String json = JsonPathUtil.getInstance().locateResult(jsonResponse, VNF_PARAMETERS_PATH).orElse(null); - - try { - - if (json != null) { - final List<VnfParameter> vnfParametersArray = - mapper.readValue(json, new TypeReference<List<VnfParameter>>() {}); - final Map<String, String> vnfParametersMap = getVnfParameterMap(vnfParametersArray); - final Map<String, String> additionalParameters = getAdditionalParameters(vnfParametersMap); - final List<ExternalVirtualLink> extVirtualLinks = getExtVirtualLinks(vnfParametersMap); - final InputParameter inputParameter = new InputParameter(additionalParameters, extVirtualLinks); - LOGGER.info("InputParameter found in sdnc response : {}", inputParameter); - return inputParameter; - } - - } catch (final IOException exception) { - LOGGER.error("Unable to parse vnf parameters : {}", json, exception); - } - } catch (final Exception exception) { - LOGGER.error("Unable to retrieve/parse input parameters using URL: {} ", url, exception); - } + if (inputParameter != null) + return inputParameter; LOGGER.warn("No input parameters found ..."); return NullInputParameter.NULL_INSTANCE; - } private List<ExternalVirtualLink> getExtVirtualLinks(final Map<String, String> vnfParametersMap) { @@ -109,19 +84,18 @@ public class SdncInputParametersProvider extends AbstractInputParametersProvider private Map<String, String> getAdditionalParameters(final Map<String, String> vnfParametersMap) { final String additionalParamsString = vnfParametersMap.get(ADDITIONAL_PARAMS); + if (additionalParamsString != null && !additionalParamsString.isEmpty()) { return parseAdditionalParameters(additionalParamsString); } return Collections.emptyMap(); } - private Map<String, String> getVnfParameterMap(final List<VnfParameter> array) { if (array != null) { return array.stream().filter(vnfParam -> vnfParam.getName() != null && vnfParam.getValue() != null) .collect(Collectors.toMap(VnfParameter::getName, VnfParameter::getValue)); } - return Collections.emptyMap(); } @@ -131,10 +105,43 @@ public class SdncInputParametersProvider extends AbstractInputParametersProvider private String getVnfType(final GenericVnf genericVnf) { final ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf(); - if (modelInfoGenericVnf != null && modelInfoGenericVnf.getModelName() != null) { + if (modelInfoGenericVnf != null) { return modelInfoGenericVnf.getModelName(); } return genericVnf.getVnfType(); } + private InputParameter parseInputParametersUsingUrl(String url) { + try { + LOGGER.debug("Will query sdnc for input parameters using url: {}", url); + final String jsonResponse = sdncClient.get(url); + final String json = JsonPathUtil.getInstance().locateResult(jsonResponse, VNF_PARAMETERS_PATH).orElse(null); + final InputParameter inputParameter = parseVnfParameters(json); + + if (inputParameter != null) + return inputParameter; + } catch (final Exception exception) { + LOGGER.error("Unable to retrieve/parse input parameters using URL: {} ", url, exception); + } + return null; + } + + private InputParameter parseVnfParameters(String json) { + try { + if (json != null) { + final List<VnfParameter> vnfParametersArray = + mapper.readValue(json, new TypeReference<List<VnfParameter>>() {}); + final Map<String, String> vnfParametersMap = getVnfParameterMap(vnfParametersArray); + final Map<String, String> additionalParameters = getAdditionalParameters(vnfParametersMap); + final List<ExternalVirtualLink> extVirtualLinks = getExtVirtualLinks(vnfParametersMap); + final InputParameter inputParameter = new InputParameter(additionalParameters, extVirtualLinks); + LOGGER.info("InputParameter found in sdnc response : {}", inputParameter); + return inputParameter; + } + + } catch (final IOException exception) { + LOGGER.error("Unable to parse vnf parameters : {}", json, exception); + } + return null; + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/UserParamInputParametersProvider.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/UserParamInputParametersProvider.java index ac939d04ec..bdd738b031 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/UserParamInputParametersProvider.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/UserParamInputParametersProvider.java @@ -40,12 +40,12 @@ public class UserParamInputParametersProvider extends AbstractInputParametersPro final InputParameter inputParameter = new InputParameter(); final Object additionalParams = userParams.get(ADDITIONAL_PARAMS); - if (additionalParams != null && additionalParams instanceof String) { + if (additionalParams instanceof String) { inputParameter.setAdditionalParams(parseAdditionalParameters(additionalParams.toString())); } final Object extVirtualLinks = userParams.get(EXT_VIRTUAL_LINKS); - if (extVirtualLinks != null && extVirtualLinks instanceof String) { + if (extVirtualLinks instanceof String) { inputParameter.setExtVirtualLinks(parseExternalVirtualLinks(extVirtualLinks.toString())); } LOGGER.info("InputParameter found in userParams : {}", inputParameter); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameter.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameter.java index 0d45dad6fe..2491c99bc4 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameter.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameter.java @@ -35,30 +35,18 @@ public class VnfParameter { @JsonProperty("vnf-parameter-value") private String value; - /** - * @return the name - */ public String getName() { return name; } - /** - * @param name the name to set - */ public void setName(final String name) { this.name = name; } - /** - * @return the value - */ public String getValue() { return value; } - /** - * @param value the value to set - */ public void setValue(final String value) { this.value = value; } @@ -66,10 +54,9 @@ public class VnfParameter { @Override public int hashCode() { final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((value == null) ? 0 : value.hashCode()); - return Objects.hash(name, value); + int nameResult = prime + ((name == null) ? 0 : name.hashCode()); + int valueResult = prime + ((value == null) ? 0 : value.hashCode()); + return Objects.hash(nameResult, valueResult); } @Override @@ -78,7 +65,6 @@ public class VnfParameter { VnfParameter other = (VnfParameter) obj; return Objects.equals(name, other.name) && Objects.equals(value, other.value); } - return false; } @@ -86,5 +72,4 @@ public class VnfParameter { public String toString() { return "VnfParameter [name=" + name + ", value=" + value + "]"; } - } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java index b337564dab..1f05522011 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java @@ -78,6 +78,9 @@ public class AppcOrchestratorPreProcessor { String identityUrl = execution.getVariable("identityUrl"); appcTaskRequest.setIdentityUrl(identityUrl); + String requestorId = gBBInput.getRequestContext().getRequestorId(); + appcTaskRequest.setRequestorId(requestorId); + if (gBBInput.getRequestContext().getRequestParameters() != null) { String payload = gBBInput.getRequestContext().getRequestParameters().getPayload(); if (payload == null) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java index 754c377914..c56ab3e71d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java @@ -23,18 +23,24 @@ package org.onap.so.bpmn.infrastructure.flowspecific.tasks; import java.util.Optional; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.exception.BBObjectNotFoundException; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.db.catalog.beans.BBNameSelectionReference; +import org.onap.so.db.catalog.beans.PnfResourceCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import static org.onap.so.client.cds.PayloadConstants.PRC_BLUEPRINT_NAME; +import static org.onap.so.client.cds.PayloadConstants.PRC_BLUEPRINT_VERSION; + @Component public class ControllerExecution { @@ -44,6 +50,8 @@ public class ControllerExecution { private static final String SCOPE = "scope"; private static final String ACTION = "action"; private static final String BBNAME = "bbName"; + private static final String MSO_REQUEST_ID = "msoRequestId"; + @Autowired private ExceptionBuilder exceptionUtil; @Autowired @@ -57,26 +65,43 @@ public class ControllerExecution { * @param execution - BuildingBlockExecution object */ public void setControllerActorScopeAction(BuildingBlockExecution execution) { + + ExecuteBuildingBlock executeBuildingBlock = execution.getVariable(BUILDING_BLOCK); + BuildingBlock buildingBlock = executeBuildingBlock.getBuildingBlock(); + + String scope = Optional.ofNullable(buildingBlock.getBpmnScope()).orElseThrow( + () -> new NullPointerException("BPMN Scope is NULL in the orchestration_flow_reference table ")); + String action = Optional.ofNullable(buildingBlock.getBpmnAction()).orElseThrow( + () -> new NullPointerException("BPMN Action is NULL in the orchestration_flow_reference table ")); + String controllerActor; + try { - GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); - String modelUuid = genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid(); - VnfResourceCustomization vnfResourceCustomization = - catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(modelUuid); - - // Fetching Controller Actor at VNF level if null then Controller Actor is set as "APPC" - String controllerActor = Optional.ofNullable(vnfResourceCustomization.getControllerActor()).orElse("APPC"); - ExecuteBuildingBlock executeBuildingBlock = execution.getVariable(BUILDING_BLOCK); - BuildingBlock buildingBlock = executeBuildingBlock.getBuildingBlock(); - String scope = Optional.ofNullable(buildingBlock.getBpmnScope()).orElseThrow( - () -> new NullPointerException("BPMN Scope is NULL in the orchestration_flow_reference table ")); - String action = Optional.ofNullable(buildingBlock.getBpmnAction()).orElseThrow( - () -> new NullPointerException("BPMN Action is NULL in the orchestration_flow_reference table ")); + if (String.valueOf(scope).equals("pnf")) { + Pnf pnf = getPnf(execution); + String pnfModelUUID = pnf.getModelInfoPnf().getModelCustomizationUuid(); + PnfResourceCustomization pnfResourceCustomization = + catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(pnfModelUUID); + + controllerActor = Optional.ofNullable(pnfResourceCustomization.getControllerActor()).orElse("APPC"); + execution.setVariable(MSO_REQUEST_ID, + execution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId()); + execution.setVariable(PRC_BLUEPRINT_VERSION, pnfResourceCustomization.getBlueprintVersion()); + execution.setVariable(PRC_BLUEPRINT_NAME, pnfResourceCustomization.getBlueprintName()); + } else { + GenericVnf genericVnf = getGenericVnf(execution); + String modelUuid = genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid(); + VnfResourceCustomization vnfResourceCustomization = + catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(modelUuid); + + controllerActor = Optional.ofNullable(vnfResourceCustomization.getControllerActor()).orElse("APPC"); + } + execution.setVariable(SCOPE, scope); execution.setVariable(ACTION, action); execution.setVariable(CONTROLLER_ACTOR, controllerActor); + logger.debug("Executing Controller Execution for ControllerActor: {}, Scope: {} , Action: {}", controllerActor, scope, action); - } catch (Exception ex) { logger.error("An exception occurred while fetching Controller Actor,Scope and Action ", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); @@ -106,4 +131,12 @@ public class ControllerExecution { } } + + private Pnf getPnf(BuildingBlockExecution buildingBlockExecution) throws BBObjectNotFoundException { + return extractPojosForBB.extractByKey(buildingBlockExecution, ResourceKey.PNF); + } + + private GenericVnf getGenericVnf(BuildingBlockExecution buildingBlockExecution) throws BBObjectNotFoundException { + return extractPojosForBB.extractByKey(buildingBlockExecution, ResourceKey.GENERIC_VNF_ID); + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfDispatcher.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfDispatcher.java new file mode 100644 index 0000000000..72a8590ad5 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfDispatcher.java @@ -0,0 +1,174 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.flowspecific.tasks; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.aai.domain.yang.Pnf; +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.db.catalog.beans.PnfResourceCustomization; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.*; + +/** + * This implementation of {@link JavaDelegate} is used to populate the execution object for pnf actions + */ +@Component +public class GenericPnfDispatcher implements JavaDelegate { + + private final Logger logger = LoggerFactory.getLogger(getClass()); + private static final String SERVICE_INSTANCE_NAME = "serviceInstanceName"; + private static final String BPMN_REQUEST = "bpmnRequest"; + private static final String RESOURCE_CUSTOMIZATION_UUID_PARAM = "resource_customization_uuid"; + private static final String PNF_NAME = "pnfName"; + + // ERROR CODE for variable not found in the delegation Context + private static final int ERROR_CODE = 601; + + @Autowired + private PnfManagement pnfManagement; + + @Autowired + private ExceptionBuilder exceptionUtil; + + @Autowired + private CatalogDbClient catalogDbClient; + + @Autowired + private ObjectMapper mapper; + + @Override + public void execute(DelegateExecution delegateExecution) throws Exception { + logger.debug("Running execute block for activity id: {}, name: {}", delegateExecution.getCurrentActivityId(), + delegateExecution.getCurrentActivityName()); + + RequestDetails bpmnRequestDetails = requestVerification(delegateExecution); + + final String serviceInstanceName = bpmnRequestDetails.getRequestInfo().getInstanceName(); + final String pnfName; + if (delegateExecution.getVariable(PNF_NAME) == null + || String.valueOf(delegateExecution.getVariable(PNF_NAME)).trim().isEmpty()) { + pnfName = bpmnRequestDetails.getRequestParameters().getUserParamValue(PNF_NAME); + } else { + pnfName = String.valueOf(delegateExecution.getVariable(PNF_NAME)); + } + final String serviceModelUuid = bpmnRequestDetails.getModelInfo().getModelUuid(); + final List<Map<String, Object>> userParams = bpmnRequestDetails.getRequestParameters().getUserParams(); + final Pnf pnf = getPnfByPnfName(delegateExecution, pnfName); + final List<PnfResourceCustomization> pnfCustomizations = + getPnfResourceCustomizations(delegateExecution, serviceModelUuid); + final PnfResourceCustomization pnfResourceCustomization = pnfCustomizations.get(0); + final String payload = bpmnRequestDetails.getRequestParameters().getPayload(); + + populateExecution(delegateExecution, bpmnRequestDetails, pnfResourceCustomization, pnf, serviceInstanceName, + pnfName, serviceModelUuid, userParams, payload); + + logger.trace("Completed dispatcher request for PNF."); + } + + private RequestDetails requestVerification(DelegateExecution delegateExecution) throws IOException { + RequestDetails bpmnRequestDetails = mapper.readValue( + JsonUtils.getJsonValue(String.valueOf(delegateExecution.getVariable(BPMN_REQUEST)), "requestDetails"), + RequestDetails.class); + + throwIfNull(delegateExecution, bpmnRequestDetails.getModelInfo(), SERVICE_MODEL_INFO); + throwIfNull(delegateExecution, bpmnRequestDetails.getRequestInfo(), "RequestInfo"); + throwIfNull(delegateExecution, bpmnRequestDetails.getRequestParameters(), "RequestParameters"); + throwIfNull(delegateExecution, bpmnRequestDetails.getRequestParameters().getUserParams(), "UserParams"); + + return bpmnRequestDetails; + } + + private void populateExecution(DelegateExecution delegateExecution, RequestDetails bpmnRequestDetails, + PnfResourceCustomization pnfResourceCustomization, Pnf pnf, String serviceInstanceName, String pnfName, + String serviceModelUuid, List<Map<String, Object>> userParams, String payload) { + + delegateExecution.setVariable(SERVICE_MODEL_INFO, bpmnRequestDetails.getModelInfo()); + delegateExecution.setVariable(SERVICE_INSTANCE_NAME, serviceInstanceName); + delegateExecution.setVariable(PNF_CORRELATION_ID, pnfName); + delegateExecution.setVariable(MODEL_UUID, serviceModelUuid); + delegateExecution.setVariable(PNF_UUID, pnf.getPnfId()); + delegateExecution.setVariable(PRC_BLUEPRINT_NAME, pnfResourceCustomization.getBlueprintName()); + delegateExecution.setVariable(PRC_BLUEPRINT_VERSION, pnfResourceCustomization.getBlueprintVersion()); + delegateExecution.setVariable(PRC_CUSTOMIZATION_UUID, pnfResourceCustomization.getModelCustomizationUUID()); + delegateExecution.setVariable(RESOURCE_CUSTOMIZATION_UUID_PARAM, + pnfResourceCustomization.getModelCustomizationUUID()); + delegateExecution.setVariable(PRC_INSTANCE_NAME, pnfResourceCustomization.getModelInstanceName()); + delegateExecution.setVariable(PRC_CONTROLLER_ACTOR, pnfResourceCustomization.getControllerActor()); + + for (Map<String, Object> param : userParams) { + if (param.containsKey("name") && param.containsKey("value")) { + delegateExecution.setVariable(param.get("name").toString(), param.get("value").toString()); + } + } + + delegateExecution.setVariable(REQUEST_PAYLOAD, payload); + } + + private Pnf getPnfByPnfName(DelegateExecution delegateExecution, String pnfName) { + Optional<Pnf> pnfOptional = Optional.empty(); + try { + pnfOptional = pnfManagement.getEntryFor(pnfName); + } catch (IOException e) { + throwExceptionWithWarn(delegateExecution, "Unable to fetch from AAI" + e.getMessage()); + } + if (!pnfOptional.isPresent()) { + throwExceptionWithWarn(delegateExecution, "AAI entry for PNF: " + pnfName + " does not exist"); + } + return pnfOptional.get(); + } + + private List<PnfResourceCustomization> getPnfResourceCustomizations(DelegateExecution delegateExecution, + String serviceModelUuid) { + List<PnfResourceCustomization> pnfCustomizations = + catalogDbClient.getPnfResourceCustomizationByModelUuid(serviceModelUuid); + + if (pnfCustomizations == null || pnfCustomizations.isEmpty()) { + throwExceptionWithWarn(delegateExecution, + "Unable to find the PNF resource customizations of model service UUID: " + serviceModelUuid); + } + return pnfCustomizations; + } + + private void throwIfNull(DelegateExecution delegateExecution, Object obj, String param) { + if (obj == null) { + throwExceptionWithWarn(delegateExecution, + "Unable to find the parameter: " + param + " in the execution context"); + } + } + + private void throwExceptionWithWarn(DelegateExecution delegateExecution, String exceptionMsg) { + logger.warn(exceptionMsg); + exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, exceptionMsg); + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GCTopologyOperationRequestMapper.java index 6af8c2f9c5..5b6043f303 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GCTopologyOperationRequestMapper.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import java.net.URI; import java.util.UUID; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GeneralTopologyObjectMapper.java index a9611cbde5..48a384c48a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GeneralTopologyObjectMapper.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import java.util.List; import java.util.Map; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/NetworkTopologyOperationRequestMapper.java index b1c95154c6..593c15d6cc 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/NetworkTopologyOperationRequestMapper.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import java.util.Map; import java.util.UUID; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/ServiceTopologyOperationMapper.java index b5957b3009..69606393c3 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/ServiceTopologyOperationMapper.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import java.util.Map; import java.util.UUID; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java index f6642ab76a..901187e231 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java @@ -20,7 +20,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import java.net.URI; import java.util.Map; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VnfTopologyOperationRequestMapper.java index fd0af3a4dd..c2dcb8f290 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VnfTopologyOperationRequestMapper.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import java.net.URI; import java.util.ArrayList; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/AbstractServiceLevelPreparable.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/AbstractServiceLevelPreparable.java new file mode 100644 index 0000000000..36db549486 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/AbstractServiceLevelPreparable.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.service.level; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.client.exception.ExceptionBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import java.util.ArrayList; +import java.util.List; + +/** + * Abstract class for Service level upgrade Execution, it should be extended for service level upgrade tasks. + */ +public abstract class AbstractServiceLevelPreparable { + + protected static final String WORKFLOW_TO_INVOKE = "healthCheckWorkflow"; + protected static final String GENERIC_PNF_HEALTH_CHECK_WORKFLOW = "GenericPnfHealthCheck"; + protected static final String GENERIC_PNF_SOFTWARE_UPGRADE_WORKFLOW = "GenericPnfSoftwareUpgrade"; + protected static final String RESOURCE_TYPE = "RESOURCE_TYPE"; + protected static final int ERROR_CODE = 601; + + // TODO This value needs to be updated once vnf health check workflow is available + protected static final String GENERIC_VNF_HEALTH_CHECK_WORKFLOW = "GenericVNFHealthCheck"; + + protected static final Logger LOG = LoggerFactory.getLogger(AbstractServiceLevelPreparable.class); + + @Autowired + protected ExceptionBuilder exceptionBuilder; + + /** + * This method fetches workflow names to be invoked based on the controller scope . + * + * @param scope Controller scope + * @return String value of Workflow name + */ + protected abstract String fetchWorkflowUsingScope(DelegateExecution execution, final String scope); + + /** + * This method validates the execution parameters to be passed for health check workflow. + * + * @param execution Delegate execution obj + * @param scope Controller scope * Throws workflow exception if validation fails + */ + protected void validateParamsWithScope(DelegateExecution execution, final String scope, List<String> params) + throws Exception { + List<String> invalidVariables = new ArrayList<>(); + for (String param : params) { + if (!execution.hasVariable(param) || execution.getVariable(param) == null + || String.valueOf(execution.getVariable(param)).isEmpty()) { + invalidVariables.add(param); + } + } + if (invalidVariables.size() > 0) { + LOG.error("Validation error for the {} health check attributes: {}", scope, invalidVariables); + exceptionBuilder.buildAndThrowWorkflowException(execution, ERROR_CODE, + "Validation of health check workflow parameters failed for the scope: " + scope); + } + + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java new file mode 100644 index 0000000000..52521ce16b --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.service.level.impl; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.so.bpmn.infrastructure.service.level.AbstractServiceLevelPreparable; +import org.springframework.stereotype.Component; +import java.util.Arrays; +import java.util.List; + + +/** + * Fetches health check workflow based on the controller_scope. Invoke the corresponding health check workflow after + * validation. + */ +@Component("ServiceLevelPreparation") +public class ServiceLevelPreparation extends AbstractServiceLevelPreparable implements JavaDelegate { + + // Health check parameters to be validated for pnf resource + private static final List<String> PNF_HC_PARAMS = Arrays.asList("SERVICE_MODEL_INFO", "SERVICE_INSTANCE_NAME", + "PNF_CORRELATION_ID", "MODEL_UUID", "PNF_UUID", "PRC_BLUEPRINT_NAME", "PRC_BLUEPRINT_VERSION", + "PRC_CUSTOMIZATION_UUID", "RESOURCE_CUSTOMIZATION_UUID_PARAM", "PRC_INSTANCE_NAME", "PRC_CONTROLLER_ACTOR", + "REQUEST_PAYLOAD"); + + @Override + public void execute(DelegateExecution execution) throws Exception { + if (execution.hasVariable(RESOURCE_TYPE) && execution.getVariable(RESOURCE_TYPE) != null) { + final String controllerScope = (String) execution.getVariable(RESOURCE_TYPE); + LOG.debug("Scope retrieved from delegate execution: " + controllerScope); + final String wflName = fetchWorkflowUsingScope(execution, controllerScope); + LOG.debug("Health check workflow fetched for the scope: {}", wflName); + validateParamsWithScope(execution, controllerScope, PNF_HC_PARAMS); + LOG.info("Parameters validated successfully for {}", wflName); + execution.setVariable(WORKFLOW_TO_INVOKE, wflName); + } else { + exceptionBuilder.buildAndThrowWorkflowException(execution, ERROR_CODE, + "Controller scope not found to invoke resource level health check"); + } + } + + @Override + public String fetchWorkflowUsingScope(DelegateExecution execution, final String scope) { + String wflName = null; + switch (scope.toLowerCase()) { + case "pnf": + wflName = GENERIC_PNF_HEALTH_CHECK_WORKFLOW; + break; + case "vnf": + wflName = GENERIC_VNF_HEALTH_CHECK_WORKFLOW; + break; + default: + exceptionBuilder.buildAndThrowWorkflowException(execution, ERROR_CODE, + "No valid health check work flow retrieved for the scope: " + scope); + } + return wflName; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ConfigBuildingBlocksDataObject.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ConfigBuildingBlocksDataObject.java index 1852485083..7f754e3f13 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ConfigBuildingBlocksDataObject.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ConfigBuildingBlocksDataObject.java @@ -20,27 +20,24 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; -import java.util.List; import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlockBase; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; import org.onap.so.serviceinstancebeans.RequestDetails; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; +import java.io.Serializable; +import java.util.List; -public class ConfigBuildingBlocksDataObject { +public class ConfigBuildingBlocksDataObject extends BuildingBlockBase<ConfigBuildingBlocksDataObject> + implements Serializable { - private ServiceInstancesRequest sIRequest; + private static final long serialVersionUID = 3L; + private DelegateExecution execution; private List<OrchestrationFlow> orchFlows; - private String requestId; private Resource resourceKey; - private String apiVersion; - private String resourceId; - private String requestAction; - private boolean aLaCarte; - private String vnfType; - private WorkflowResourceIds workflowResourceIds; - private RequestDetails requestDetails; - private DelegateExecution execution; + private ServiceInstancesRequest sIRequest; + private ReplaceInstanceRelatedInformation replaceInformation; public ServiceInstancesRequest getsIRequest() { return sIRequest; @@ -60,15 +57,6 @@ public class ConfigBuildingBlocksDataObject { return this; } - public String getRequestId() { - return requestId; - } - - public ConfigBuildingBlocksDataObject setRequestId(String requestId) { - this.requestId = requestId; - return this; - } - public Resource getResourceKey() { return resourceKey; } @@ -78,75 +66,21 @@ public class ConfigBuildingBlocksDataObject { return this; } - public String getApiVersion() { - return apiVersion; - } - - public ConfigBuildingBlocksDataObject setApiVersion(String apiVersion) { - this.apiVersion = apiVersion; - return this; - } - - public String getResourceId() { - return resourceId; - } - - public ConfigBuildingBlocksDataObject setResourceId(String resourceId) { - this.resourceId = resourceId; - return this; - } - - public String getRequestAction() { - return requestAction; - } - - public ConfigBuildingBlocksDataObject setRequestAction(String requestAction) { - this.requestAction = requestAction; - return this; - } - - public boolean isaLaCarte() { - return aLaCarte; - } - - public ConfigBuildingBlocksDataObject setaLaCarte(boolean aLaCarte) { - this.aLaCarte = aLaCarte; - return this; - } - - public String getVnfType() { - return vnfType; - } - - public ConfigBuildingBlocksDataObject setVnfType(String vnfType) { - this.vnfType = vnfType; - return this; - } - - public WorkflowResourceIds getWorkflowResourceIds() { - return workflowResourceIds; - } - - public ConfigBuildingBlocksDataObject setWorkflowResourceIds(WorkflowResourceIds workflowResourceIds) { - this.workflowResourceIds = workflowResourceIds; - return this; - } - - public RequestDetails getRequestDetails() { - return requestDetails; + public DelegateExecution getExecution() { + return execution; } - public ConfigBuildingBlocksDataObject setRequestDetails(RequestDetails requestDetails) { - this.requestDetails = requestDetails; + public ConfigBuildingBlocksDataObject setExecution(DelegateExecution execution) { + this.execution = execution; return this; } - public DelegateExecution getExecution() { - return execution; + public ReplaceInstanceRelatedInformation getReplaceInformation() { + return replaceInformation; } - public ConfigBuildingBlocksDataObject setExecution(DelegateExecution execution) { - this.execution = execution; + public ConfigBuildingBlocksDataObject setReplaceInformation(ReplaceInstanceRelatedInformation replaceInformation) { + this.replaceInformation = replaceInformation; return this; } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java index e2dd73f9ec..f233de2baa 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java @@ -11,9 +11,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. @@ -24,9 +24,15 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; -import java.util.EnumSet; -import java.util.Set; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.exception.BBObjectNotFoundException; @@ -45,6 +51,8 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.web.client.HttpClientErrorException; +import java.util.EnumSet; +import java.util.Set; @Component public class OrchestrationStatusValidator { @@ -57,9 +65,6 @@ public class OrchestrationStatusValidator { private static final String ORCHESTRATION_VALIDATION_FAIL = "Orchestration Status Validation failed. ResourceType=(%s), TargetAction=(%s), OrchestrationStatus=(%s)"; private static final String ORCHESTRATION_STATUS_VALIDATION_RESULT = "orchestrationStatusValidationResult"; - private static final String ALACARTE = "aLaCarte"; - private static final String MULTI_STAGE_DESIGN_OFF = "false"; - private static final String MULTI_STAGE_DESIGN_ON = "true"; private static final String RESOURCE_EXIST_STATUS_MESSAGE = "The %s was found to already exist, thus no new %s was created in the cloud via this request"; private static final String RESOURCE_NOT_EXIST_STATUS_MESSAGE = @@ -79,20 +84,11 @@ public class OrchestrationStatusValidator { /** * This method validate's the status of the OrchestrationStatus against the buildingBlockDetail ResourceType - * - * @param execution */ public void validateOrchestrationStatus(BuildingBlockExecution execution) { try { - OrchestrationStatusValidationDirective previousOrchestrationStatusValidationResult = - execution.getVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT); - execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, null); - - boolean aLaCarte = (boolean) execution.getVariable(ALACARTE); - String buildingBlockFlowName = execution.getFlowToBeCalled(); - BuildingBlockDetail buildingBlockDetail = catalogDbClient.getBuildingBlockDetail(buildingBlockFlowName); if (buildingBlockDetail == null) { @@ -100,63 +96,10 @@ public class OrchestrationStatusValidator { String.format(BUILDING_BLOCK_DETAIL_NOT_FOUND, buildingBlockFlowName)); } - OrchestrationStatus orchestrationStatus; - - switch (buildingBlockDetail.getResourceType()) { - case SERVICE: - org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstance = - extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); - orchestrationStatus = serviceInstance.getOrchestrationStatus(); - break; - case VNF: - org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf genericVnf = - extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); - orchestrationStatus = genericVnf.getOrchestrationStatus(); - break; - case VF_MODULE: - org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = - extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); - orchestrationStatus = vfModule.getOrchestrationStatus(); - break; - case VOLUME_GROUP: - org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup = - extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID); - orchestrationStatus = volumeGroup.getOrchestrationStatus(); - break; - case NETWORK: - org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network = - extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID); - orchestrationStatus = network.getOrchestrationStatus(); - break; - case NETWORK_COLLECTION: - org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInst = - extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); - org.onap.so.bpmn.servicedecomposition.bbobjects.Collection networkCollection = - serviceInst.getCollection(); - orchestrationStatus = networkCollection.getOrchestrationStatus(); - break; - case CONFIGURATION: - org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration configuration = - extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID); - orchestrationStatus = configuration.getOrchestrationStatus(); - break; - case INSTANCE_GROUP: - org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup instanceGroup = - extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID); - orchestrationStatus = instanceGroup.getOrchestrationStatus(); - break; - case NO_VALIDATE: - // short circuit and exit method - execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, - OrchestrationStatusValidationDirective.VALIDATION_SKIPPED); - return; - default: - // can't currently get here, so not tested. Added in case enum is expanded - // without a change to this - // code - throw new OrchestrationStatusValidationException( - String.format(UNKNOWN_RESOURCE_TYPE, buildingBlockFlowName, - buildingBlockDetail.getResourceType(), buildingBlockDetail.getTargetAction())); + OrchestrationStatus orchestrationStatus = + getOrchestrationStatus(execution, buildingBlockFlowName, buildingBlockDetail); + if (buildingBlockDetail.getResourceType().equals(ResourceType.NO_VALIDATE)) { + return; } if (orchestrationStatus == null) { @@ -199,6 +142,66 @@ public class OrchestrationStatusValidator { } } + private OrchestrationStatus getOrchestrationStatus(BuildingBlockExecution execution, String buildingBlockFlowName, + BuildingBlockDetail buildingBlockDetail) + throws BBObjectNotFoundException, OrchestrationStatusValidationException { + OrchestrationStatus orchestrationStatus = null; + + switch (buildingBlockDetail.getResourceType()) { + case SERVICE: + ServiceInstance serviceInstance = + extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); + orchestrationStatus = serviceInstance.getOrchestrationStatus(); + break; + case VNF: + GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); + orchestrationStatus = genericVnf.getOrchestrationStatus(); + break; + case VF_MODULE: + VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); + orchestrationStatus = vfModule.getOrchestrationStatus(); + break; + case VOLUME_GROUP: + VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID); + orchestrationStatus = volumeGroup.getOrchestrationStatus(); + break; + case NETWORK: + L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID); + orchestrationStatus = network.getOrchestrationStatus(); + break; + case NETWORK_COLLECTION: + Collection networkCollection = getNetworkCollection(execution); + orchestrationStatus = networkCollection.getOrchestrationStatus(); + break; + case CONFIGURATION: + Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID); + orchestrationStatus = configuration.getOrchestrationStatus(); + break; + case INSTANCE_GROUP: + InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID); + orchestrationStatus = instanceGroup.getOrchestrationStatus(); + break; + case NO_VALIDATE: + // short circuit and exit method + execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, + OrchestrationStatusValidationDirective.VALIDATION_SKIPPED); + break; + default: + // can't currently get here, so not tested. Added in case enum is expanded + // without a change to this + // code + throw new OrchestrationStatusValidationException( + String.format(UNKNOWN_RESOURCE_TYPE, buildingBlockFlowName, + buildingBlockDetail.getResourceType(), buildingBlockDetail.getTargetAction())); + } + return orchestrationStatus; + } + + private Collection getNetworkCollection(BuildingBlockExecution execution) throws BBObjectNotFoundException { + ServiceInstance serviceInst = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); + return serviceInst.getCollection(); + } + private void updatedResourceStatus(BuildingBlockExecution execution, BuildingBlockDetail buildingBlockDetail) { if (cloudResources.contains(buildingBlockDetail.getResourceType())) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ReplaceInstanceRelatedInformation.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ReplaceInstanceRelatedInformation.java new file mode 100644 index 0000000000..d9e8fa55fa --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ReplaceInstanceRelatedInformation.java @@ -0,0 +1,16 @@ +package org.onap.so.bpmn.infrastructure.workflow.tasks; + +public class ReplaceInstanceRelatedInformation { + + private String oldVolumeGroupName; + + public String getOldVolumeGroupName() { + return oldVolumeGroupName; + } + + public ReplaceInstanceRelatedInformation setOldVolumeGroupName(String oldVolumeGroupName) { + this.oldVolumeGroupName = oldVolumeGroupName; + return this; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index b4eb97a187..44a99b88c5 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -37,6 +37,7 @@ import java.util.UUID; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; +import org.apache.commons.lang3.SerializationUtils; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.javatuples.Pair; import org.onap.aai.domain.yang.GenericVnf; @@ -75,6 +76,7 @@ import org.onap.so.db.catalog.beans.CollectionResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.CvnfcCustomization; +import org.onap.so.db.catalog.beans.InstanceGroup; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; @@ -143,6 +145,8 @@ public class WorkflowAction { private static final String VOLUMEGROUP_DELETE_PATTERN = "(Un|De)(.*)Volume(.*)"; private static final String VOLUMEGROUP_CREATE_PATTERN = "(A|C)(.*)Volume(.*)"; private static final String CONTROLLER = "Controller"; + private static final String DEFAULT_CLOUD_OWNER = "org.onap.so.cloud-owner"; + private static final String HOMING = "homing"; @Autowired protected BBInputSetup bbInputSetup; @@ -158,10 +162,8 @@ public class WorkflowAction { private WorkflowActionExtractResourcesAAI workflowActionUtils; @Autowired private VrfValidation vrfValidation; - @Autowired private Environment environment; - private String defaultCloudOwner = "org.onap.so.cloud-owner"; public void setBbInputSetupUtils(BBInputSetupUtils bbInputSetupUtils) { this.bbInputSetupUtils = bbInputSetupUtils; @@ -176,30 +178,33 @@ public class WorkflowAction { final String bpmnRequest = (String) execution.getVariable(BBConstants.G_BPMN_REQUEST); ServiceInstancesRequest sIRequest = new ObjectMapper().readValue(bpmnRequest, ServiceInstancesRequest.class); - RequestDetails requestDetails = sIRequest.getRequestDetails(); - String uri = (String) execution.getVariable(BBConstants.G_URI); + final String requestId = (String) execution.getVariable(BBConstants.G_REQUEST_ID); - final boolean aLaCarte = (boolean) execution.getVariable(BBConstants.G_ALACARTE); + + String uri = (String) execution.getVariable(BBConstants.G_URI); boolean isResume = isUriResume(uri); - String requestAction = (String) execution.getVariable(BBConstants.G_ACTION); + + final boolean isALaCarte = (boolean) execution.getVariable(BBConstants.G_ALACARTE); + Resource resource = getResource(bbInputSetupUtils, isResume, isALaCarte, uri, requestId); + WorkflowResourceIds workflowResourceIds = populateResourceIdsFromApiHandler(execution); - Resource resource = getResource(bbInputSetupUtils, isResume, aLaCarte, uri, requestId); + RequestDetails requestDetails = sIRequest.getRequestDetails(); + String requestAction = (String) execution.getVariable(BBConstants.G_ACTION); String resourceId = getResourceId(resource, requestAction, requestDetails, workflowResourceIds); WorkflowType resourceType = resource.getResourceType(); + String serviceInstanceId = getServiceInstanceId(execution, resourceId, resourceType); + fillExecution(execution, requestDetails.getRequestInfo().getSuppressRollback(), resourceId, resourceType); List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); - if (isRequestMacroServiceResume(aLaCarte, resourceType, requestAction, serviceInstanceId)) { - flowsToExecute = bbInputSetupUtils.loadOriginalFlowExecutionPath(requestId); - if (flowsToExecute == null) { - buildAndThrowException(execution, "Could not resume Macro flow. Error loading execution path."); - } - } else if (aLaCarte && isResume) { - flowsToExecute = bbInputSetupUtils.loadOriginalFlowExecutionPath(requestId); - if (flowsToExecute == null) { - buildAndThrowException(execution, - "Could not resume request with request Id: " + requestId + ". No flowsToExecute was found"); - } + + if (isRequestMacroServiceResume(isALaCarte, resourceType, requestAction, serviceInstanceId)) { + String errorMessage = "Could not resume Macro flow. Error loading execution path."; + flowsToExecute = loadExecuteBuildingBlocks(execution, requestId, errorMessage); + } else if (isALaCarte && isResume) { + String errorMessage = + "Could not resume request with request Id: " + requestId + ". No flowsToExecute was found"; + flowsToExecute = loadExecuteBuildingBlocks(execution, requestId, errorMessage); } else { String vnfType = (String) execution.getVariable(VNF_TYPE); String cloudOwner = getCloudOwner(requestDetails.getCloudConfiguration()); @@ -208,51 +213,42 @@ public class WorkflowAction { final String apiVersion = (String) execution.getVariable(BBConstants.G_APIVERSION); final String serviceType = Optional.ofNullable((String) execution.getVariable(BBConstants.G_SERVICE_TYPE)).orElse(""); - if (aLaCarte) { + if (isALaCarte) { if (orchFlows == null || orchFlows.isEmpty()) { orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, true, cloudOwner, serviceType); } - String key = ""; - ModelInfo modelInfo = sIRequest.getRequestDetails().getModelInfo(); - if (modelInfo != null) { - if (modelInfo.getModelType().equals(ModelType.service)) { - key = modelInfo.getModelVersionId(); - } else { - key = modelInfo.getModelCustomizationId(); - } - } - boolean isConfiguration = isConfiguration(orchFlows); - Resource resourceKey = new Resource(resourceType, key, true); - if (isConfiguration && !requestAction.equalsIgnoreCase(CREATEINSTANCE)) { - List<ExecuteBuildingBlock> configBuildingBlocks = getConfigBuildingBlocks( - new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest).setOrchFlows(orchFlows) - .setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion) - .setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(true) - .setVnfType(vnfType).setWorkflowResourceIds(workflowResourceIds) - .setRequestDetails(requestDetails).setExecution(execution)); - - flowsToExecute.addAll(configBuildingBlocks); - } - orchFlows = orchFlows.stream().filter(item -> !item.getFlowName().contains(FABRIC_CONFIGURATION)) - .collect(Collectors.toList()); + Resource resourceKey = getResourceKey(sIRequest, resourceType); + ReplaceInstanceRelatedInformation replaceInfo = new ReplaceInstanceRelatedInformation(); if ((requestAction.equalsIgnoreCase(REPLACEINSTANCE) || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)) && resourceType.equals(WorkflowType.VFMODULE)) { logger.debug("Build a BB list for replacing BB modules"); - orchFlows = getVfModuleReplaceBuildingBlocks( - new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest).setOrchFlows(orchFlows) - .setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion) - .setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(true) - .setVnfType(vnfType).setWorkflowResourceIds(workflowResourceIds) - .setRequestDetails(requestDetails).setExecution(execution)); - } - for (OrchestrationFlow orchFlow : orchFlows) { - ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, - apiVersion, resourceId, requestAction, true, vnfType, workflowResourceIds, - requestDetails, false, null, null, false); - flowsToExecute.add(ebb); + ConfigBuildingBlocksDataObject cbbdo = createConfigBuildingBlocksDataObject(execution, + sIRequest, requestId, workflowResourceIds, requestDetails, requestAction, resourceId, + vnfType, orchFlows, apiVersion, resourceKey, replaceInfo); + orchFlows = getVfModuleReplaceBuildingBlocks(cbbdo); + + createBuildingBlocksForOrchFlows(execution, sIRequest, requestId, workflowResourceIds, + requestDetails, requestAction, resourceId, flowsToExecute, vnfType, orchFlows, + apiVersion, resourceKey, replaceInfo); + } else { + if (isConfiguration(orchFlows) && !requestAction.equalsIgnoreCase(CREATEINSTANCE)) { + addConfigBuildingBlocksToFlowsToExecuteList(execution, sIRequest, requestId, + workflowResourceIds, requestDetails, requestAction, resourceId, flowsToExecute, + vnfType, apiVersion, resourceKey, replaceInfo, orchFlows); + } + orchFlows = + orchFlows.stream().filter(item -> !item.getFlowName().contains(FABRIC_CONFIGURATION)) + .collect(Collectors.toList()); + + for (OrchestrationFlow orchFlow : orchFlows) { + ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, + apiVersion, resourceId, requestAction, true, vnfType, workflowResourceIds, + requestDetails, false, null, null, false, replaceInfo); + flowsToExecute.add(ebb); + } } } else { boolean foundRelated = false; @@ -263,13 +259,7 @@ public class WorkflowAction { // SERVICE-MACRO-ASSIGN will always get user params with a // service. if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) { - List<Map<String, Object>> userParams = - sIRequest.getRequestDetails().getRequestParameters().getUserParams(); - for (Map<String, Object> params : userParams) { - if (params.containsKey(USERPARAMSERVICE)) { - containsService = true; - } - } + containsService = isContainsService(sIRequest); if (containsService) { traverseUserParamsService(execution, resourceList, sIRequest, requestAction); } @@ -285,13 +275,7 @@ public class WorkflowAction { // queries the SI and finds a VNF, macro fails. if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) { - List<Map<String, Object>> userParams = - sIRequest.getRequestDetails().getRequestParameters().getUserParams(); - for (Map<String, Object> params : userParams) { - if (params.containsKey(USERPARAMSERVICE)) { - containsService = true; - } - } + containsService = isContainsService(sIRequest); } if (containsService) { foundRelated = traverseUserParamsService(execution, resourceList, sIRequest, requestAction); @@ -312,43 +296,41 @@ public class WorkflowAction { } else if (resourceType == WorkflowType.SERVICE && "deactivateInstance".equalsIgnoreCase(requestAction)) { resourceList.add(new Resource(WorkflowType.SERVICE, "", false)); - } else if (resourceType == WorkflowType.VNF && ("replaceInstance".equalsIgnoreCase(requestAction) + } else if (resourceType == WorkflowType.VNF && (REPLACEINSTANCE.equalsIgnoreCase(requestAction) || ("recreateInstance".equalsIgnoreCase(requestAction)))) { traverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(), workflowResourceIds.getVnfId(), aaiResourceIds); } else { buildAndThrowException(execution, "Current Macro Request is not supported"); } - String foundObjects = ""; + StringBuilder foundObjects = new StringBuilder(); for (WorkflowType type : WorkflowType.values()) { - foundObjects = foundObjects + type + " - " + resourceList.stream() - .filter(x -> type.equals(x.getResourceType())).collect(Collectors.toList()).size() - + " "; + foundObjects.append(type).append(" - ").append( + (int) resourceList.stream().filter(x -> type.equals(x.getResourceType())).count()) + .append(" "); } logger.info("Found {}", foundObjects); if (orchFlows == null || orchFlows.isEmpty()) { - orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte, + orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, isALaCarte, cloudOwner, serviceType); } boolean vnfReplace = false; - if (resourceType.equals(WorkflowType.VNF) && ("replaceInstance".equalsIgnoreCase(requestAction) - || "replaceInstanceRetainAssignments".equalsIgnoreCase(requestAction))) { + if (resourceType.equals(WorkflowType.VNF) && (REPLACEINSTANCE.equalsIgnoreCase(requestAction) + || REPLACEINSTANCERETAINASSIGNMENTS.equalsIgnoreCase(requestAction))) { vnfReplace = true; } flowsToExecute = buildExecuteBuildingBlockList(orchFlows, resourceList, requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, vnfReplace); - if (!resourceList.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()) - .collect(Collectors.toList()).isEmpty()) { + if (isNetworkCollectionInTheResourceList(resourceList)) { logger.info("Sorting for Vlan Tagging"); flowsToExecute = sortExecutionPathByObjectForVlanTagging(flowsToExecute, requestAction); } // By default, enable homing at VNF level for CREATEINSTANCE and ASSIGNINSTANCE if (resourceType == WorkflowType.SERVICE && (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE)) - && !resourceList.stream().filter(x -> WorkflowType.VNF.equals(x.getResourceType())) - .collect(Collectors.toList()).isEmpty()) { - execution.setVariable("homing", true); + && resourceList.stream().anyMatch(x -> WorkflowType.VNF.equals(x.getResourceType()))) { + execution.setVariable(HOMING, true); execution.setVariable("calledHoming", false); } if (resourceType == WorkflowType.SERVICE && (requestAction.equalsIgnoreCase(ASSIGNINSTANCE) @@ -364,15 +346,10 @@ public class WorkflowAction { // enable it. if (sIRequest.getRequestDetails().getRequestParameters() != null && sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) { - List<Map<String, Object>> userParams = - sIRequest.getRequestDetails().getRequestParameters().getUserParams(); + List<Map<String, Object>> userParams = getListOfUserParams(sIRequest); for (Map<String, Object> params : userParams) { if (params.containsKey(HOMINGSOLUTION)) { - if ("none".equals(params.get(HOMINGSOLUTION))) { - execution.setVariable("homing", false); - } else { - execution.setVariable("homing", true); - } + execution.setVariable(HOMING, !"none".equals(params.get(HOMINGSOLUTION))); } } } @@ -392,12 +369,7 @@ public class WorkflowAction { if (!isResume) { bbInputSetupUtils.persistFlowExecutionPath(requestId, flowsToExecute); } - execution.setVariable("flowNames", flowNames); - execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, 0); - execution.setVariable("retryCount", 0); - execution.setVariable("isRollback", false); - execution.setVariable("flowsToExecute", flowsToExecute); - execution.setVariable("isRollbackComplete", false); + setExecutionVariables(execution, flowsToExecute, flowNames); } catch (Exception ex) { if (!(execution.hasVariable("WorkflowException") @@ -409,12 +381,104 @@ public class WorkflowAction { } } + private void setExecutionVariables(DelegateExecution execution, List<ExecuteBuildingBlock> flowsToExecute, + List<String> flowNames) { + execution.setVariable("flowNames", flowNames); + execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, 0); + execution.setVariable("retryCount", 0); + execution.setVariable("isRollback", false); + execution.setVariable("flowsToExecute", flowsToExecute); + execution.setVariable("isRollbackComplete", false); + } + + private boolean isContainsService(ServiceInstancesRequest sIRequest) { + boolean containsService; + List<Map<String, Object>> userParams = getListOfUserParams(sIRequest); + containsService = userParams.stream().anyMatch(param -> param.containsKey(USERPARAMSERVICE)); + return containsService; + } + + private List<Map<String, Object>> getListOfUserParams(ServiceInstancesRequest sIRequest) { + return sIRequest.getRequestDetails().getRequestParameters().getUserParams(); + } + + private List<ExecuteBuildingBlock> loadExecuteBuildingBlocks(DelegateExecution execution, String requestId, + String errorMessage) { + List<ExecuteBuildingBlock> flowsToExecute; + flowsToExecute = bbInputSetupUtils.loadOriginalFlowExecutionPath(requestId); + if (flowsToExecute == null) { + buildAndThrowException(execution, errorMessage); + } + return flowsToExecute; + } + + private ConfigBuildingBlocksDataObject createConfigBuildingBlocksDataObject(DelegateExecution execution, + ServiceInstancesRequest sIRequest, String requestId, WorkflowResourceIds workflowResourceIds, + RequestDetails requestDetails, String requestAction, String resourceId, String vnfType, + List<OrchestrationFlow> orchFlows, String apiVersion, Resource resourceKey, + ReplaceInstanceRelatedInformation replaceInfo) { + + return new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest).setOrchFlows(orchFlows) + .setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion).setResourceId(resourceId) + .setRequestAction(requestAction).setaLaCarte(true).setVnfType(vnfType) + .setWorkflowResourceIds(workflowResourceIds).setRequestDetails(requestDetails).setExecution(execution) + .setReplaceInformation(replaceInfo); + } + + private void createBuildingBlocksForOrchFlows(DelegateExecution execution, ServiceInstancesRequest sIRequest, + String requestId, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, + String requestAction, String resourceId, List<ExecuteBuildingBlock> flowsToExecute, String vnfType, + List<OrchestrationFlow> orchFlows, String apiVersion, Resource resourceKey, + ReplaceInstanceRelatedInformation replaceInfo) throws Exception { + + for (OrchestrationFlow orchFlow : orchFlows) { + if (orchFlow.getFlowName().contains(CONFIGURATION)) { + List<OrchestrationFlow> configOrchFlows = new ArrayList<>(); + configOrchFlows.add(orchFlow); + addConfigBuildingBlocksToFlowsToExecuteList(execution, sIRequest, requestId, workflowResourceIds, + requestDetails, requestAction, resourceId, flowsToExecute, vnfType, apiVersion, resourceKey, + replaceInfo, configOrchFlows); + } else { + ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, + resourceId, requestAction, true, vnfType, workflowResourceIds, requestDetails, false, null, + null, false, replaceInfo); + flowsToExecute.add(ebb); + } + } + } + + private void addConfigBuildingBlocksToFlowsToExecuteList(DelegateExecution execution, + ServiceInstancesRequest sIRequest, String requestId, WorkflowResourceIds workflowResourceIds, + RequestDetails requestDetails, String requestAction, String resourceId, + List<ExecuteBuildingBlock> flowsToExecute, String vnfType, String apiVersion, Resource resourceKey, + ReplaceInstanceRelatedInformation replaceInfo, List<OrchestrationFlow> configOrchFlows) throws Exception { + + ConfigBuildingBlocksDataObject cbbdo = createConfigBuildingBlocksDataObject(execution, sIRequest, requestId, + workflowResourceIds, requestDetails, requestAction, resourceId, vnfType, configOrchFlows, apiVersion, + resourceKey, replaceInfo); + List<ExecuteBuildingBlock> configBuildingBlocks = getConfigBuildingBlocks(cbbdo); + flowsToExecute.addAll(configBuildingBlocks); + } + + private Resource getResourceKey(ServiceInstancesRequest sIRequest, WorkflowType resourceType) { + String resourceId = ""; + ModelInfo modelInfo = sIRequest.getRequestDetails().getModelInfo(); + if (modelInfo != null) { + if (modelInfo.getModelType().equals(ModelType.service)) { + resourceId = modelInfo.getModelVersionId(); + } else { + resourceId = modelInfo.getModelCustomizationId(); + } + } + return new Resource(resourceType, resourceId, true); + } + private String getCloudOwner(CloudConfiguration cloudConfiguration) { if (cloudConfiguration != null && cloudConfiguration.getCloudOwner() != null) { return cloudConfiguration.getCloudOwner(); } logger.warn("cloud owner value not found in request details, it will be set as default"); - return environment.getProperty(defaultCloudOwner); + return environment.getProperty(DEFAULT_CLOUD_OWNER); } protected <T> List<T> getRelatedResourcesInVfModule(String vnfId, String vfModuleId, Class<T> resultClass, @@ -436,9 +500,8 @@ public class WorkflowAction { return vnfcs; } - protected <T> List<T> getRelatedResourcesInVnfc(Vnfc vnfc, Class<T> resultClass, AAIObjectType type) { - - List<T> configurations = new ArrayList<>(); + protected <T> T getRelatedResourcesInVnfc(Vnfc vnfc, Class<T> resultClass, AAIObjectType type) throws Exception { + T configuration = null; AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfc.getVnfcName()); AAIResultWrapper vnfcResultsWrapper = bbInputSetupUtils.getAAIResourceDepthOne(uri); Optional<Relationships> relationshipsOp = vnfcResultsWrapper.getRelationships(); @@ -448,12 +511,19 @@ public class WorkflowAction { Relationships relationships = relationshipsOp.get(); List<AAIResultWrapper> configurationResultWrappers = this.getResultWrappersFromRelationships(relationships, type); - for (AAIResultWrapper configurationResultWrapper : configurationResultWrappers) { - Optional<T> configurationOp = configurationResultWrapper.asBean(resultClass); - configurationOp.ifPresent(configurations::add); + if (configurationResultWrappers.size() > 1) { + String multipleRelationshipsError = + "Multiple relationships exist from VNFC " + vnfc.getVnfcName() + " to Configurations"; + throw new Exception(multipleRelationshipsError); + } + if (!configurationResultWrappers.isEmpty()) { + Optional<T> configurationOp = configurationResultWrappers.get(0).asBean(resultClass); + if (configurationOp.isPresent()) { + configuration = configurationOp.get(); + } } } - return configurations; + return configuration; } protected List<AAIResultWrapper> getResultWrappersFromRelationships(Relationships relationships, @@ -480,7 +550,7 @@ public class WorkflowAction { String vfModuleId = dataObj.getWorkflowResourceIds().getVfModuleId(); String vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId(); - String vfModuleCustomizationUUID = ""; + String vfModuleCustomizationUUID; org.onap.aai.domain.yang.VfModule aaiVfModule = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId); if (aaiVfModule == null) { @@ -495,32 +565,26 @@ public class WorkflowAction { List<org.onap.aai.domain.yang.Vnfc> vnfcs = getRelatedResourcesInVfModule(vnfId, vfModuleId, org.onap.aai.domain.yang.Vnfc.class, AAIObjectType.VNFC); for (org.onap.aai.domain.yang.Vnfc vnfc : vnfcs) { - List<org.onap.aai.domain.yang.Configuration> configurations = getRelatedResourcesInVnfc(vnfc, + WorkflowResourceIds workflowIdsCopy = SerializationUtils.clone(dataObj.getWorkflowResourceIds()); + org.onap.aai.domain.yang.Configuration configuration = getRelatedResourcesInVnfc(vnfc, org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION); - if (configurations.size() > 1) { - String multipleRelationshipsError = - "Multiple relationships exist from VNFC " + vnfc.getVnfcName() + " to Configurations"; - buildAndThrowException(dataObj.getExecution(), "Exception in getConfigBuildingBlock: ", - new Exception(multipleRelationshipsError)); - } - for (org.onap.aai.domain.yang.Configuration configuration : configurations) { - dataObj.getWorkflowResourceIds().setConfigurationId(configuration.getConfigurationId()); - for (OrchestrationFlow orchFlow : result) { - dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID); - dataObj.getResourceKey().setCvnfModuleCustomizationId(vnfc.getModelCustomizationId()); - dataObj.getResourceKey().setVnfCustomizationId(vnfCustomizationUUID); - String vnfcName = getVnfcNameForConfiguration(configuration); - if (vnfcName == null || vnfcName.isEmpty()) { - buildAndThrowException(dataObj.getExecution(), "Exception in create execution list " - + ": VnfcName does not exist or is null while there is a configuration for the vfModule", - new Exception("Vnfc and Configuration do not match")); - } - ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, dataObj.getRequestId(), - dataObj.getResourceKey(), dataObj.getApiVersion(), dataObj.getResourceId(), - dataObj.getRequestAction(), dataObj.isaLaCarte(), dataObj.getVnfType(), - dataObj.getWorkflowResourceIds(), dataObj.getRequestDetails(), false, null, vnfcName, true); - flowsToExecuteConfigs.add(ebb); + workflowIdsCopy.setConfigurationId(configuration.getConfigurationId()); + for (OrchestrationFlow orchFlow : result) { + dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID); + dataObj.getResourceKey().setCvnfModuleCustomizationId(vnfc.getModelCustomizationId()); + dataObj.getResourceKey().setVnfCustomizationId(vnfCustomizationUUID); + String vnfcName = vnfc.getVnfcName(); + if (vnfcName == null || vnfcName.isEmpty()) { + buildAndThrowException(dataObj.getExecution(), "Exception in create execution list " + + ": VnfcName does not exist or is null while there is a configuration for the vfModule", + new Exception("Vnfc and Configuration do not match")); } + ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, dataObj.getRequestId(), + dataObj.getResourceKey(), dataObj.getApiVersion(), dataObj.getResourceId(), + dataObj.getRequestAction(), dataObj.isaLaCarte(), dataObj.getVnfType(), workflowIdsCopy, + dataObj.getRequestDetails(), false, null, vnfcName, true, null); + flowsToExecuteConfigs.add(ebb); + } } return flowsToExecuteConfigs; @@ -541,17 +605,18 @@ public class WorkflowAction { boolean rebuildVolumeGroups = false; if (dataObj.getRequestDetails().getRequestParameters() != null && dataObj.getRequestDetails().getRequestParameters().getRebuildVolumeGroups() != null) { - rebuildVolumeGroups = - dataObj.getRequestDetails().getRequestParameters().getRebuildVolumeGroups().booleanValue(); + rebuildVolumeGroups = dataObj.getRequestDetails().getRequestParameters().getRebuildVolumeGroups(); } - + String volumeGroupName = ""; Optional<VolumeGroup> volumeGroupFromVfModule = bbInputSetupUtils.getRelatedVolumeGroupFromVfModule(vnfId, vfModuleId); if (volumeGroupFromVfModule.isPresent()) { String volumeGroupId = volumeGroupFromVfModule.get().getVolumeGroupId(); + volumeGroupName = volumeGroupFromVfModule.get().getVolumeGroupName(); logger.debug("Volume group id of the existing volume group is: " + volumeGroupId); volumeGroupExisted = true; dataObj.getWorkflowResourceIds().setVolumeGroupId(volumeGroupId); + dataObj.getReplaceInformation().setOldVolumeGroupName(volumeGroupName); } List<OrchestrationFlow> orchFlows = dataObj.getOrchFlows(); @@ -564,6 +629,7 @@ public class WorkflowAction { if (!volumeGroupExisted) { String newVolumeGroupId = UUID.randomUUID().toString(); dataObj.getWorkflowResourceIds().setVolumeGroupId(newVolumeGroupId); + dataObj.getReplaceInformation().setOldVolumeGroupName(volumeGroupName); logger.debug("newVolumeGroupId: " + newVolumeGroupId); } } @@ -586,23 +652,6 @@ public class WorkflowAction { return orchFlows; } - protected String getVnfcNameForConfiguration(org.onap.aai.domain.yang.Configuration configuration) { - AAIResultWrapper wrapper = new AAIResultWrapper(configuration); - Optional<Relationships> relationshipsOp = wrapper.getRelationships(); - if (!relationshipsOp.isPresent()) { - logger.debug("No relationships were found for Configuration in AAI"); - return null; - } - Relationships relationships = relationshipsOp.get(); - List<AAIResultWrapper> vnfcResultWrappers = relationships.getByType(AAIObjectType.VNFC); - if (vnfcResultWrappers.size() > 1 || vnfcResultWrappers.isEmpty()) { - logger.debug("Too many vnfcs or no vnfc found that are related to configuration"); - } - Optional<Vnfc> vnfcOp = vnfcResultWrappers.get(0).asBean(Vnfc.class); - return vnfcOp.map(Vnfc::getVnfcName).orElse(null); - - } - protected List<Resource> sortVfModulesByBaseFirst(List<Resource> vfModuleResources) { int count = 0; for (Resource resource : vfModuleResources) { @@ -633,11 +682,10 @@ public class WorkflowAction { logger.debug(pair.getValue0() + ", " + pair.getValue1()); } - Arrays.stream(WorkflowType.values()).filter(type -> !type.equals(WorkflowType.SERVICE)).forEach(type -> { - resourceList.stream().filter(resource -> type.equals(resource.getResourceType())) - .forEach(resource -> updateWorkflowResourceIds(flowsToExecute, type, resource.getResourceId(), - retrieveAAIResourceId(aaiResourceIds, type), null, serviceInstanceId)); - }); + Arrays.stream(WorkflowType.values()).filter(type -> !type.equals(WorkflowType.SERVICE)) + .forEach(type -> resourceList.stream().filter(resource -> type.equals(resource.getResourceType())) + .forEach(resource -> updateWorkflowResourceIds(flowsToExecute, type, resource.getResourceId(), + retrieveAAIResourceId(aaiResourceIds, type), null, serviceInstanceId))); } private String retrieveAAIResourceId(List<Pair<WorkflowType, String>> aaiResourceIds, WorkflowType resource) { @@ -654,11 +702,10 @@ public class WorkflowAction { private void generateResourceIds(List<ExecuteBuildingBlock> flowsToExecute, List<Resource> resourceList, String serviceInstanceId) { - Arrays.stream(WorkflowType.values()).filter(type -> !type.equals(WorkflowType.SERVICE)).forEach(type -> { - resourceList.stream().filter(resource -> type.equals(resource.getResourceType())) - .forEach(resource -> updateWorkflowResourceIds(flowsToExecute, type, resource.getResourceId(), null, - resource.getVirtualLinkKey(), serviceInstanceId)); - }); + Arrays.stream(WorkflowType.values()).filter(type -> !type.equals(WorkflowType.SERVICE)) + .forEach(type -> resourceList.stream().filter(resource -> type.equals(resource.getResourceType())) + .forEach(resource -> updateWorkflowResourceIds(flowsToExecute, type, resource.getResourceId(), + null, resource.getVirtualLinkKey(), serviceInstanceId))); } protected void updateWorkflowResourceIds(List<ExecuteBuildingBlock> flowsToExecute, WorkflowType resourceType, @@ -799,88 +846,125 @@ public class WorkflowAction { protected void traverseNetworkCollection(DelegateExecution execution, List<Resource> resourceList, org.onap.so.db.catalog.beans.Service service) { - if (service.getVnfCustomizations() == null || service.getVnfCustomizations().isEmpty()) { - List<CollectionResourceCustomization> customizations = service.getCollectionResourceCustomizations(); - if (customizations.isEmpty()) { - logger.debug("No Collections found. CollectionResourceCustomization list is empty."); - } else { - CollectionResourceCustomization collectionResourceCustomization = - findCatalogNetworkCollection(execution, service); - if (collectionResourceCustomization != null) { - resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, - collectionResourceCustomization.getModelCustomizationUUID(), false)); - logger.debug("Found a network collection"); - if (collectionResourceCustomization.getCollectionResource() != null) { - if (collectionResourceCustomization.getCollectionResource().getInstanceGroup() != null) { - String toscaNodeType = collectionResourceCustomization.getCollectionResource() - .getInstanceGroup().getToscaNodeType(); - if (toscaNodeType != null && toscaNodeType.contains(NETWORKCOLLECTION)) { - int minNetworks = 0; - org.onap.so.db.catalog.beans.InstanceGroup instanceGroup = - collectionResourceCustomization.getCollectionResource().getInstanceGroup(); - CollectionResourceInstanceGroupCustomization collectionInstCust = null; - if (!instanceGroup.getCollectionInstanceGroupCustomizations().isEmpty()) { - for (CollectionResourceInstanceGroupCustomization collectionInstanceGroupTemp : instanceGroup - .getCollectionInstanceGroupCustomizations()) { - if (collectionInstanceGroupTemp.getModelCustomizationUUID().equalsIgnoreCase( - collectionResourceCustomization.getModelCustomizationUUID())) { - collectionInstCust = collectionInstanceGroupTemp; - break; - } - } - if (collectionInstCust != null - && collectionInstCust.getSubInterfaceNetworkQuantity() != null) { - minNetworks = collectionInstCust.getSubInterfaceNetworkQuantity(); - } - } - logger.debug("minNetworks: {}", minNetworks); - CollectionNetworkResourceCustomization collectionNetworkResourceCust = null; - for (CollectionNetworkResourceCustomization collectionNetworkTemp : instanceGroup - .getCollectionNetworkResourceCustomizations()) { - if (collectionNetworkTemp.getNetworkResourceCustomization() - .getModelCustomizationUUID().equalsIgnoreCase( - collectionResourceCustomization.getModelCustomizationUUID())) { - collectionNetworkResourceCust = collectionNetworkTemp; - break; - } - } - for (int i = 0; i < minNetworks; i++) { - if (collectionNetworkResourceCust != null && collectionInstCust != null) { - Resource resource = new Resource(WorkflowType.VIRTUAL_LINK, - collectionNetworkResourceCust.getModelCustomizationUUID(), false); - resource.setVirtualLinkKey(Integer.toString(i)); - resourceList.add(resource); - } - } - } else { - logger.debug("Instance Group tosca node type does not contain NetworkCollection: {}", - toscaNodeType); - } - } else { - logger.debug("No Instance Group found for network collection."); - } - } else { - logger.debug("No Network Collection found. collectionResource is null"); - } - } else { - logger.debug("No Network Collection Customization found"); + if (isVnfCustomizationsInTheService(service)) { + buildAndThrowException(execution, + "Cannot orchestrate Service-Macro-Create without user params with a vnf. Please update ASDC model for new macro orchestration support or add service_recipe records to route to old macro flows"); + } + List<CollectionResourceCustomization> customizations = service.getCollectionResourceCustomizations(); + if (customizations.isEmpty()) { + logger.debug("No Collections found. CollectionResourceCustomization list is empty."); + } else { + CollectionResourceCustomization collectionResourceCustomization = + findCatalogNetworkCollection(execution, service); + traverseNetworkCollectionResourceCustomization(resourceList, collectionResourceCustomization); + } + traverseNetworkCollectionCustomization(resourceList, service); + } + + private void traverseNetworkCollectionResourceCustomization(List<Resource> resourceList, + CollectionResourceCustomization collectionResourceCustomization) { + if (collectionResourceCustomizationShouldNotBeProcessed(resourceList, collectionResourceCustomization)) + return; + int minNetworks = 0; + org.onap.so.db.catalog.beans.InstanceGroup instanceGroup = + collectionResourceCustomization.getCollectionResource().getInstanceGroup(); + CollectionResourceInstanceGroupCustomization collectionInstCust = null; + if (!instanceGroup.getCollectionInstanceGroupCustomizations().isEmpty()) { + for (CollectionResourceInstanceGroupCustomization collectionInstanceGroupTemp : instanceGroup + .getCollectionInstanceGroupCustomizations()) { + if (collectionInstanceGroupTemp.getModelCustomizationUUID() + .equalsIgnoreCase(collectionResourceCustomization.getModelCustomizationUUID())) { + collectionInstCust = collectionInstanceGroupTemp; + break; } } - if (resourceList.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()) - .collect(Collectors.toList()).isEmpty()) { - if (service.getNetworkCustomizations() == null) { - logger.debug("No networks were found on this service model"); - } else { - for (int i = 0; i < service.getNetworkCustomizations().size(); i++) { - resourceList.add(new Resource(WorkflowType.NETWORK, - service.getNetworkCustomizations().get(i).getModelCustomizationUUID(), false)); - } - } + if (interfaceNetworkQuantityIsAvailableInCollection(collectionInstCust)) { + minNetworks = collectionInstCust.getSubInterfaceNetworkQuantity(); } - } else { - buildAndThrowException(execution, - "Cannot orchestrate Service-Macro-Create without user params with a vnf. Please update ASDC model for new macro orchestration support or add service_recipe records to route to old macro flows"); } + logger.debug("minNetworks: {}", minNetworks); + CollectionNetworkResourceCustomization collectionNetworkResourceCust = + getCollectionNetworkResourceCustomization(collectionResourceCustomization, instanceGroup); + for (int i = 0; i < minNetworks; i++) { + if (collectionNetworkResourceCust != null) { + Resource resource = new Resource(WorkflowType.VIRTUAL_LINK, + collectionNetworkResourceCust.getModelCustomizationUUID(), false); + resource.setVirtualLinkKey(Integer.toString(i)); + resourceList.add(resource); + } + } + } + + private CollectionNetworkResourceCustomization getCollectionNetworkResourceCustomization( + CollectionResourceCustomization collectionResourceCustomization, InstanceGroup instanceGroup) { + CollectionNetworkResourceCustomization collectionNetworkResourceCust = null; + for (CollectionNetworkResourceCustomization collectionNetworkTemp : instanceGroup + .getCollectionNetworkResourceCustomizations()) { + if (collectionNetworkTemp.getNetworkResourceCustomization().getModelCustomizationUUID() + .equalsIgnoreCase(collectionResourceCustomization.getModelCustomizationUUID())) { + collectionNetworkResourceCust = collectionNetworkTemp; + break; + } + } + return collectionNetworkResourceCust; + } + + private boolean collectionResourceCustomizationShouldNotBeProcessed(List<Resource> resourceList, + CollectionResourceCustomization collectionResourceCustomization) { + if (collectionResourceCustomization == null) { + logger.debug("No Network Collection Customization found"); + return true; + } + resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, + collectionResourceCustomization.getModelCustomizationUUID(), false)); + logger.debug("Found a network collection"); + if (collectionResourceCustomization.getCollectionResource() == null) { + logger.debug("No Network Collection found. collectionResource is null"); + return true; + } + if (collectionResourceCustomization.getCollectionResource().getInstanceGroup() == null) { + logger.debug("No Instance Group found for network collection."); + return true; + } + String toscaNodeType = + collectionResourceCustomization.getCollectionResource().getInstanceGroup().getToscaNodeType(); + if (!toscaNodeTypeHasNetworkCollection(toscaNodeType)) { + logger.debug("Instance Group tosca node type does not contain NetworkCollection: {}", toscaNodeType); + return true; + } + return false; + } + + private boolean interfaceNetworkQuantityIsAvailableInCollection( + CollectionResourceInstanceGroupCustomization collectionInstCust) { + return collectionInstCust != null && collectionInstCust.getSubInterfaceNetworkQuantity() != null; + } + + private boolean toscaNodeTypeHasNetworkCollection(String toscaNodeType) { + return toscaNodeType != null && toscaNodeType.contains(NETWORKCOLLECTION); + } + + private void traverseNetworkCollectionCustomization(List<Resource> resourceList, + org.onap.so.db.catalog.beans.Service service) { + if (isNetworkCollectionInTheResourceList(resourceList)) { + return; + } + if (service.getNetworkCustomizations() == null) { + logger.debug("No networks were found on this service model"); + return; + } + for (int i = 0; i < service.getNetworkCustomizations().size(); i++) { + resourceList.add(new Resource(WorkflowType.NETWORK, + service.getNetworkCustomizations().get(i).getModelCustomizationUUID(), false)); + } + } + + private boolean isNetworkCollectionInTheResourceList(List<Resource> resourceList) { + return resourceList.stream().anyMatch(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()); + } + + private boolean isVnfCustomizationsInTheService(org.onap.so.db.catalog.beans.Service service) { + return !(service.getVnfCustomizations() == null || service.getVnfCustomizations().isEmpty()); } protected void traverseAAIService(DelegateExecution execution, List<Resource> resourceList, String resourceId, @@ -890,28 +974,8 @@ public class WorkflowAction { org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = bbInputSetup.getExistingServiceInstance(serviceInstanceAAI); resourceList.add(new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false)); - if (serviceInstanceMSO.getVnfs() != null) { - for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO.getVnfs()) { - aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId())); - resourceList.add(new Resource(WorkflowType.VNF, vnf.getVnfId(), false)); - if (vnf.getVfModules() != null) { - for (VfModule vfModule : vnf.getVfModules()) { - aaiResourceIds.add(new Pair<>(WorkflowType.VFMODULE, vfModule.getVfModuleId())); - Resource resource = new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false); - resource.setBaseVfModule(vfModule.getModelInfoVfModule().getIsBaseBoolean()); - resourceList.add(resource); - } - } - if (vnf.getVolumeGroups() != null) { - for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf - .getVolumeGroups()) { - aaiResourceIds.add(new Pair<>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId())); - resourceList - .add(new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false)); - } - } - } - } + traverseServiceInstanceMSOVnfs(resourceList, aaiResourceIds, serviceInstanceMSO); + traverseServiceInstanceMSOPnfs(resourceList, aaiResourceIds, serviceInstanceMSO); if (serviceInstanceMSO.getNetworks() != null) { for (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network : serviceInstanceMSO .getNetworks()) { @@ -950,6 +1014,50 @@ public class WorkflowAction { } } + private void traverseServiceInstanceMSOVnfs(List<Resource> resourceList, + List<Pair<WorkflowType, String>> aaiResourceIds, + org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO) { + if (serviceInstanceMSO.getVnfs() == null) { + return; + } + for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO.getVnfs()) { + aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId())); + resourceList.add(new Resource(WorkflowType.VNF, vnf.getVnfId(), false)); + traverseVnfModules(resourceList, aaiResourceIds, vnf); + if (vnf.getVolumeGroups() != null) { + for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf.getVolumeGroups()) { + aaiResourceIds.add(new Pair<>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId())); + resourceList.add(new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false)); + } + } + } + } + + private void traverseServiceInstanceMSOPnfs(List<Resource> resourceList, + List<Pair<WorkflowType, String>> aaiResourceIds, + org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO) { + if (serviceInstanceMSO.getPnfs() == null) { + return; + } + for (org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf pnf : serviceInstanceMSO.getPnfs()) { + aaiResourceIds.add(new Pair<>(WorkflowType.PNF, pnf.getPnfId())); + resourceList.add(new Resource(WorkflowType.PNF, pnf.getPnfId(), false)); + } + } + + private void traverseVnfModules(List<Resource> resourceList, List<Pair<WorkflowType, String>> aaiResourceIds, + org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf) { + if (vnf.getVfModules() == null) { + return; + } + for (VfModule vfModule : vnf.getVfModules()) { + aaiResourceIds.add(new Pair<>(WorkflowType.VFMODULE, vfModule.getVfModuleId())); + Resource resource = new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false); + resource.setBaseVfModule(vfModule.getModelInfoVfModule().getIsBaseBoolean()); + resourceList.add(resource); + } + } + private void traverseAAIVnf(DelegateExecution execution, List<Resource> resourceList, String serviceId, String vnfId, List<Pair<WorkflowType, String>> aaiResourceIds) { try { @@ -1023,7 +1131,7 @@ public class WorkflowAction { String vnfCustomizationUUID = ""; String vfModuleCustomizationUUID = ""; if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) { - List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters().getUserParams(); + List<Map<String, Object>> userParams = getListOfUserParams(sIRequest); for (Map<String, Object> params : userParams) { if (params.containsKey(USERPARAMSERVICE)) { ObjectMapper obj = new ObjectMapper(); @@ -1051,23 +1159,18 @@ public class WorkflowAction { && vfModuleCustomization.getVolumeHeatEnv() != null) { resourceList.add(new Resource(WorkflowType.VOLUMEGROUP, vfModuleCustomization.getModelCustomizationUUID(), false)); - foundRelated = true; foundVfModuleOrVG = true; } if (vfModuleCustomization.getVfModule() != null && vfModuleCustomization.getVfModule().getModuleHeatTemplate() != null && vfModuleCustomization.getHeatEnvironment() != null) { - foundRelated = true; foundVfModuleOrVG = true; Resource resource = new Resource(WorkflowType.VFMODULE, vfModuleCustomization.getModelCustomizationUUID(), false); - if (vfModuleCustomization.getVfModule().getIsBase() != null - && vfModuleCustomization.getVfModule().getIsBase()) { - resource.setBaseVfModule(true); - } else { - resource.setBaseVfModule(false); - } + resource.setBaseVfModule( + vfModuleCustomization.getVfModule().getIsBase() != null + && vfModuleCustomization.getVfModule().getIsBase()); resourceList.add(resource); if (vfModule.getModelInfo() != null && vfModule.getModelInfo().getModelCustomizationUuid() != null) { @@ -1322,7 +1425,7 @@ public class WorkflowAction { resourceList.stream().filter(resource -> resource.getResourceType().equals(workflowType)) .forEach(resource -> flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, apiVersion, resourceId, requestAction, false, vnfType, workflowResourceIds, requestDetails, - isVirtualLink, resource.getVirtualLinkKey(), null, isConfiguration))); + isVirtualLink, resource.getVirtualLinkKey(), null, isConfiguration, null))); } protected List<ExecuteBuildingBlock> buildExecuteBuildingBlockList(List<OrchestrationFlow> orchFlows, @@ -1343,7 +1446,8 @@ public class WorkflowAction { addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VNF, orchFlow, requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, false); - } else if (orchFlow.getFlowName().contains(PNF)) { + } else if (orchFlow.getFlowName().contains(PNF) || (orchFlow.getFlowName().contains(CONTROLLER) + && (PNF).equalsIgnoreCase(orchFlow.getBpmnScope()))) { addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.PNF, orchFlow, requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, false); @@ -1357,7 +1461,7 @@ public class WorkflowAction { true, false); } else if (orchFlow.getFlowName().contains(VFMODULE) || (orchFlow.getFlowName().contains(CONTROLLER) && (VFMODULE).equalsIgnoreCase(orchFlow.getBpmnScope()))) { - List<Resource> vfModuleResourcesSorted = null; + List<Resource> vfModuleResourcesSorted; if (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE) || requestAction.equals("activateInstance")) { vfModuleResourcesSorted = sortVfModulesByBaseFirst(resourceList.stream() @@ -1366,10 +1470,10 @@ public class WorkflowAction { vfModuleResourcesSorted = sortVfModulesByBaseLast(resourceList.stream() .filter(x -> WorkflowType.VFMODULE == x.getResourceType()).collect(Collectors.toList())); } - for (int i = 0; i < vfModuleResourcesSorted.size(); i++) { - flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, vfModuleResourcesSorted.get(i), - apiVersion, resourceId, requestAction, false, vnfType, workflowResourceIds, requestDetails, - false, null, null, false)); + for (Resource resource : vfModuleResourcesSorted) { + flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, apiVersion, resourceId, + requestAction, false, vnfType, workflowResourceIds, requestDetails, false, null, null, + false, null)); } } else if (orchFlow.getFlowName().contains(VOLUMEGROUP)) { if (requestAction.equalsIgnoreCase(REPLACEINSTANCE) @@ -1389,8 +1493,9 @@ public class WorkflowAction { requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, true); } else { - flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, null, apiVersion, resourceId, - requestAction, false, vnfType, workflowResourceIds, requestDetails, false, null, null, false)); + flowsToExecute + .add(buildExecuteBuildingBlock(orchFlow, requestId, null, apiVersion, resourceId, requestAction, + false, vnfType, workflowResourceIds, requestDetails, false, null, null, false, null)); } } return flowsToExecute; @@ -1399,15 +1504,19 @@ public class WorkflowAction { protected ExecuteBuildingBlock buildExecuteBuildingBlock(OrchestrationFlow orchFlow, String requestId, Resource resource, String apiVersion, String resourceId, String requestAction, boolean aLaCarte, String vnfType, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, - boolean isVirtualLink, String virtualLinkKey, String vnfcName, boolean isConfiguration) { + boolean isVirtualLink, String virtualLinkKey, String vnfcName, boolean isConfiguration, + ReplaceInstanceRelatedInformation replaceInfo) { BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName(orchFlow.getFlowName()).setMsoId(UUID.randomUUID().toString()) .setIsVirtualLink(isVirtualLink).setVirtualLinkKey(virtualLinkKey) .setKey(Optional.ofNullable(resource).map(Resource::getResourceId).orElse("")); - Optional.ofNullable(orchFlow.getBpmnAction()).ifPresent(action -> buildingBlock.setBpmnAction(action)); - Optional.ofNullable(orchFlow.getBpmnScope()).ifPresent(scope -> buildingBlock.setBpmnScope(scope)); - + Optional.ofNullable(orchFlow.getBpmnAction()).ifPresent(buildingBlock::setBpmnAction); + Optional.ofNullable(orchFlow.getBpmnScope()).ifPresent(buildingBlock::setBpmnScope); + String oldVolumeGroupName = ""; + if (replaceInfo != null) { + oldVolumeGroupName = replaceInfo.getOldVolumeGroupName(); + } if (resource != null && (orchFlow.getFlowName().contains(VOLUMEGROUP) && (requestAction.equalsIgnoreCase(REPLACEINSTANCE) || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)))) { @@ -1418,19 +1527,24 @@ public class WorkflowAction { ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setApiVersion(apiVersion) .setaLaCarte(aLaCarte).setRequestAction(requestAction).setResourceId(resourceId).setVnfType(vnfType) .setWorkflowResourceIds(workflowResourceIds).setRequestId(requestId).setBuildingBlock(buildingBlock) - .setRequestDetails(requestDetails); + .setRequestDetails(requestDetails).setOldVolumeGroupName(oldVolumeGroupName); if (resource != null && (isConfiguration || resource.getResourceType().equals(WorkflowType.CONFIGURATION))) { - ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys(); - Optional.ofNullable(vnfcName).ifPresent(name -> configurationResourceKeys.setVnfcName(name)); - configurationResourceKeys.setCvnfcCustomizationUUID(resource.getCvnfModuleCustomizationId()); - configurationResourceKeys.setVfModuleCustomizationUUID(resource.getVfModuleCustomizationId()); - configurationResourceKeys.setVnfResourceCustomizationUUID(resource.getVnfCustomizationId()); + ConfigurationResourceKeys configurationResourceKeys = getConfigurationResourceKeys(resource, vnfcName); executeBuildingBlock.setConfigurationResourceKeys(configurationResourceKeys); } return executeBuildingBlock; } + private ConfigurationResourceKeys getConfigurationResourceKeys(Resource resource, String vnfcName) { + ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys(); + Optional.ofNullable(vnfcName).ifPresent(configurationResourceKeys::setVnfcName); + configurationResourceKeys.setCvnfcCustomizationUUID(resource.getCvnfModuleCustomizationId()); + configurationResourceKeys.setVfModuleCustomizationUUID(resource.getVfModuleCustomizationId()); + configurationResourceKeys.setVnfResourceCustomizationUUID(resource.getVnfCustomizationId()); + return configurationResourceKeys; + } + protected List<OrchestrationFlow> queryNorthBoundRequestCatalogDb(DelegateExecution execution, String requestAction, WorkflowType resourceName, boolean aLaCarte, String cloudOwner) { return this.queryNorthBoundRequestCatalogDb(execution, requestAction, resourceName, aLaCarte, cloudOwner, ""); @@ -1439,7 +1553,7 @@ public class WorkflowAction { protected List<OrchestrationFlow> queryNorthBoundRequestCatalogDb(DelegateExecution execution, String requestAction, WorkflowType resourceName, boolean aLaCarte, String cloudOwner, String serviceType) { List<OrchestrationFlow> listToExecute = new ArrayList<>(); - NorthBoundRequest northBoundRequest = null; + NorthBoundRequest northBoundRequest; if (serviceType.equalsIgnoreCase(SERVICE_TYPE_TRANSPORT) || serviceType.equalsIgnoreCase(SERVICE_TYPE_BONDING)) { northBoundRequest = @@ -1520,7 +1634,7 @@ public class WorkflowAction { } protected String validateServiceResourceIdInAAI(String generatedResourceId, String instanceName, - RequestDetails reqDetails) throws DuplicateNameException, MultipleObjectsFoundException { + RequestDetails reqDetails) throws DuplicateNameException { String globalCustomerId = reqDetails.getSubscriberInfo().getGlobalSubscriberId(); String serviceType = reqDetails.getRequestParameters().getSubscriptionServiceType(); if (instanceName != null) { @@ -1584,8 +1698,7 @@ public class WorkflowAction { } protected String validateVnfResourceIdInAAI(String generatedResourceId, String instanceName, - RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) - throws DuplicateNameException, MultipleObjectsFoundException { + RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException { Optional<GenericVnf> vnf = bbInputSetupUtils .getRelatedVnfByNameFromServiceInstance(workflowResourceIds.getServiceInstanceId(), instanceName); if (vnf.isPresent()) { @@ -1629,8 +1742,7 @@ public class WorkflowAction { } protected String validateVolumeGroupResourceIdInAAI(String generatedResourceId, String instanceName, - RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) - throws DuplicateNameException, MultipleObjectsFoundException { + RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException { Optional<VolumeGroup> volumeGroup = bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf(workflowResourceIds.getVnfId(), instanceName); if (volumeGroup.isPresent()) { @@ -1648,8 +1760,7 @@ public class WorkflowAction { } protected String validateConfigurationResourceIdInAAI(String generatedResourceId, String instanceName, - RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) - throws DuplicateNameException, MultipleObjectsFoundException { + RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException { Optional<org.onap.aai.domain.yang.Configuration> configuration = bbInputSetupUtils.getRelatedConfigurationByNameFromServiceInstance( workflowResourceIds.getServiceInstanceId(), instanceName); @@ -1671,7 +1782,7 @@ public class WorkflowAction { private void fillExecution(DelegateExecution execution, boolean suppressRollback, String resourceId, WorkflowType resourceType) { execution.setVariable("sentSyncResponse", false); - execution.setVariable("homing", false); + execution.setVariable(HOMING, false); execution.setVariable("calledHoming", false); execution.setVariable(BBConstants.G_ISTOPLEVELFLOW, true); execution.setVariable("suppressRollback", suppressRollback); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index 0ddafa0b44..7420df144a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -20,20 +20,12 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.UUID; -import javax.persistence.EntityNotFoundException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.aai.domain.yang.InstanceGroup; -import org.onap.aai.domain.yang.L3Network; -import org.onap.aai.domain.yang.ServiceInstance; -import org.onap.aai.domain.yang.VfModule; -import org.onap.aai.domain.yang.Vnfc; -import org.onap.aai.domain.yang.VolumeGroup; +import org.onap.aai.domain.yang.*; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.entities.Configuration; import org.onap.so.bpmn.common.DelegateExecutionImpl; import org.onap.so.bpmn.common.listener.db.RequestsDbListenerRunner; import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner; @@ -44,8 +36,6 @@ import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.aai.entities.Configuration; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; @@ -58,8 +48,13 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; +import javax.persistence.EntityNotFoundException; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.UUID; +import java.util.stream.Collectors; @Component public class WorkflowActionBBTasks { @@ -74,6 +69,8 @@ public class WorkflowActionBBTasks { private static final String COMPLETED = "completed"; private static final String HANDLINGCODE = "handlingCode"; private static final String ROLLBACKTOCREATED = "RollbackToCreated"; + private static final String REPLACEINSTANCE = "replaceInstance"; + private static final String VFMODULE = "VfModule"; protected String maxRetries = "mso.rainyDay.maxRetries"; private static final Logger logger = LoggerFactory.getLogger(WorkflowActionBBTasks.class); @@ -106,11 +103,7 @@ public class WorkflowActionBBTasks { execution.setVariable("buildingBlock", ebb); currentSequence++; - if (currentSequence >= flowsToExecute.size()) { - execution.setVariable(COMPLETED, true); - } else { - execution.setVariable(COMPLETED, false); - } + execution.setVariable(COMPLETED, currentSequence >= flowsToExecute.size()); execution.setVariable(G_CURRENT_SEQUENCE, currentSequence); } @@ -150,7 +143,7 @@ public class WorkflowActionBBTasks { protected Long getPercentProgress(int completedBBs, int totalBBs) { double ratio = (completedBBs / (totalBBs * 1.0)); int percentProgress = (int) (ratio * 95); - return new Long(percentProgress + 5); + return (long) (percentProgress + 5); } protected String getStatusMessage(String completedBB, String nextBB, int completedBBs, int remainingBBs) { @@ -220,7 +213,7 @@ public class WorkflowActionBBTasks { final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE); final String resourceName = (String) execution.getVariable("resourceName"); String statusMessage = (String) execution.getVariable("StatusMessage"); - String macroAction = ""; + String macroAction; if (statusMessage == null) { if (aLaCarte) { macroAction = "ALaCarte-" + resourceName + "-" + action + " request was executed correctly."; @@ -235,7 +228,7 @@ public class WorkflowActionBBTasks { request.setEndTime(endTime); request.setFlowStatus("Successfully completed all Building Blocks"); request.setStatusMessage(macroAction); - request.setProgress(Long.valueOf(100)); + request.setProgress(100L); request.setRequestStatus("COMPLETE"); request.setLastModifiedBy("CamundaBPMN"); requestsDbListener.post(request, new DelegateExecutionImpl(execution)); @@ -286,12 +279,20 @@ public class WorkflowActionBBTasks { * working on. */ public void rollbackExecutionPath(DelegateExecution execution) { + final String action = (String) execution.getVariable(G_ACTION); + final String resourceName = (String) execution.getVariable("resourceName"); if (!(boolean) execution.getVariable("isRollback")) { List<ExecuteBuildingBlock> flowsToExecute = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); - List<ExecuteBuildingBlock> rollbackFlows = new ArrayList(); + + List<ExecuteBuildingBlock> flowsToExecuteChangeBBs = flowsToExecute.stream() + .filter(buildingBlock -> buildingBlock.getBuildingBlock().getBpmnFlowName().startsWith("Change")) + .collect(Collectors.toList()); + + List<ExecuteBuildingBlock> rollbackFlows = new ArrayList<>(); int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE); int listSize = flowsToExecute.size(); + for (int i = listSize - 1; i >= 0; i--) { if (i > currentSequence - 1) { flowsToExecute.remove(i); @@ -326,25 +327,34 @@ public class WorkflowActionBBTasks { } String handlingCode = (String) execution.getVariable(HANDLINGCODE); - List<ExecuteBuildingBlock> rollbackFlowsFiltered = new ArrayList<>(); - rollbackFlowsFiltered.addAll(rollbackFlows); + List<ExecuteBuildingBlock> rollbackFlowsFiltered = new ArrayList<>(rollbackFlows); if ("RollbackToAssigned".equals(handlingCode) || ROLLBACKTOCREATED.equals(handlingCode)) { - for (int i = 0; i < rollbackFlows.size(); i++) { - if (rollbackFlows.get(i).getBuildingBlock().getBpmnFlowName().contains("Unassign") && !rollbackFlows - .get(i).getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration")) { - rollbackFlowsFiltered.remove(rollbackFlows.get(i)); - } else if (rollbackFlows.get(i).getBuildingBlock().getBpmnFlowName().contains("Delete") + for (ExecuteBuildingBlock rollbackFlow : rollbackFlows) { + if (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("Unassign") + && !rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration")) { + rollbackFlowsFiltered.remove(rollbackFlow); + } else if (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("Delete") + && !rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration") && ROLLBACKTOCREATED.equals(handlingCode)) { - rollbackFlowsFiltered.remove(rollbackFlows.get(i)); + rollbackFlowsFiltered.remove(rollbackFlow); } } } + List<ExecuteBuildingBlock> rollbackFlowsFilteredNonChangeBBs = new ArrayList<>(); + if (action.equals(REPLACEINSTANCE) && resourceName.equals(VFMODULE)) { + for (ExecuteBuildingBlock executeBuildingBlock : rollbackFlowsFiltered) { + if (!executeBuildingBlock.getBuildingBlock().getBpmnFlowName().startsWith("Change")) { + rollbackFlowsFilteredNonChangeBBs.add(executeBuildingBlock); + } + } + rollbackFlowsFiltered.clear(); + rollbackFlowsFiltered.addAll(flowsToExecuteChangeBBs); + rollbackFlowsFiltered.addAll(rollbackFlowsFilteredNonChangeBBs); + } + workflowActionBBFailure.updateRequestErrorStatusMessage(execution); - if (rollbackFlows.isEmpty()) - execution.setVariable("isRollbackNeeded", false); - else - execution.setVariable("isRollbackNeeded", true); + execution.setVariable("isRollbackNeeded", !rollbackFlows.isEmpty()); execution.setVariable("flowsToExecute", rollbackFlowsFiltered); execution.setVariable(HANDLINGCODE, "PreformingRollback"); execution.setVariable("isRollback", true); @@ -431,9 +441,8 @@ public class WorkflowActionBBTasks { ExecuteBuildingBlock addConfigBB = getExecuteBBForConfig(ADD_FABRIC_CONFIGURATION_BB, ebb, configurationId, configurationResourceKeys); flowsToExecute.add(addConfigBB); - flowsToExecute.stream() - .forEach(executeBB -> logger.info("Flows to Execute After Post Processing: {}", - executeBB.getBuildingBlock().getBpmnFlowName())); + flowsToExecute.forEach(executeBB -> logger.info("Flows to Execute After Post Processing: {}", + executeBB.getBuildingBlock().getBpmnFlowName())); execution.setVariable("flowsToExecute", flowsToExecute); execution.setVariable(COMPLETED, false); } else { @@ -450,11 +459,10 @@ public class WorkflowActionBBTasks { } } - protected String getConfigurationId(Vnfc vnfc) { - List<Configuration> configurations = + protected String getConfigurationId(Vnfc vnfc) throws Exception { + Configuration configuration = workflowAction.getRelatedResourcesInVnfc(vnfc, Configuration.class, AAIObjectType.CONFIGURATION); - if (!configurations.isEmpty()) { - Configuration configuration = configurations.get(0); + if (configuration != null) { return configuration.getConfigurationId(); } else { return UUID.randomUUID().toString(); @@ -466,14 +474,12 @@ public class WorkflowActionBBTasks { BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName(bbName).setMsoId(UUID.randomUUID().toString()); - WorkflowResourceIds workflowResourceIds = ebb.getWorkflowResourceIds(); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(ebb.getWorkflowResourceIds()); workflowResourceIds.setConfigurationId(configurationId); - ExecuteBuildingBlock configBB = new ExecuteBuildingBlock().setaLaCarte(ebb.isaLaCarte()) - .setApiVersion(ebb.getApiVersion()).setRequestAction(ebb.getRequestAction()) - .setVnfType(ebb.getVnfType()).setRequestId(ebb.getRequestId()) + return new ExecuteBuildingBlock().setaLaCarte(ebb.isaLaCarte()).setApiVersion(ebb.getApiVersion()) + .setRequestAction(ebb.getRequestAction()).setVnfType(ebb.getVnfType()).setRequestId(ebb.getRequestId()) .setRequestDetails(ebb.getRequestDetails()).setBuildingBlock(buildingBlock) .setWorkflowResourceIds(workflowResourceIds).setConfigurationResourceKeys(configurationResourceKeys); - return configBB; } protected void setInstanceName(String resourceId, WorkflowType resourceType, InfraActiveRequests request) { @@ -497,9 +503,7 @@ public class WorkflowActionBBTasks { } else if (resourceType == WorkflowType.VOLUMEGROUP && request.getVolumeGroupName() == null) { Optional<VolumeGroup> volumeGroup = bbInputSetupUtils.getRelatedVolumeGroupByIdFromVnf(request.getVnfId(), resourceId); - if (volumeGroup.isPresent()) { - request.setVolumeGroupName(volumeGroup.get().getVolumeGroupName()); - } + volumeGroup.ifPresent(group -> request.setVolumeGroupName(group.getVolumeGroupName())); } else if (resourceType == WorkflowType.NETWORK && request.getNetworkName() == null) { L3Network network = bbInputSetupUtils.getAAIL3Network(resourceId); if (network != null) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java index 6254aae029..bc32489944 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java @@ -39,13 +39,12 @@ public class HomingListener implements FlowManipulator { public void run(List<ExecuteBuildingBlock> flowsToExecute, ExecuteBuildingBlock currentBB, BuildingBlockExecution execution) { - boolean homing = (boolean) execution.getVariable("homing"); - boolean calledHoming = (boolean) execution.getVariable("calledHoming"); + boolean homing = execution.getVariable("homing"); + boolean calledHoming = execution.getVariable("calledHoming"); if (homing && !calledHoming) { currentBB.setHoming(true); execution.setVariable("calledHoming", true); } } - } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java index 772fca0841..6589ae77f5 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java @@ -13,8 +13,11 @@ import org.springframework.stereotype.Component; @Component public class SkipConfigVnfListener implements FlowManipulator { - @Autowired - private CatalogDbClient catalogDbClient; + private final CatalogDbClient catalogDbClient; + + public SkipConfigVnfListener(CatalogDbClient catalogDbClient) { + this.catalogDbClient = catalogDbClient; + } @Override public boolean shouldRunFor(String currentBBName, boolean isFirst, BuildingBlockExecution execution) { @@ -39,6 +42,4 @@ public class SkipConfigVnfListener implements FlowManipulator { } } - - } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java index 3b22cd9d81..3da17194ff 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java @@ -22,6 +22,7 @@ package org.onap.so.client.orchestration; import com.google.common.base.Strings; import java.util.Optional; +import org.apache.commons.lang3.StringUtils; import org.onap.aai.domain.yang.RelatedToProperty; import org.onap.aai.domain.yang.Relationship; import org.onap.aai.domain.yang.RelationshipData; @@ -68,11 +69,39 @@ public class AAIPnfResources { injectionHelper.getAaiClient().update(pnfURI, aaiObjectMapper.mapPnf(pnfCopy)); } - public void checkIfPnfExistsInAaiAndCanBeUsed(String pnfName) throws Exception { - Optional<org.onap.aai.domain.yang.Pnf> pnfFromAai = injectionHelper.getAaiClient() - .get(org.onap.aai.domain.yang.Pnf.class, AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfName)); + public void checkIfPnfExistsInAaiAndCanBeUsed(Pnf pnf) throws Exception { + Optional<org.onap.aai.domain.yang.Pnf> pnfFromAai = + injectionHelper.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class, + AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnf.getPnfName())); if (pnfFromAai.isPresent()) { checkIfPnfCanBeUsed(pnfFromAai.get()); + updatePnfInAAI(pnf, pnfFromAai.get()); + } + } + + private void updatePnfInAAI(Pnf pnf, org.onap.aai.domain.yang.Pnf pnfFromAai) { + updatePnfFields(pnf, pnfFromAai); + injectionHelper.getAaiClient().update(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnf.getPnfName()), + pnfFromAai); + logger.debug("updatePnfInAAI: {}", pnfFromAai); + } + + private void updatePnfFields(Pnf pnf, org.onap.aai.domain.yang.Pnf pnfFromAai) { + if (pnf.getModelInfoPnf() != null + && StringUtils.isNotBlank(pnf.getModelInfoPnf().getModelCustomizationUuid())) { + pnfFromAai.setModelCustomizationId(pnf.getModelInfoPnf().getModelCustomizationUuid()); + } + if (pnf.getModelInfoPnf() != null && StringUtils.isNotBlank(pnf.getModelInfoPnf().getModelInvariantUuid())) { + pnfFromAai.setModelInvariantId(pnf.getModelInfoPnf().getModelInvariantUuid()); + } + if (pnf.getModelInfoPnf() != null && StringUtils.isNotBlank(pnf.getModelInfoPnf().getModelUuid())) { + pnfFromAai.setModelVersionId(pnf.getModelInfoPnf().getModelUuid()); + } + if (pnf.getOrchestrationStatus() != null && StringUtils.isNotBlank(pnf.getOrchestrationStatus().toString())) { + pnfFromAai.setOrchestrationStatus(pnf.getOrchestrationStatus().toString()); + } + if (StringUtils.isNotBlank(pnf.getRole())) { + pnfFromAai.setNfRole(pnf.getRole()); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java index 4aa6a1026a..da675bb498 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java @@ -21,6 +21,7 @@ package org.onap.so.client.orchestration; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GCTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; @@ -29,7 +30,6 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.mapper.GCTopologyOperationRequestMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.net.URI; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java index 0123eb67be..dc59969492 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java @@ -24,6 +24,7 @@ package org.onap.so.client.orchestration; import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.NetworkTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; @@ -31,7 +32,6 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.NetworkTopologyOperationRequestMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java index 960efea2f0..54efd23bf9 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java @@ -22,6 +22,7 @@ package org.onap.so.client.orchestration; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.ServiceTopologyOperationMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; @@ -29,7 +30,6 @@ import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.ServiceTopologyOperationMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java index 01511eaccc..c500374dc1 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java @@ -24,6 +24,7 @@ package org.onap.so.client.orchestration; import java.net.URI; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.VfModuleTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -36,7 +37,6 @@ import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.VfModuleTopologyOperationRequestMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java index 27edeed02a..d198756b1e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java @@ -25,6 +25,7 @@ package org.onap.so.client.orchestration; import java.net.URI; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.VnfTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -35,7 +36,6 @@ import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.VnfTopologyOperationRequestMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java index a7dfe7f7a4..28d2abc792 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java @@ -161,6 +161,26 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test + public void updateOrchestrationStatusInventoriedPnfTest() throws Exception { + Pnf pnf = preparePnfAndExtractForPnf(); + doNothing().when(aaiPnfResources).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.INVENTORIED); + + aaiUpdateTasks.updateOrchestrationStatusInventoriedPnf(execution); + + verify(aaiPnfResources, times(1)).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.INVENTORIED); + } + + @Test + public void updateOrchestrationStatusInventoriedPnfExceptionTest() throws Exception { + Pnf pnf = preparePnfAndExtractForPnf(); + doThrow(RuntimeException.class).when(aaiPnfResources).updateOrchestrationStatusPnf(pnf, + OrchestrationStatus.INVENTORIED); + + expectedException.expect(BpmnError.class); + aaiUpdateTasks.updateOrchestrationStatusInventoriedPnf(execution); + } + + @Test public void updateOrchestrationStatusActivePnfTest() throws Exception { Pnf pnf = preparePnfAndExtractForPnf(); doNothing().when(aaiPnfResources).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.ACTIVE); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java index 38c74eecc7..d7d6da209e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java @@ -149,6 +149,7 @@ public class AppcOrchestratorPreProcessorTest extends BaseTaskTest { private void fillRequiredAppcExecutionFields() { RequestContext context = new RequestContext(); context.setMsoRequestId("TEST-MSO-ID"); + context.setRequestorId("testRequestorId"); execution.setVariable("aicIdentity", "AIC-TEST"); execution.setVariable("vmIdList", "VM-ID-LIST-TEST"); execution.setVariable("vserverIdList", "VSERVER-ID-LIST"); @@ -192,6 +193,7 @@ public class AppcOrchestratorPreProcessorTest extends BaseTaskTest { "{\"request_parameters\":{\"host_ip_address\":\"10.10.10.10\"},\"configuration_parameters\":{\"name1\":\"value1\",\"name2\":\"value2\"}}"); context.setRequestParameters(requestParameters); context.setMsoRequestId("TEST-MSO-ID"); + context.setRequestorId("testRequestorId"); execution.setVariable("aicIdentity", "AIC-TEST"); execution.setVariable("vmIdList", "VM-ID-LIST-TEST"); execution.setVariable("vserverIdList", "VSERVER-ID-LIST"); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GCTopologyOperationRequestMapperTest.java index 0eb0304cdf..d4f1660986 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GCTopologyOperationRequestMapperTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import java.net.URI; import java.net.URISyntaxException; @@ -33,6 +33,8 @@ import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GCTopologyOperationRequestMapper; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; @@ -78,81 +80,4 @@ public class GCTopologyOperationRequestMapperTest extends TestDataSetup { Assert.assertEquals("MsoRequestId", genericInfo.getRequestInformation().getRequestId()); } - - - private VpnBondingLink getVpnBondingLink() { - VpnBondingLink vpnBondingLink = new VpnBondingLink(); - Configuration vrfConfiguration = getVRFConfiguration(); - vpnBondingLink.setVrfConfiguration(vrfConfiguration); - Configuration vnrConfiguration = getVNRConfiguration(); - vpnBondingLink.setVnrConfiguration(vnrConfiguration); - vpnBondingLink.setTransportServiceProxy(buildServiceProxy(buildServiceInstance(buildGenericVnf()))); - return vpnBondingLink; - } - - private RequestContext getRequestContext() { - RequestContext requestContext = new RequestContext(); - requestContext.setMsoRequestId("MsoRequestId"); - Map<String, Object> userParams = getUserParams(); - requestContext.setUserParams(userParams); - return requestContext; - } - - private Map<String, Object> getUserParams() { - Map<String, Object> userParams = new HashMap<>(); - userParams.put("lppCustomerId", "lppCustomerId"); - return userParams; - } - - private ServiceProxy buildServiceProxy(ServiceInstance serviceInstance) { - ServiceProxy serviceProxy = new ServiceProxy(); - serviceProxy.setServiceInstance(serviceInstance); - return serviceProxy; - } - - private Configuration getVRFConfiguration() { - Configuration vrfConfiguration = new Configuration(); - vrfConfiguration.setConfigurationId("ConfigurationId"); - vrfConfiguration.setConfigurationName("ConfigurationName"); - vrfConfiguration.setConfigurationSubType("ConfigurationSubType"); - vrfConfiguration.setConfigurationType("VRF-ENTRY"); - return vrfConfiguration; - } - - public Configuration getVNRConfiguration() { - Configuration vnrConfiguration = new Configuration(); - vnrConfiguration.setConfigurationId("ConfigurationId"); - vnrConfiguration.setConfigurationName("ConfigurationName"); - vnrConfiguration.setConfigurationSubType("ConfigurationSubType"); - vnrConfiguration.setConfigurationType("VNRConfiguration"); - L3Network l3Network = getL3Network(); - vnrConfiguration.setNetwork(l3Network); - return vnrConfiguration; - } - - public L3Network getL3Network() { - L3Network l3Network = new L3Network(); - l3Network.setNetworkId("l3NetworkId"); - Subnet ipv4subnet = getSubnet("ipv4CidrMask", "ipv4NetworkStartAddress", "IPV4"); - Subnet ipv6subnet = getSubnet("ipv6CidrMask", "ipv6NetworkStartAddress", "IPV6"); - l3Network.getSubnets().add(ipv4subnet); - l3Network.getSubnets().add(ipv6subnet); - return l3Network; - } - - private Subnet getSubnet(String ipv4CidrMask, String ipv4NetworkStartAddress, String ipv4) { - Subnet ipv4subnet = new Subnet(); - ipv4subnet.setCidrMask(ipv4CidrMask); - ipv4subnet.setNetworkStartAddress(ipv4NetworkStartAddress); - ipv4subnet.setIpVersion(ipv4); - return ipv4subnet; - } - - private ServiceInstance buildServiceInstance(GenericVnf vnf) { - ServiceInstance serviceInstance = new ServiceInstance(); - serviceInstance.setServiceInstanceId("ServiceInstanceId"); - List<GenericVnf> vnfs = serviceInstance.getVnfs(); - vnfs.add(vnf); - return serviceInstance; - } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GeneralTopologyObjectMapperTest.java index 88a291e68b..92fc13b633 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GeneralTopologyObjectMapperTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; @@ -47,6 +47,7 @@ import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumerat import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java index 76e915781f..0952a35ab0 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; @@ -38,6 +38,8 @@ import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.NetworkTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/ServiceTopologyOperationMapperTest.java index f4006ab5d5..bd5c234e50 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/ServiceTopologyOperationMapperTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; @@ -33,6 +33,8 @@ import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.ServiceTopologyOperationMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java index 2fd684e0f0..e064300ab7 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; @@ -40,6 +40,8 @@ import org.mockito.InjectMocks; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.VfModuleTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java index 00836176f0..a042289281 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -35,6 +35,8 @@ import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.VnfTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java new file mode 100644 index 0000000000..a99ee7d2df --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java @@ -0,0 +1,130 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.service.level; + +import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.onap.so.bpmn.infrastructure.service.level.impl.ServiceLevelPreparation; +import org.onap.so.client.exception.ExceptionBuilder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import static org.assertj.core.api.Assertions.assertThat; +import static org.onap.so.bpmn.infrastructure.service.level.AbstractServiceLevelPreparable.RESOURCE_TYPE; +import static org.onap.so.bpmn.infrastructure.service.level.AbstractServiceLevelPreparable.WORKFLOW_TO_INVOKE; + + + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {ServiceLevelPreparation.class, ExceptionBuilder.class}) +public class ServiceLevelPreparationTest { + + private static final String TEST_PNF_SCOPE = "pnf"; + private static final String TEST_PROCESS_KEY = "testProcessKey"; + private static final String PROCESS_KEY_VALUE = "testProcessKeyValue"; + private static final List<String> PNF_HEALTH_CHECK_PARAMS = Arrays.asList("SERVICE_MODEL_INFO", + "SERVICE_INSTANCE_NAME", "PNF_CORRELATION_ID", "MODEL_UUID", "PNF_UUID", "PRC_BLUEPRINT_NAME", + "PRC_BLUEPRINT_VERSION", "PRC_CUSTOMIZATION_UUID", "RESOURCE_CUSTOMIZATION_UUID_PARAM", "PRC_INSTANCE_NAME", + "PRC_CONTROLLER_ACTOR", "REQUEST_PAYLOAD"); + private Map<String, String> pnfHealthCheckTestParams = new HashMap<>(); + + @Autowired + private ServiceLevelPreparation serviceLevelPrepare; + + @Autowired + private ExceptionBuilder exceptionBuilder; + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + private DelegateExecution execution = new DelegateExecutionFake(); + private DelegateExecution invalidExecution = new DelegateExecutionFake(); + + + @Before + public void setUpPnfUpgradeTest() { + pnfHealthCheckTestParams.put("TEST_SERVICE_MODEL_INFO", "d4c6855e-3be2-5dtu-9390-c999a38829bc"); + pnfHealthCheckTestParams.put("TEST_SERVICE_INSTANCE_NAME", "test_service_id"); + pnfHealthCheckTestParams.put("TEST_PNF_CORRELATION_ID", "pnfCorrelationId"); + pnfHealthCheckTestParams.put("TEST_MODEL_UUID", "6bc0b04d-1873-4721-b53d-6615225b2a28"); + pnfHealthCheckTestParams.put("TEST_PNF_UUID", "c93g70d9-8de3-57f1-7de1-f5690ac2b005"); + pnfHealthCheckTestParams.put("TEST_PRC_BLUEPRINT_NAME", "serviceUpgrade"); + pnfHealthCheckTestParams.put("TEST_PRC_BLUEPRINT_VERSION", "1.0.2"); + pnfHealthCheckTestParams.put("TEST_PRC_CUSTOMIZATION_UUID", "PRC_customizationUuid"); + pnfHealthCheckTestParams.put("TEST_RESOURCE_CUSTOMIZATION_UUID_PARAM", "9acb3a83-8a52-412c-9a45-901764938144"); + pnfHealthCheckTestParams.put("TEST_PRC_INSTANCE_NAME", "Demo_pnf"); + pnfHealthCheckTestParams.put("TEST_PRC_CONTROLLER_ACTOR", "cds"); + pnfHealthCheckTestParams.put("TEST_REQUEST_PAYLOAD", "test_payload"); + + for (String param : PNF_HEALTH_CHECK_PARAMS) { + execution.setVariable(param, pnfHealthCheckTestParams.get("TEST_" + param)); + } + execution.setVariable(RESOURCE_TYPE, TEST_PNF_SCOPE); + execution.setVariable(TEST_PROCESS_KEY, PROCESS_KEY_VALUE); + + invalidExecution.setVariables(execution.getVariables()); + } + + @Test + public void executePnfUpgradeSuccessTest() throws Exception { + serviceLevelPrepare.execute(execution); + // Expect the pnf health check workflow to be set in to execution if validation is successful + assertThat(String.valueOf(execution.getVariable(WORKFLOW_TO_INVOKE))).isEqualTo("GenericPnfHealthCheck"); + } + + @Test + public void validateFailureParamsForPnfTest() throws Exception { + invalidExecution.removeVariable("PNF_UUID"); + invalidExecution.setVariable("PRC_BLUEPRINT_NAME", null); + // BPMN exception is thrown in case of validation failure or invalid execution + thrown.expect(BpmnError.class); + serviceLevelPrepare.validateParamsWithScope(invalidExecution, TEST_PNF_SCOPE, PNF_HEALTH_CHECK_PARAMS); + } + + @Test + public void invalidScopeExecuteTest() throws Exception { + invalidExecution.setVariable(RESOURCE_TYPE, "InvalidResource"); + // BPMN workflow exception is expected incase of invalid resource type other than pnf/vnf + thrown.expect(BpmnError.class); + serviceLevelPrepare.execute(invalidExecution); + } + + @Test + public void invokeServiceLevelPrepareWithoutScope() throws Exception { + invalidExecution.removeVariable(RESOURCE_TYPE); + thrown.expect(BpmnError.class); + serviceLevelPrepare.execute(invalidExecution); + + } + +} + + diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java index b9feeedc14..98f84414db 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java @@ -4,12 +4,14 @@ * ================================================================================ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Copyright (C) 2020 Nokia Intellectual Property. All rights reserved. + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,31 +22,20 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.when; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import org.camunda.bpm.engine.delegate.BpmnError; -import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; +import org.mockito.Mock; import org.mockito.Mockito; import org.onap.so.bpmn.BaseTaskTest; -import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.exception.OrchestrationStatusValidationException; import org.onap.so.db.catalog.beans.BuildingBlockDetail; import org.onap.so.db.catalog.beans.OrchestrationAction; import org.onap.so.db.catalog.beans.OrchestrationStatus; @@ -52,7 +43,16 @@ import org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective; import org.onap.so.db.catalog.beans.OrchestrationStatusValidationDirective; import org.onap.so.db.catalog.beans.ResourceType; import org.onap.so.db.request.beans.InfraActiveRequests; -import org.springframework.beans.factory.annotation.Autowired; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; public class OrchestrationStatusValidatorTest extends BaseTaskTest { @@ -62,6 +62,9 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { private static final String vfModuleNotExistExpectedMessage = "The VfModule was not found, thus no VfModule was deleted in the cloud via this request"; + @Mock + private ExceptionBuilder exceptionBuilder; + @InjectMocks protected OrchestrationStatusValidator orchestrationStatusValidator = new OrchestrationStatusValidator(); @@ -72,11 +75,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { execution.setVariable("aLaCarte", true); execution.setVariable("flowToBeCalled", flowToBeCalled); - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("AssignServiceInstanceBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.SERVICE); - buildingBlockDetail.setTargetAction(OrchestrationAction.ASSIGN); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail("AssignServiceInstanceBB", ResourceType.SERVICE, OrchestrationAction.ASSIGN); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); @@ -88,12 +88,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { .thenReturn(serviceInstance); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.CONTINUE); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.SERVICE); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ASSIGN); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.CONTINUE, + OrchestrationStatus.PRECREATED, ResourceType.SERVICE, OrchestrationAction.ASSIGN); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.SERVICE, OrchestrationStatus.PRECREATED, @@ -107,6 +103,19 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { Mockito.verifyZeroInteractions(requestsDbClient); } + private OrchestrationStatusStateTransitionDirective getOrchestrationStatusStateTransitionDirective( + OrchestrationStatusValidationDirective aContinue, OrchestrationStatus precreated, ResourceType service, + OrchestrationAction assign) { + OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = + new OrchestrationStatusStateTransitionDirective(); + orchestrationStatusStateTransitionDirective.setFlowDirective(aContinue); + orchestrationStatusStateTransitionDirective.setId(1); + orchestrationStatusStateTransitionDirective.setOrchestrationStatus(precreated); + orchestrationStatusStateTransitionDirective.setResourceType(service); + orchestrationStatusStateTransitionDirective.setTargetAction(assign); + return orchestrationStatusStateTransitionDirective; + } + @Test public void test_validateOrchestrationStatusConfiguration() throws Exception { lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId"); @@ -124,11 +133,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { execution.setVariable("flowToBeCalled", flowToBeCalled); execution.setVariable("aLaCarte", true); - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("UnassignFabricConfigurationBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.CONFIGURATION); - buildingBlockDetail.setTargetAction(OrchestrationAction.UNASSIGN); + BuildingBlockDetail buildingBlockDetail = getBuildingBlockDetail("UnassignFabricConfigurationBB", + ResourceType.CONFIGURATION, OrchestrationAction.UNASSIGN); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); @@ -140,13 +146,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { .thenReturn(configuration); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective - .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.CONFIGURATION); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.UNASSIGN); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS, + OrchestrationStatus.PRECREATED, ResourceType.CONFIGURATION, OrchestrationAction.UNASSIGN); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.CONFIGURATION, @@ -160,44 +161,30 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { Mockito.verifyZeroInteractions(requestsDbClient); } - @Ignore @Test - public void test_validateOrchestrationStatus_buildingBlockDetailNotFound() throws Exception { - expectedException.expect(BpmnError.class); - + public void test_validateOrchestrationStatus_buildingBlockDetailNotFound() { String flowToBeCalled = "AssignServiceInstanceBB"; - execution.setVariable("flowToBeCalled", flowToBeCalled); - doReturn(null).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); orchestrationStatusValidator.validateOrchestrationStatus(execution); + + verify(exceptionBuilder).buildAndThrowWorkflowException(eq(execution), eq(7000), + any(OrchestrationStatusValidationException.class)); } - @Ignore @Test - public void test_validateOrchestrationStatus_orchestrationValidationFail() throws Exception { - expectedException.expect(BpmnError.class); - + public void test_validateOrchestrationStatus_orchestrationValidationFail() { String flowToBeCalled = "AssignServiceInstanceBB"; - execution.setVariable("flowToBeCalled", flowToBeCalled); - - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("AssignServiceInstanceBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.SERVICE); - buildingBlockDetail.setTargetAction(OrchestrationAction.ASSIGN); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail("AssignServiceInstanceBB", ResourceType.SERVICE, OrchestrationAction.ASSIGN); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.FAIL); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.SERVICE); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ASSIGN); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.FAIL, + OrchestrationStatus.PRECREATED, ResourceType.SERVICE, OrchestrationAction.ASSIGN); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.SERVICE, OrchestrationStatus.PRECREATED, @@ -206,32 +193,23 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { orchestrationStatusValidator.validateOrchestrationStatus(execution); Mockito.verifyZeroInteractions(requestsDbClient); + verify(exceptionBuilder).buildAndThrowWorkflowException(eq(execution), eq(7000), + any(NullPointerException.class)); } - @Ignore @Test - public void test_validateOrchestrationStatus_orchestrationValidationNotFound() throws Exception { - expectedException.expect(BpmnError.class); - + public void test_validateOrchestrationStatus_orchestrationValidationNotFound() { String flowToBeCalled = "AssignServiceInstanceBB"; - execution.setVariable("flowToBeCalled", flowToBeCalled); - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("AssignServiceInstanceBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.SERVICE); - buildingBlockDetail.setTargetAction(OrchestrationAction.ASSIGN); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail("AssignServiceInstanceBB", ResourceType.SERVICE, OrchestrationAction.ASSIGN); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.FAIL); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.SERVICE); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ASSIGN); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.FAIL, + OrchestrationStatus.PRECREATED, ResourceType.SERVICE, OrchestrationAction.ASSIGN); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.NETWORK, OrchestrationStatus.PRECREATED, @@ -240,24 +218,33 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { orchestrationStatusValidator.validateOrchestrationStatus(execution); Mockito.verifyZeroInteractions(requestsDbClient); + verify(exceptionBuilder).buildAndThrowWorkflowException(eq(execution), eq(7000), + any(NullPointerException.class)); + } + + private BuildingBlockDetail getBuildingBlockDetail(String assignServiceInstanceBB, ResourceType service, + OrchestrationAction assign) { + BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); + buildingBlockDetail.setBuildingBlockName(assignServiceInstanceBB); + buildingBlockDetail.setId(1); + buildingBlockDetail.setResourceType(service); + buildingBlockDetail.setTargetAction(assign); + return buildingBlockDetail; } @Test - public void test_validateOrchestrationStatus_unassignNotFound() throws Exception { + public void test_validateOrchestrationStatus_unassignNotFound() { String flowToBeCalled = "UnassignServiceInstanceBB"; execution.setVariable("flowToBeCalled", flowToBeCalled); execution.setVariable("aLaCarte", true); - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("UnassignServiceInstanceBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.SERVICE); - buildingBlockDetail.setTargetAction(OrchestrationAction.UNASSIGN); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail("UnassignServiceInstanceBB", ResourceType.SERVICE, OrchestrationAction.UNASSIGN); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); - lookupKeyMap = new HashMap<ResourceKey, String>(); + lookupKeyMap = new HashMap<>(); orchestrationStatusValidator.validateOrchestrationStatus(execution); @@ -285,21 +272,14 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.VF_MODULE); - buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail("CreateVfModuleBB", ResourceType.VF_MODULE, OrchestrationAction.CREATE); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.CONTINUE); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.CONTINUE, + OrchestrationStatus.PENDING_ACTIVATION, ResourceType.VF_MODULE, OrchestrationAction.CREATE); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, @@ -334,22 +314,14 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.VF_MODULE); - buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail("CreateVfModuleBB", ResourceType.VF_MODULE, OrchestrationAction.CREATE); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective - .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS, + OrchestrationStatus.PENDING_ACTIVATION, ResourceType.VF_MODULE, OrchestrationAction.CREATE); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, @@ -387,11 +359,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf); setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.VF_MODULE); - buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail("CreateVfModuleBB", ResourceType.VF_MODULE, OrchestrationAction.CREATE); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); @@ -402,13 +371,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective - .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS, + OrchestrationStatus.PENDING_ACTIVATION, ResourceType.VF_MODULE, OrchestrationAction.CREATE); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, @@ -446,11 +410,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf); setVfModule().setOrchestrationStatus(OrchestrationStatus.ASSIGNED); - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.VF_MODULE); - buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail("CreateVfModuleBB", ResourceType.VF_MODULE, OrchestrationAction.CREATE); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); @@ -461,13 +422,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective - .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS, + OrchestrationStatus.PENDING_ACTIVATION, ResourceType.VF_MODULE, OrchestrationAction.CREATE); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.ASSIGNED, @@ -505,11 +461,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf); setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.VF_MODULE); - buildingBlockDetail.setTargetAction(OrchestrationAction.ACTIVATE); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail("CreateVfModuleBB", ResourceType.VF_MODULE, OrchestrationAction.ACTIVATE); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); @@ -520,13 +473,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective - .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ACTIVATE); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS, + OrchestrationStatus.PENDING_ACTIVATION, ResourceType.VF_MODULE, OrchestrationAction.ACTIVATE); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, @@ -564,11 +512,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf); setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.VF_MODULE); - buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail("CreateVfModuleBB", ResourceType.VF_MODULE, OrchestrationAction.CREATE); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); @@ -579,13 +524,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective - .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ACTIVATE); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS, + OrchestrationStatus.PENDING_ACTIVATION, ResourceType.VF_MODULE, OrchestrationAction.ACTIVATE); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, @@ -611,11 +551,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { @Test public void continueValidationActivatedTest() throws Exception { String flowToBeCalled = "DeactivateVnfBB"; - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName(flowToBeCalled); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.VF_MODULE); - buildingBlockDetail.setTargetAction(OrchestrationAction.DEACTIVATE); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail(flowToBeCalled, ResourceType.VF_MODULE, OrchestrationAction.DEACTIVATE); when(catalogDbClient.getBuildingBlockDetail(flowToBeCalled)).thenReturn(buildingBlockDetail); org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = @@ -625,12 +562,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.CONTINUE); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.ACTIVATED); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.DEACTIVATE); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.CONTINUE, + OrchestrationStatus.ACTIVATED, ResourceType.VF_MODULE, OrchestrationAction.DEACTIVATE); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.ACTIVATED, OrchestrationAction.DEACTIVATE); @@ -666,22 +599,14 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); - BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); - buildingBlockDetail.setBuildingBlockName("DeleteVfModuleBB"); - buildingBlockDetail.setId(1); - buildingBlockDetail.setResourceType(ResourceType.VF_MODULE); - buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE); + BuildingBlockDetail buildingBlockDetail = + getBuildingBlockDetail("DeleteVfModuleBB", ResourceType.VF_MODULE, OrchestrationAction.CREATE); doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = - new OrchestrationStatusStateTransitionDirective(); - orchestrationStatusStateTransitionDirective - .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS); - orchestrationStatusStateTransitionDirective.setId(1); - orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); - orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE); - orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE); + getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS, + OrchestrationStatus.PENDING_ACTIVATION, ResourceType.VF_MODULE, OrchestrationAction.CREATE); doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java index 2e4f2e54f0..a7ee89f073 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java @@ -44,7 +44,9 @@ import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner; import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.serviceinstancebeans.ModelInfo; @@ -53,7 +55,9 @@ import org.springframework.core.env.Environment; import java.util.ArrayList; import java.util.List; import java.util.Optional; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.ArgumentMatchers.anyString; @@ -67,6 +71,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { private static final String SAMPLE_MSO_REQUEST_ID = "00f704ca-c5e5-4f95-a72c-6889db7b0688"; private static final String SAMPLE_REQUEST_ACTION = "Delete-Network-Collection"; private static final int SAMPLE_SEQUENCE = 0; + private static final String EMPTY_STRING = ""; @Mock protected WorkflowAction workflowAction; @@ -172,7 +177,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { workflowActionBBTasks.selectBB(execution); boolean success = (boolean) execution.getVariable("completed"); int currentSequence = (int) execution.getVariable("gCurrentSequence"); - assertEquals(false, success); + assertFalse(success); assertEquals(1, currentSequence); } @@ -195,6 +200,8 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { public void rollbackExecutionPathTest() { execution.setVariable("handlingCode", "Rollback"); execution.setVariable("isRollback", false); + execution.setVariable("requestAction", EMPTY_STRING); + execution.setVariable("resourceName", EMPTY_STRING); List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); @@ -224,6 +231,8 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { public void rollbackExecutionPathUnfinishedFlowTest() { execution.setVariable("handlingCode", "Rollback"); execution.setVariable("isRollback", false); + execution.setVariable("requestAction", EMPTY_STRING); + execution.setVariable("resourceName", EMPTY_STRING); List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); @@ -253,6 +262,8 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { public void rollbackExecutionTest() { execution.setVariable("handlingCode", "Rollback"); execution.setVariable("isRollback", false); + execution.setVariable("requestAction", EMPTY_STRING); + execution.setVariable("resourceName", EMPTY_STRING); List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignServiceInstanceBB"); ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); @@ -286,6 +297,8 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { public void rollbackExecutionRollbackToAssignedTest() { execution.setVariable("isRollback", false); execution.setVariable("handlingCode", "RollbackToAssigned"); + execution.setVariable("requestAction", EMPTY_STRING); + execution.setVariable("resourceName", EMPTY_STRING); List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); @@ -311,9 +324,50 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { } @Test + public void rollbackExecutionPathChangeBBForReplaceVFModuleTest() { + execution.setVariable("handlingCode", "Rollback"); + execution.setVariable("isRollback", false); + execution.setVariable("requestAction", "replaceInstance"); + execution.setVariable("resourceName", "VfModule"); + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); + BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); + flowsToExecute.add(ebb1); + + BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB"); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2); + flowsToExecute.add(ebb2); + + BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3); + flowsToExecute.add(ebb3); + + + BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("ChangeModelVnfBB"); + ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4); + flowsToExecute.add(ebb4); + + BuildingBlock buildingBlock5 = new BuildingBlock().setBpmnFlowName("ChangeModelServiceInstanceBB"); + ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock5); + flowsToExecute.add(ebb5); + + execution.setVariable("flowsToExecute", flowsToExecute); + execution.setVariable("gCurrentSequence", 5); + doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class)); + + workflowActionBBTasks.rollbackExecutionPath(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(), "ChangeModelVnfBB"); + assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(), "ChangeModelServiceInstanceBB"); + assertEquals(0, execution.getVariable("gCurrentSequence")); + } + + @Test public void rollbackExecutionRollbackToAssignedWithFabricTest() { execution.setVariable("isRollback", false); execution.setVariable("handlingCode", "RollbackToAssigned"); + execution.setVariable("requestAction", EMPTY_STRING); + execution.setVariable("resourceName", EMPTY_STRING); List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); @@ -346,9 +400,47 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { } @Test + public void rollbackExecutionRollbackToCreatedWithFabricTest() { + execution.setVariable("isRollback", false); + execution.setVariable("handlingCode", "RollbackToCreated"); + execution.setVariable("requestAction", EMPTY_STRING); + execution.setVariable("resourceName", EMPTY_STRING); + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); + + BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); + flowsToExecute.add(ebb1); + + BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB"); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2); + flowsToExecute.add(ebb2); + + BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3); + flowsToExecute.add(ebb3); + + BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB"); + ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4); + flowsToExecute.add(ebb4); + + execution.setVariable("flowsToExecute", flowsToExecute); + execution.setVariable("gCurrentSequence", 4); + + workflowActionBBTasks.rollbackExecutionPath(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + assertEquals(0, execution.getVariable("gCurrentSequence")); + assertEquals(2, ebbs.size()); + assertEquals("DeleteFabricConfigurationBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName()); + assertEquals("DeactivateVfModuleBB", ebbs.get(1).getBuildingBlock().getBpmnFlowName()); + + } + + @Test public void rollbackExecutionRollbackToCreatedTest() { execution.setVariable("isRollback", false); execution.setVariable("handlingCode", "RollbackToCreated"); + execution.setVariable("requestAction", EMPTY_STRING); + execution.setVariable("resourceName", EMPTY_STRING); List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); @@ -376,6 +468,8 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { public void rollbackExecutionRollbackInPlaceSoftwareUpdateTest() { execution.setVariable("isRollback", false); execution.setVariable("handlingCode", "Rollback"); + execution.setVariable("requestAction", EMPTY_STRING); + execution.setVariable("resourceName", EMPTY_STRING); List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("VNFCheckPserversLockedFlagActivity"); ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); @@ -435,6 +529,8 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { public void rollbackExecutionRollbackConfigModifyTest() { execution.setVariable("isRollback", false); execution.setVariable("handlingCode", "Rollback"); + execution.setVariable("requestAction", EMPTY_STRING); + execution.setVariable("resourceName", EMPTY_STRING); List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("VNFCheckPserversLockedFlagActivity"); ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); @@ -471,6 +567,55 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { assertEquals(2, ebbs.size()); } + @Test + public void postProcessingExecuteBBActivateVfModuleTest() throws CloneNotSupportedException { + BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); + ExecuteBuildingBlock ebbActivateVfModule = new ExecuteBuildingBlock().setBuildingBlock(bbActivateVfModule); + + WorkflowResourceIds resourceIdsActivateVfModule = new WorkflowResourceIds(); + resourceIdsActivateVfModule.setServiceInstanceId("test-service-inbstance-id"); + resourceIdsActivateVfModule.setVnfId("test-vnf-id"); + resourceIdsActivateVfModule.setVfModuleId("test-vf-module-id"); + resourceIdsActivateVfModule.setConfigurationId(""); + + RequestDetails requestDetails = new RequestDetails(); + + ebbActivateVfModule.setApiVersion("7"); + ebbActivateVfModule.setaLaCarte(true); + ebbActivateVfModule.setRequestAction("createInstance"); + ebbActivateVfModule.setVnfType("test-vnf-type"); + ebbActivateVfModule.setRequestId("f6c00ae2-a205-4cbd-b055-02e553efde12"); + ebbActivateVfModule.setRequestDetails(requestDetails); + ebbActivateVfModule.setWorkflowResourceIds(resourceIdsActivateVfModule); + + ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys(); + configurationResourceKeys.setCvnfcCustomizationUUID("07d64cd2-4427-4156-b11d-d14b96b3e4cb"); + configurationResourceKeys.setVfModuleCustomizationUUID("50b61075-6ebb-4aab-a9fc-bedad9a2aa76"); + configurationResourceKeys.setVnfResourceCustomizationUUID("a1d0e36e-34a9-431b-b5ba-4bbb72f63c7c"); + configurationResourceKeys.setVnfcName("rdm54bvbgw5001vm018pim001"); + + ExecuteBuildingBlock ebbAddFabricConfig = + workflowActionBBTasks.getExecuteBBForConfig("AddFabricConfigurationBB", ebbActivateVfModule, + "cc7e12f9-967c-4362-8d14-e5b2bf0608a4", configurationResourceKeys); + + assertEquals("7", ebbAddFabricConfig.getApiVersion()); + assertTrue(ebbAddFabricConfig.isaLaCarte()); + assertEquals("createInstance", ebbAddFabricConfig.getRequestAction()); + assertEquals("test-vnf-type", ebbAddFabricConfig.getVnfType()); + assertEquals("f6c00ae2-a205-4cbd-b055-02e553efde12", ebbAddFabricConfig.getRequestId()); + assertEquals(requestDetails, ebbAddFabricConfig.getRequestDetails()); + assertEquals("cc7e12f9-967c-4362-8d14-e5b2bf0608a4", + ebbAddFabricConfig.getWorkflowResourceIds().getConfigurationId()); + assertEquals("test-service-inbstance-id", ebbAddFabricConfig.getWorkflowResourceIds().getServiceInstanceId()); + assertEquals("test-vnf-id", ebbAddFabricConfig.getWorkflowResourceIds().getVnfId()); + assertEquals("test-vf-module-id", ebbAddFabricConfig.getWorkflowResourceIds().getVfModuleId()); + + assertThat(ebbAddFabricConfig.getConfigurationResourceKeys()).isEqualTo(configurationResourceKeys); + assertThat(ebbAddFabricConfig.getWorkflowResourceIds()) + .isNotEqualTo(ebbActivateVfModule.getWorkflowResourceIds()); + assertThat(ebbAddFabricConfig.getWorkflowResourceIds().getConfigurationId()) + .isNotEqualTo(ebbActivateVfModule.getWorkflowResourceIds().getConfigurationId()); + } @Test public void checkRetryStatusTest() { @@ -533,7 +678,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { } @Test - public void getConfigurationId() { + public void getConfigurationId() throws Exception { org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc(); vnfc.setModelInvariantId("modelInvariantId"); vnfc.setVnfcName("testVnfcName"); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index e24eaf0581..407a844c4e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -43,6 +43,7 @@ import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.when; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; import java.net.MalformedURLException; @@ -116,6 +117,15 @@ import org.springframework.core.env.Environment; public class WorkflowActionTest extends BaseTaskTest { + private static final String MACRO_ACTIVATE_DELETE_UNASSIGN_JSON = "Macro/ServiceMacroActivateDeleteUnassign.json"; + private static final String MACRO_ASSIGN_JSON = "Macro/ServiceMacroAssign.json"; + private static final String MACRO_ASSIGN_NO_CLOUD_JSON = "Macro/ServiceMacroAssignNoCloud.json"; + private static final String VF_MODULE_CREATE_WITH_FABRIC_JSON = "VfModuleCreateWithFabric.json"; + private static final String VF_MODULE_REPLACE_REBUILD_VOLUME_GROUPS_JSON = + "VfModuleReplaceRebuildVolumeGroups.json"; + private static final String MACRO_CREATE_NETWORK_COLLECTION_JSON = "Macro/CreateNetworkCollection.json"; + private static final String MACRO_VNF_MACRO_REPLACE_JSON = "Macro/VnfMacroReplace.json"; + @Mock protected Environment environment; @InjectMocks @@ -140,6 +150,11 @@ public class WorkflowActionTest extends BaseTaskTest { "DeleteVfModuleATTBB", "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "UnassignVolumeGroupBB", "AssignVolumeGroupBB", "ChangeModelVfModuleBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB"); + private List<OrchestrationFlow> replaceVfModuleWithFabricOrchFlows = createFlowList("DeleteFabricConfigurationBB", + "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", + "UnassignVFModuleBB", "UnassignVolumeGroupBB", "AssignVolumeGroupBB", "AssignVfModuleBB", + "CreateVfModuleBB", "ActivateVfModuleBB", "AddFabricConfigurationBB", "CreateVolumeGroupBB", + "ActivateVolumeGroupBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB"); @Before public void before() throws Exception { @@ -158,13 +173,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteNetworkCreateTest() throws Exception { String gAction = "createInstance"; String resource = "Network"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v6/networks/123"); NorthBoundRequest northBoundRequest = new NorthBoundRequest(); @@ -183,13 +193,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteNetworkDeleteTest() throws Exception { String gAction = "deleteInstance"; String resource = "Network"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v6/networks/123"); NorthBoundRequest northBoundRequest = new NorthBoundRequest(); @@ -208,13 +213,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteServiceCreateTest() throws Exception { String gAction = "createInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v6/serviceInstances/123"); @@ -230,87 +230,11 @@ public class WorkflowActionTest extends BaseTaskTest { } @Test - public void selectExecutionListExceptionAlreadyBuiltTest() throws Exception { - DelegateExecution delegateExecution = new DelegateExecutionFake(); - String gAction = "deleteInstance"; - String resource = "VfModule"; - delegateExecution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - delegateExecution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - delegateExecution.setVariable("bpmnRequest", bpmnRequest); - delegateExecution.setVariable("aLaCarte", true); - delegateExecution.setVariable("apiVersion", "7"); - delegateExecution.setVariable("requestUri", - "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules"); - - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); - List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", - "UnassignVfModuleBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB"); - northBoundRequest.setOrchestrationFlowList(orchFlows); - - when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, - true, "my-custom-cloud-owner")).thenReturn(northBoundRequest); - - doAnswer(invocation -> { - DelegateExecutionFake execution = invocation.getArgument(0); - execution.setVariable("WorkflowException", "exception"); - execution.setVariable("WorkflowExceptionErrorMessage", "errorMessage"); - throw new BpmnError("WorkflowException"); - }).when(exceptionUtil).buildAndThrowWorkflowException(delegateExecution, 7000, - "Exception in getConfigBuildingBlock: Multiple relationships exist from VNFC testVnfcName to Configurations"); - - - org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf(); - vnf.setVnfId("vnf0"); - vnf.setModelCustomizationId("modelCustomizationId"); - when(bbSetupUtils.getAAIGenericVnf(any())).thenReturn(vnf); - - org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule(); - vfModule.setModelCustomizationId("modelCustomizationId"); - when(bbSetupUtils.getAAIVfModule(any(), any())).thenReturn(vfModule); - - List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>(); - org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc(); - vnfc.setModelInvariantId("modelInvariantId"); - vnfc.setVnfcName("testVnfcName"); - vnfcs.add(vnfc); - doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(any(), any(), any(), any()); - - List<org.onap.aai.domain.yang.Configuration> configurations = - new ArrayList<org.onap.aai.domain.yang.Configuration>(); - org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration(); - configuration.setConfigurationId("configurationId"); - configuration.setModelCustomizationId("modelCustimizationId"); - configuration.setConfigurationName("testConfigurationName"); - configurations.add(configuration); - org.onap.aai.domain.yang.Configuration configuration1 = new org.onap.aai.domain.yang.Configuration(); - configuration1.setConfigurationId("configurationId"); - configuration1.setModelCustomizationId("modelCustimizationId"); - configuration1.setConfigurationName("testConfigurationName"); - configurations.add(configuration1); - doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(any(), any(), any()); - - doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(any()); - - thrown.expect(BpmnError.class); - SPY_workflowAction.selectExecutionList(delegateExecution); - assertEquals( - "Exception in getConfigBuildingBlock: Multiple relationships exist from VNFC testVnfcName to Configurations", - delegateExecution.getVariable("WorkflowException")); - } - - @Test public void selectExecutionListDuplicateNameExceptionTest() throws Exception { String gAction = "createInstance"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v6/serviceInstances"); - execution.setVariable("requestAction", gAction); doThrow(new DuplicateNameException( "serviceInstance with name (instanceName) and different version id (3c40d244-808e-42ca-b09a-256d83d19d0a) already exists. The name must be unique.")) @@ -329,16 +253,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroAssignTest() throws Exception { String gAction = "assignInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB"); @@ -383,16 +301,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroAssignNoCloudTest() throws Exception { String gAction = "assignInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String( - Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssignNoCloud.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_NO_CLOUD_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB"); @@ -438,16 +350,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroActivateTest() throws Exception { String gAction = "activateInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/si0"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = createFlowList("CreateNetworkBB", "ActivateNetworkBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", @@ -462,7 +368,6 @@ public class WorkflowActionTest extends BaseTaskTest { new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf(); vnf.setVnfId("vnf0"); - org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = buildVfModule(); vnf.getVfModules().add(vfModule); org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = buildVfModule(); @@ -492,23 +397,16 @@ public class WorkflowActionTest extends BaseTaskTest { assertEquals("testVfModuleId2", ebbs.get(5).getWorkflowResourceIds().getVfModuleId()); assertEquals("vnf0", ebbs.get(6).getWorkflowResourceIds().getVnfId()); assertEquals("si0", ebbs.get(7).getWorkflowResourceIds().getServiceInstanceId()); - } @Test public void selectExecutionListServiceMacroDeactivateTest() throws Exception { String gAction = "deactivateInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = createFlowList("DeactivateServiceInstanceBB"); northBoundRequest.setOrchestrationFlowList(orchFlows); @@ -524,16 +422,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroEmptyServiceTest() throws Exception { String gAction = "createInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); northBoundRequest.setIsToplevelflow(true); List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB", @@ -556,16 +448,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroCreateJustNetworkTest() throws Exception { String gAction = "createInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); northBoundRequest.setIsToplevelflow(true); List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB", @@ -592,16 +478,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroCreateWithNetworkCollectionTest() throws Exception { String gAction = "createInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); northBoundRequest.setIsToplevelflow(true); List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB", @@ -687,16 +567,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroCreateWithUserParams() throws Exception { String gAction = "createInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB", "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "CreateNetworkBB", @@ -769,21 +643,16 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroDeleteTest() throws Exception { String gAction = "deleteInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", - "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", "DeactivateNetworkBB", - "DeleteNetworkBB", "DeleteNetworkCollectionBB", "DeactivateServiceInstanceBB", "UnassignVfModuleBB", - "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignNetworkBB", "UnassignServiceInstanceBB"); + "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", "DeactivatePnfBB", + "DeactivateNetworkBB", "DeleteNetworkBB", "DeleteNetworkCollectionBB", "DeactivateServiceInstanceBB", + "UnassignVfModuleBB", "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignNetworkBB", + "UnassignServiceInstanceBB"); northBoundRequest.setOrchestrationFlowList(orchFlows); ServiceInstance serviceInstanceAAI = new ServiceInstance(); @@ -792,7 +661,10 @@ public class WorkflowActionTest extends BaseTaskTest { new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance(); org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf(); + org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf pnf = + new org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf(); vnf.setVnfId("vnfId123"); + pnf.setPnfId("pnfId123"); org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = buildVfModule(); vnf.getVfModules().add(vfModule); @@ -805,6 +677,7 @@ public class WorkflowActionTest extends BaseTaskTest { vnf.getVolumeGroups().add(volumeGroup); serviceInstanceMSO.getVnfs().add(vnf); + serviceInstanceMSO.getPnfs().add(pnf); doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123"); doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI); @@ -814,24 +687,53 @@ public class WorkflowActionTest extends BaseTaskTest { List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeleteVfModuleBB", "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", - "DeactivateServiceInstanceBB", "UnassignVfModuleBB", "UnassignVfModuleBB", "UnassignVolumeGroupBB", - "UnassignVnfBB", "UnassignServiceInstanceBB"); + "DeactivatePnfBB", "DeactivateServiceInstanceBB", "UnassignVfModuleBB", "UnassignVfModuleBB", + "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignServiceInstanceBB"); + } + + @Test + public void selectExecutionListServiceMacroDeleteWithPnfTest() throws Exception { + String gAction = "deleteInstance"; + String resource = "Service"; + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); + execution.setVariable("requestUri", "v6/serviceInstances/123"); + + NorthBoundRequest northBoundRequest = new NorthBoundRequest(); + List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", + "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", "DeactivatePnfBB", + "DeactivateNetworkBB", "DeleteNetworkBB", "DeleteNetworkCollectionBB", "DeactivateServiceInstanceBB", + "UnassignVfModuleBB", "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignNetworkBB", + "UnassignServiceInstanceBB"); + northBoundRequest.setOrchestrationFlowList(orchFlows); + + ServiceInstance serviceInstanceAAI = new ServiceInstance(); + serviceInstanceAAI.setServiceInstanceId("aaisi123"); + org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = + new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance(); + org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf pnf = + new org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf(); + pnf.setPnfId("pnfId123"); + + serviceInstanceMSO.getPnfs().add(pnf); + + doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123"); + doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI); + when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, + false, "my-custom-cloud-owner")).thenReturn(northBoundRequest); + workflowAction.selectExecutionList(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + assertEqualsBulkFlowName(ebbs, "DeactivatePnfBB", "DeactivateServiceInstanceBB", "UnassignServiceInstanceBB"); } @Test public void selectExecutionListServiceMacroUnassignTest() throws Exception { String gAction = "unassignInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = createFlowList("UnassignVfModuleBB", "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignNetworkBB", "UnassignServiceInstanceBB"); @@ -871,16 +773,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroDeleteNetworkCollectionTest() throws Exception { String gAction = "deleteInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", "DeactivateNetworkBB", @@ -920,13 +816,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListVnfMacroRecreateTest() throws Exception { String gAction = "recreateInstance"; String resource = "Vnf"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/VnfMacroReplace.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_VNF_MACRO_REPLACE_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v7/serviceInstances/123/vnfs/1234/recreate"); execution.setVariable("serviceInstanceId", "123"); execution.setVariable("vnfId", "1234"); @@ -974,13 +865,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListVnfMacroReplaceTest() throws Exception { String gAction = "replaceInstance"; String resource = "Vnf"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/VnfMacroReplace.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_VNF_MACRO_REPLACE_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v7/serviceInstances/123/vnfs/1234/replace"); execution.setVariable("serviceInstanceId", "123"); execution.setVariable("vnfId", "1234"); @@ -1047,16 +933,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListNetworkCollectionMacroCreate() throws Exception { String gAction = "createInstance"; String resource = "NetworkCollection"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String( - Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/CreateNetworkCollection.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_CREATE_NETWORK_COLLECTION_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123/networkCollections/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = createFlowList("CreateNetworkCollectionBB", "AssignNetworkBB", "CreateNetworkBB", "ActivateNetworkBB", "ActivateNetworkCollectionBB"); @@ -1084,13 +964,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListNetworkCollectionMacroDelete() throws Exception { String gAction = "deleteInstance"; String resource = "NetworkCollection"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String( - Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/CreateNetworkCollection.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_CREATE_NETWORK_COLLECTION_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123/networkCollections/123"); NorthBoundRequest northBoundRequest = new NorthBoundRequest(); @@ -1119,17 +994,11 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleNoFabricCreateTest() throws Exception { String gAction = "createInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = createFlowList("AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB"); @@ -1146,13 +1015,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleFabricCreateTest() throws Exception { String gAction = "createInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules"); @@ -1205,13 +1069,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleNoVolumeGroupReplaceTest() throws Exception { String gAction = "replaceInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); @@ -1231,13 +1090,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleNoVolumeGroupReplaceRetainAssignmentsTest() throws Exception { String gAction = "replaceInstanceRetainAssignments"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); @@ -1256,13 +1110,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleVolumeGroupToNoVolumeGroupReplaceTest() throws Exception { String gAction = "replaceInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1289,13 +1138,8 @@ public class WorkflowActionTest extends BaseTaskTest { throws Exception { String gAction = "replaceInstanceRetainAssignments"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1322,13 +1166,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleKeepVolumeGroupReplaceTest() throws Exception { String gAction = "replaceInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1360,16 +1199,69 @@ public class WorkflowActionTest extends BaseTaskTest { } @Test + public void selectExecutionListALaCarteVfModuleWithFabricKeepVolumeGroupReplaceTest() throws Exception { + String gAction = "replaceInstance"; + String resource = "VfModule"; + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); + execution.setVariable("requestUri", + "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); + execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); + execution.setVariable("vfModuleId", "1234"); + + org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf(); + vnf.setVnfId("b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); + vnf.setModelCustomizationId("modelCustomizationId"); + when(bbSetupUtils.getAAIGenericVnf(any())).thenReturn(vnf); + + org.onap.aai.domain.yang.VfModule vfModuleFromAAI = new org.onap.aai.domain.yang.VfModule(); + vfModuleFromAAI.setModelCustomizationId("modelCustomizationId"); + vfModuleFromAAI.setVfModuleId("1234"); + when(bbSetupUtils.getAAIVfModule(any(), any())).thenReturn(vfModuleFromAAI); + + VolumeGroup volumeGroup = new VolumeGroup(); + volumeGroup.setVolumeGroupId("volumeGroupId"); + doReturn(Optional.of(volumeGroup)).when(bbSetupUtils) + .getRelatedVolumeGroupFromVfModule("b80b16a5-f80d-4ffa-91c8-bd47c7438a3d", "1234"); + + VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); + vfModuleCustomization.setVolumeHeatEnv(new HeatEnvironment()); + org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule(); + vfModule.setVolumeHeatTemplate(new HeatTemplate()); + vfModuleCustomization.setVfModule(vfModule); + when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("9a6d01fd-19a7-490a-9800-460830a12e0b")) + .thenReturn(vfModuleCustomization); + List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>(); + org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc(); + vnfc.setModelInvariantId("modelInvariantId"); + vnfc.setVnfcName("testVnfcName"); + vnfcs.add(vnfc); + doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(any(), any(), any(), any()); + + org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration(); + configuration.setConfigurationId("configurationId"); + configuration.setModelCustomizationId("modelCustimizationId"); + configuration.setConfigurationName("testConfigurationName"); + doReturn(configuration).when(SPY_workflowAction).getRelatedResourcesInVnfc(any(), any(), any()); + + NorthBoundRequest northBoundRequest = new NorthBoundRequest(); + northBoundRequest.setOrchestrationFlowList(replaceVfModuleWithFabricOrchFlows); + when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, + true, "my-custom-cloud-owner")).thenReturn(northBoundRequest); + SPY_workflowAction.selectExecutionList(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + + assertEqualsBulkFlowName(ebbs, "DeleteFabricConfigurationBB", "DeactivateVfModuleBB", "DeleteVfModuleATTBB", + "UnassignVFModuleBB", "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", + "AddFabricConfigurationBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB"); + } + + @Test public void selectExecutionListALaCarteVfModuleKeepVolumeGroupReplaceRetainAssignmentsTest() throws Exception { String gAction = "replaceInstanceRetainAssignments"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1403,13 +1295,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleNoVolumeGroupToVolumeGroupReplaceTest() throws Exception { String gAction = "replaceInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1440,13 +1327,8 @@ public class WorkflowActionTest extends BaseTaskTest { throws Exception { String gAction = "replaceInstanceRetainAssignments"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1476,13 +1358,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleRebuildVolumeGroupReplaceTest() throws Exception { String gAction = "replaceInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String( - Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleReplaceRebuildVolumeGroups.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_REPLACE_REBUILD_VOLUME_GROUPS_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1518,13 +1395,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleRebuildVolumeGroupReplaceRetainAssignmentsTest() throws Exception { String gAction = "replaceInstanceRetainAssignments"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String( - Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleReplaceRebuildVolumeGroups.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_REPLACE_REBUILD_VOLUME_GROUPS_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1561,13 +1433,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleFabricDeleteTest() throws Exception { String gAction = "deleteInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules"); @@ -1596,18 +1463,13 @@ public class WorkflowActionTest extends BaseTaskTest { doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(), anyObject()); - List<org.onap.aai.domain.yang.Configuration> configurations = - new ArrayList<org.onap.aai.domain.yang.Configuration>(); org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration(); configuration.setConfigurationId("configurationId"); configuration.setModelCustomizationId("modelCustimizationId"); configuration.setConfigurationName("testConfigurationName"); - configurations.add(configuration); - doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(), + doReturn(configuration).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(), anyObject()); - doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject()); - SPY_workflowAction.selectExecutionList(execution); List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); assertEqualsBulkFlowName(ebbs, "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB", @@ -1619,10 +1481,9 @@ public class WorkflowActionTest extends BaseTaskTest { String gAction = "deleteInstance"; ObjectMapper mapper = new ObjectMapper(); WorkflowType resourceType = WorkflowType.VFMODULE; + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); execution.setVariable("bpmnRequest", bpmnRequest); execution.setVariable("vnfId", "1234"); execution.setVariable("vfModuleId", "vfModuleId1234"); @@ -1665,22 +1526,92 @@ public class WorkflowActionTest extends BaseTaskTest { } @Test - public void selectExecutionListALaCarteVfModuleNoFabricDeleteTest() throws Exception { + public void getConfigBuildingBlocksTest() throws Exception { String gAction = "deleteInstance"; - String resource = "VfModule"; + ObjectMapper mapper = new ObjectMapper(); + mapper.disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES); + + WorkflowType resourceType = WorkflowType.VFMODULE; execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); execution.setVariable("requestAction", gAction); String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + execution.setVariable("vnfId", "1234"); + execution.setVariable("vfModuleId", "vfModuleId1234"); + execution.setVariable("requestUri", + "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules"); + ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class); + RequestDetails requestDetails = sIRequest.getRequestDetails(); + String requestAction = "deleteInstance"; + String requestId = "9c944122-d161-4280-8594-48c06a9d96d5"; + boolean aLaCarte = true; + String apiVersion = "7"; + String vnfType = "vnfType"; + String key = "00d15ebb-c80e-43c1-80f0-90c40dde70b0"; + String resourceId = "d1d35800-783d-42d3-82f6-d654c5054a6e"; + Resource resourceKey = new Resource(resourceType, key, aLaCarte); + WorkflowResourceIds workflowResourceIds = SPY_workflowAction.populateResourceIdsFromApiHandler(execution); + + List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", + "UnassignVfModuleBB", "DeleteFabricConfigurationBB"); + + ConfigBuildingBlocksDataObject dataObj = new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest) + .setOrchFlows(orchFlows).setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion) + .setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(aLaCarte).setVnfType(vnfType) + .setWorkflowResourceIds(workflowResourceIds).setRequestDetails(requestDetails).setExecution(execution); + + org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf(); + vnf.setVnfId("vnf0"); + vnf.setModelCustomizationId("modelCustomizationId"); + when(bbSetupUtils.getAAIGenericVnf(any())).thenReturn(vnf); + + org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule(); + vfModule.setModelCustomizationId("modelCustomizationId"); + + org.onap.aai.domain.yang.Configuration config1 = new org.onap.aai.domain.yang.Configuration(); + config1.setConfigurationId("config1"); + org.onap.aai.domain.yang.Configuration config2 = new org.onap.aai.domain.yang.Configuration(); + config2.setConfigurationId("config2"); + + List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>(); + org.onap.aai.domain.yang.Vnfc vnfc1 = new org.onap.aai.domain.yang.Vnfc(); + vnfc1.setVnfcName("zauk53avetd02svm001"); + org.onap.aai.domain.yang.Vnfc vnfc2 = new org.onap.aai.domain.yang.Vnfc(); + vnfc2.setVnfcName("zauk53avetd02tvm001"); + vnfcs.add(vnfc1); + vnfcs.add(vnfc2); + + when(bbSetupUtils.getAAIVfModule(any(), any())).thenReturn(vfModule); + doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(any(), any(), + eq(org.onap.aai.domain.yang.Vnfc.class), eq(AAIObjectType.VNFC)); + doReturn(config1).when(SPY_workflowAction).getRelatedResourcesInVnfc(eq(vnfc1), + eq(org.onap.aai.domain.yang.Configuration.class), eq(AAIObjectType.CONFIGURATION)); + doReturn(config2).when(SPY_workflowAction).getRelatedResourcesInVnfc(eq(vnfc2), + eq(org.onap.aai.domain.yang.Configuration.class), eq(AAIObjectType.CONFIGURATION)); + + List<ExecuteBuildingBlock> results = SPY_workflowAction.getConfigBuildingBlocks(dataObj); + + assertFalse(results.isEmpty()); + assertEquals(2, results.size()); + assertEquals("config1", results.get(0).getWorkflowResourceIds().getConfigurationId()); + assertEquals("config2", results.get(1).getWorkflowResourceIds().getConfigurationId()); + assertEquals("zauk53avetd02svm001", results.get(0).getConfigurationResourceKeys().getVnfcName()); + assertEquals("zauk53avetd02tvm001", results.get(1).getConfigurationResourceKeys().getVnfcName()); + } + + @Test + public void selectExecutionListALaCarteVfModuleNoFabricDeleteTest() throws Exception { + String gAction = "deleteInstance"; + String resource = "VfModule"; + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules"); NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", - "UnassignVfModuleBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB"); + "UnassignVfModuleBB", "DeleteFabricConfigurationBB"); northBoundRequest.setOrchestrationFlowList(orchFlows); when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, @@ -1696,21 +1627,10 @@ public class WorkflowActionTest extends BaseTaskTest { when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(vfModule); List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>(); - org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc(); - vnfc.setModelInvariantId("modelInvariantId"); - vnfc.setVnfcName("testVnfcName"); - vnfcs.add(vnfc); - doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(), - anyObject()); - List<org.onap.aai.domain.yang.Configuration> configurations = - new ArrayList<org.onap.aai.domain.yang.Configuration>(); - org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration(); - doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(), + doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(), anyObject()); - doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject()); - SPY_workflowAction.selectExecutionList(execution); List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleBB", "UnassignVfModuleBB"); @@ -1720,13 +1640,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListMacroResumeTest() throws Exception { String gAction = "createInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); NorthBoundRequest northBoundRequest = new NorthBoundRequest(); @@ -1780,10 +1695,9 @@ public class WorkflowActionTest extends BaseTaskTest { doReturn(configurationResultWrappers).when(SPY_workflowAction).getResultWrappersFromRelationships(anyObject(), anyObject()); - List<org.onap.aai.domain.yang.Configuration> configurationsList = SPY_workflowAction.getRelatedResourcesInVnfc( - vnfc, org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION); - assertEquals(1, configurationsList.size()); - assertEquals("testConfigurationId", configurationsList.get(0).getConfigurationId()); + org.onap.aai.domain.yang.Configuration configuration = SPY_workflowAction.getRelatedResourcesInVnfc(vnfc, + org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION); + assertEquals("testConfigurationId", configuration.getConfigurationId()); } /** @@ -2961,8 +2875,7 @@ public class WorkflowActionTest extends BaseTaskTest { doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a"); doReturn(collectionResourceCustomization).when(catalogDbClient) .getNetworkCollectionResourceCustomizationByID("123"); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); ObjectMapper mapper = new ObjectMapper(); ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class); List<Resource> resourceCounter = new ArrayList<>(); @@ -3049,7 +2962,7 @@ public class WorkflowActionTest extends BaseTaskTest { ExecuteBuildingBlock result = null; try { result = workflowAction.buildExecuteBuildingBlock(new OrchestrationFlow(), null, null, null, null, null, - false, null, null, null, false, null, null, true); + false, null, null, null, false, null, null, true, null); } catch (NullPointerException e) { fail("NullPointerException should not be thrown when 'resource' is null"); } @@ -3138,4 +3051,16 @@ public class WorkflowActionTest extends BaseTaskTest { assertEquals(ebbs.get(i).getBuildingBlock().getBpmnFlowName(), flowNames[i]); } } + + private void initExecution(String gAction, String bpmnRequest, boolean isAlaCarte) { + execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); + execution.setVariable("requestAction", gAction); + execution.setVariable("bpmnRequest", bpmnRequest); + execution.setVariable("aLaCarte", isAlaCarte); + execution.setVariable("apiVersion", "7"); + } + + private String readBpmnRequestFromFile(String fileName) throws IOException { + return new String(Files.readAllBytes(Paths.get("src/test/resources/__files/" + fileName))); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListenerTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListenerTest.java new file mode 100644 index 0000000000..d2383185d0 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListenerTest.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Nokia + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.workflow.tasks.listeners; + +import static org.assertj.core.api.Assertions.assertThat; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.junit.Test; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.DelegateExecutionImpl; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; + +public class HomingListenerTest { + + private static final String CALLED_HOMING = "calledHoming"; + + @Test + public void shouldRunForAssignVnfBB() { + assertThat(new HomingListener().shouldRunFor("AssignVnfBB", false, null)).isTrue(); + } + + @Test + public void shouldNotRunForDifferentThanAssignVnfBB() { + assertThat(new HomingListener().shouldRunFor("someDifferentBB", false, null)).isFalse(); + } + + @Test + public void runWithHoming() { + // given + DelegateExecution execution = new DelegateExecutionFake(); + execution.setVariable("homing", true); + execution.setVariable(CALLED_HOMING, false); + BuildingBlockExecution buildingBlockExecution = new DelegateExecutionImpl(execution); + ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock(); + // when + new HomingListener().run(null, executeBuildingBlock, buildingBlockExecution); + // then + assertThat(executeBuildingBlock.isHoming()).isTrue(); + assertThat((boolean) buildingBlockExecution.getVariable(CALLED_HOMING)).isTrue(); + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListenerTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListenerTest.java new file mode 100644 index 0000000000..64c42fa577 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListenerTest.java @@ -0,0 +1,122 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Nokia + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.workflow.tasks.listeners; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.DelegateExecutionImpl; +import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.db.catalog.beans.VnfResourceCustomization; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.serviceinstancebeans.ModelInfo; +import org.onap.so.serviceinstancebeans.RequestDetails; + +@RunWith(MockitoJUnitRunner.class) +public class SkipConfigVnfListenerTest { + + private static final String MODEL_UUID = "modelUuidTest"; + private static final String VNF_CUSTOMIZATION_UUID = "vnfCustomizationUUIDTest"; + private static final String G_CURRENT_SEQUENCE = "gCurrentSequence"; + + private DelegateExecution execution; + @Mock + private CatalogDbClient catalogDbClientMock; + @InjectMocks + private SkipConfigVnfListener testedObject; + private BuildingBlockExecution buildingBlockExecution; + + @Before + public void setup() { + execution = new DelegateExecutionFake(); + buildingBlockExecution = new DelegateExecutionImpl(execution); + } + + @Test + public void shouldRunFor_ConfigAssignVnfBB() { + assertThat(testedObject.shouldRunFor("ConfigAssignVnfBB", true, null)).isTrue(); + } + + @Test + public void shouldRunFor_ConfigDeployVnfBB() { + assertThat(testedObject.shouldRunFor("ConfigDeployVnfBB", true, null)).isTrue(); + } + + @Test + public void shouldNotRunFor_notConfigBB() { + assertThat(testedObject.shouldRunFor("BBtest", true, null)).isFalse(); + } + + @Test + public void skipVnfSuccessful_sequenceIncremented() { + // given + execution.setVariable(G_CURRENT_SEQUENCE, 0); + List<VnfResourceCustomization> vnfResourceCustomizations = createVnfResourceCustomizationList(); + when(catalogDbClientMock.getVnfResourceCustomizationByModelUuid(MODEL_UUID)) + .thenReturn(vnfResourceCustomizations); + when(catalogDbClientMock.findVnfResourceCustomizationInList(VNF_CUSTOMIZATION_UUID, vnfResourceCustomizations)) + .thenReturn(createVnfResourceCustomization()); + // when + testedObject.run(null, createExecuteBuildingBlock(), buildingBlockExecution); + // then + assertThat((int) execution.getVariable(G_CURRENT_SEQUENCE)).isEqualTo(1); + } + + private ExecuteBuildingBlock createExecuteBuildingBlock() { + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelUuid(MODEL_UUID); + RequestDetails requestDetails = new RequestDetails(); + requestDetails.setModelInfo(modelInfo); + + ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock(); + BuildingBlock buildingBlock = new BuildingBlock(); + buildingBlock.setKey(VNF_CUSTOMIZATION_UUID); + executeBuildingBlock.setBuildingBlock(buildingBlock); + executeBuildingBlock.setRequestDetails(requestDetails); + return executeBuildingBlock; + } + + private List<VnfResourceCustomization> createVnfResourceCustomizationList() { + VnfResourceCustomization vnfResourceCustomization2 = new VnfResourceCustomization(); + vnfResourceCustomization2.setSkipPostInstConf(false); + return new ArrayList<>(Arrays.asList(createVnfResourceCustomization(), vnfResourceCustomization2)); + } + + private VnfResourceCustomization createVnfResourceCustomization() { + VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); + vnfResourceCustomization.setSkipPostInstConf(true); + return vnfResourceCustomization; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java index 59cd53edd5..b8be045f97 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java @@ -48,13 +48,18 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.aaiclient.client.aai.AAIResourcesClient; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf; import org.onap.so.client.aai.mapper.AAIObjectMapper; import org.onap.so.db.catalog.beans.OrchestrationStatus; @RunWith(MockitoJUnitRunner.Silent.class) public class AAIPnfResourcesTest extends TestDataSetup { + public static final String TEST_VERSION = "testVersion"; private static final String PNF_NAME = "pnfTest"; + public static final String TEST_CUSTOMIZATION_UUID = "testCustomizationUuid"; + public static final String TEST_INVARIANT_UUID = "testInvariantUuid"; + public static final String TEST_ROLE = "testRole"; private Pnf pnf; private ServiceInstance serviceInstance; @@ -110,42 +115,87 @@ public class AAIPnfResourcesTest extends TestDataSetup { @Test public void existingPnfInAaiWithInventoriedStatusCanBeUsed() throws Exception { // given + Pnf pnfTest = createPnfWithDefaultName(); org.onap.aai.domain.yang.Pnf pnfFromAai = createPnf(OrchestrationStatus.INVENTORIED.toString()); when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class, AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai)); // when - testedObject.checkIfPnfExistsInAaiAndCanBeUsed(PNF_NAME); + testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest); + verify(aaiResourcesClientMock, times(1)).update(any(), any()); } @Test public void existingPnfInAaiWithNullStatusCanBeUsed() throws Exception { // given + Pnf pnfTest = createPnfWithDefaultName(); org.onap.aai.domain.yang.Pnf pnfFromAai = createPnf(null); + pnfTest.setRole("test"); when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class, AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai)); // when - testedObject.checkIfPnfExistsInAaiAndCanBeUsed(PNF_NAME); + testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest); + verify(aaiResourcesClientMock, times(1)).update(any(), eq(pnfFromAai)); + } + + @Test + public void existingPnfInAaiIsUpdated() throws Exception { + // given + org.onap.aai.domain.yang.Pnf pnfFromAai = createPnf(null); + Pnf pnfTest = getPnfWithTestValues(); + when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class, + AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai)); + // when + testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest); + verify(aaiResourcesClientMock, times(1)).update(any(), eq(pnfFromAai)); + verifyPnfFromAai(pnfFromAai); + } + + private void verifyPnfFromAai(org.onap.aai.domain.yang.Pnf pnf) { + assertEquals(OrchestrationStatus.INVENTORIED.toString(), pnf.getOrchestrationStatus()); + assertEquals(TEST_ROLE, pnf.getNfRole()); + assertEquals(TEST_CUSTOMIZATION_UUID, pnf.getModelCustomizationId()); + assertEquals(TEST_INVARIANT_UUID, pnf.getModelInvariantId()); + assertEquals(TEST_VERSION, pnf.getModelVersionId()); + } + + private Pnf getPnfWithTestValues() { + Pnf pnfTest = createPnfWithDefaultName(); + ModelInfoPnf modelInfoPnf = getModelInfoPnf(); + pnfTest.setModelInfoPnf(modelInfoPnf); + pnfTest.setOrchestrationStatus(OrchestrationStatus.INVENTORIED); + pnfTest.setRole(TEST_ROLE); + return pnfTest; + } + + private ModelInfoPnf getModelInfoPnf() { + ModelInfoPnf modelInfoPnf = new ModelInfoPnf(); + modelInfoPnf.setModelCustomizationUuid(TEST_CUSTOMIZATION_UUID); + modelInfoPnf.setModelInvariantUuid(TEST_INVARIANT_UUID); + modelInfoPnf.setModelUuid(TEST_VERSION); + return modelInfoPnf; } @Test public void existingPnfInAaiWithEmptyStatusCanBeUsed() throws Exception { // given + Pnf pnfTest = createPnfWithDefaultName(); org.onap.aai.domain.yang.Pnf pnfFromAai = createPnf(Strings.EMPTY); when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class, AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai)); // when - testedObject.checkIfPnfExistsInAaiAndCanBeUsed(PNF_NAME); + testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest); } @Test public void existingPnfInAaiCanNotBeUsed() { // given + Pnf pnfTest = createPnfWithDefaultName(); org.onap.aai.domain.yang.Pnf pnfFromAai = createPnf(OrchestrationStatus.ACTIVE.toString()); when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class, AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai)); // when try { - testedObject.checkIfPnfExistsInAaiAndCanBeUsed(PNF_NAME); + testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest); } catch (Exception e) { // then assertThat(e.getMessage()).isEqualTo(String.format( @@ -153,6 +203,7 @@ public class AAIPnfResourcesTest extends TestDataSetup { + "if status is not set or set as Inventoried", PNF_NAME)); } + verify(aaiResourcesClientMock, times(0)).update(any(), any()); } @Test @@ -161,19 +212,21 @@ public class AAIPnfResourcesTest extends TestDataSetup { final String relatedTo = "service-instance"; final String serviceInstanceId = "service-instance-id"; final String path = "src/test/resources/__files/BuildingBlocks/aaiPnf.json"; + Pnf pnfTest = createPnfWithDefaultName(); org.onap.aai.domain.yang.Pnf pnfFromAai = new ObjectMapper().readValue(new File(path), org.onap.aai.domain.yang.Pnf.class); when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class, AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai)); // when try { - testedObject.checkIfPnfExistsInAaiAndCanBeUsed(PNF_NAME); + testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest); } catch (Exception e) { // then assertThat(e.getMessage()).isEqualTo(String.format( "Pnf with name %s exist with orchestration status %s and is related to %s service with certain service-instance-id: %s", PNF_NAME, OrchestrationStatus.ACTIVE, relatedTo, serviceInstanceId)); } + verify(aaiResourcesClientMock, times(0)).update(any(), any()); } private org.onap.aai.domain.yang.Pnf createPnf(String orchestrationStatus) { @@ -182,4 +235,10 @@ public class AAIPnfResourcesTest extends TestDataSetup { pnfFromAai.setOrchestrationStatus(orchestrationStatus); return pnfFromAai; } + + private Pnf createPnfWithDefaultName() { + Pnf pnfTest = new Pnf(); + pnfTest.setPnfName(PNF_NAME); + return pnfTest; + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java index 9049fe1965..3429a16f0b 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java @@ -35,6 +35,7 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GCTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -45,7 +46,6 @@ import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.mapper.GCTopologyOperationRequestMapper; @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCConfigurationResourcesTest extends TestDataSetup { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java index 327bae5749..f86a712e33 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java @@ -32,6 +32,7 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.NetworkTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; @@ -42,7 +43,6 @@ import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.NetworkTopologyOperationRequestMapper; @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCNetworkResourcesTest extends TestDataSetup { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java index ad05ac0072..4282b0d158 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java @@ -35,6 +35,7 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.ServiceTopologyOperationMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; @@ -42,7 +43,6 @@ import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.ServiceTopologyOperationMapper; @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCServiceInstanceResourcesTest extends TestDataSetup { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java index 14e993281a..813c2f7cd4 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java @@ -33,6 +33,7 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.VfModuleTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -43,8 +44,7 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.VfModuleTopologyOperationRequestMapper;; +import org.onap.so.client.sdnc.beans.SDNCSvcOperation;; @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCVfModuleResourcesTest extends TestDataSetup { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java index 0ccf056ddc..f9c380bc84 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java @@ -39,6 +39,7 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.VnfTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -49,7 +50,6 @@ import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.VnfTopologyOperationRequestMapper; @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCVnfResourcesTest extends TestDataSetup { diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json index 957c603dc9..191e0ac40e 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json @@ -2,6 +2,7 @@ "ApplicationControllerTaskRequest": { "controllerType": "TEST-CONTROLLER-NAME", "action": "Lock", + "requestorId": "testRequestorId", "identityUrl": "IDENTITY-URL-TEST", "applicationControllerVnf": { "vnfId": "TEST-VNF-ID", diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json index 040c680d1c..724f096a4e 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json @@ -2,6 +2,7 @@ "ApplicationControllerTaskRequest": { "controllerType": "APPC", "action": "ConfigModify", + "requestorId": "testRequestorId", "identityUrl": "IDENTITY-URL-TEST", "applicationControllerVnf": { "vnfId": "TEST-VNF-ID", diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/aaiVfModule.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/aaiVfModule.json new file mode 100644 index 0000000000..ac047a9638 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/aaiVfModule.json @@ -0,0 +1,40 @@ +{ + "automated-assignment": false, + "heat-stack-id": "zauk53avetd02_base/5c7a8a55-edb8-458e-a7dc-2dbbc696682e", + "is-base-vf-module": true, + "model-customization-id": "521d5f9b-0b76-49d3-879e-fce8767f34eb", + "model-invariant-id": "f0ac6f78-543f-41ac-81c3-672a4d47001c", + "model-version-id": "215ea5bd-f0e0-4560-9f64-9a9716ff6178", + "module-index": 0, + "orchestration-status": "Active", + "relationship-list": { + "relationship": [ + { + "related-link": "/aai/v20/network/vnfcs/vnfc/zauk53avetd02svm001", + "related-to": "vnfc", + "relationship-data": [ + { + "relationship-key": "vnfc.vnfc-name", + "relationship-value": "zauk53avetd02svm001" + } + ], + "relationship-label": "org.onap.relationships.inventory.Uses" + }, + { + "related-link": "/aai/v20/network/vnfcs/vnfc/zauk53avetd02tvm001", + "related-to": "vnfc", + "relationship-data": [ + { + "relationship-key": "vnfc.vnfc-name", + "relationship-value": "zauk53avetd02tvm001" + } + ], + "relationship-label": "org.onap.relationships.inventory.Uses" + } + ] + }, + "resource-version": "1595304004908", + "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/16b9c65d-70c7-47f0-aa03-7cdb8dfb76be/service-data/vnfs/vnf/9cf22c37-4f39-4fa5-a942-b72efc8f6450/vnf-data/vf-modules/vf-module/2cf0ecd4-737c-4a46-9097-adc2f0088483/vf-module-data/vf-module-topology/", + "vf-module-id": "2cf0ecd4-737c-4a46-9097-adc2f0088483", + "vf-module-name": "zauk53avetd02_base" +}
\ No newline at end of file diff --git a/cloudify-client/pom.xml b/cloudify-client/pom.xml index 6bb9357c38..ccf2c4270e 100644 --- a/cloudify-client/pom.xml +++ b/cloudify-client/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>so</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <groupId>org.onap.so</groupId> @@ -18,7 +18,8 @@ <plugins> <plugin> <artifactId>maven-jar-plugin</artifactId> - <version>2.6</version> + <!--<version>2.6</version>--> + <version>3.0.2</version> <configuration> <classesDirectory>target/classes</classesDirectory> </configuration> diff --git a/common/pom.xml b/common/pom.xml index ab498f8844..08554480c3 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -1,11 +1,11 @@ -<?xml version="1.0"?> +<?xml version="1.0" ?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.so</groupId> <artifactId>so</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>common</artifactId> <name>MSO Common classes</name> @@ -58,7 +58,7 @@ <dependency> <groupId>org.modelmapper</groupId> <artifactId>modelmapper</artifactId> - <version>1.1.0</version> + <version>2.3.2</version> </dependency> <dependency> <groupId>com.google.guava</groupId> @@ -109,6 +109,10 @@ <optional>true</optional> </dependency> <dependency> + <groupId>org.springframework.retry</groupId> + <artifactId>spring-retry</artifactId> + </dependency> + <dependency> <groupId>net.jodah</groupId> <artifactId>failsafe</artifactId> <version>2.0.1</version> @@ -133,12 +137,16 @@ <dependency> <groupId>org.onap.aaf.authz</groupId> <artifactId>aaf-cadi-aaf</artifactId> - <version>2.1.9</version> + <version>${aaf.cadi.version}</version> <exclusions> <exclusion> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> </exclusion> + <exclusion> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + </exclusion> </exclusions> </dependency> <dependency> @@ -262,6 +270,21 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>javax.xml.bind</groupId> + <artifactId>jaxb-api</artifactId> + <version>2.3.0</version> + </dependency> + <dependency> + <groupId>com.sun.xml.bind</groupId> + <artifactId>jaxb-core</artifactId> + <version>2.3.0</version> + </dependency> + <dependency> + <groupId>com.sun.xml.bind</groupId> + <artifactId>jaxb-impl</artifactId> + <version>2.3.0</version> + </dependency> </dependencies> <dependencyManagement> <dependencies> @@ -335,4 +358,4 @@ </plugin> </plugins> </build> -</project> +</project>
\ No newline at end of file diff --git a/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java b/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java index c240957ae9..010e184618 100644 --- a/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java +++ b/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java @@ -11,6 +11,7 @@ public class ApplicationControllerTaskRequest implements Serializable { private static final long serialVersionUID = -3150320542857627682L; private Action action; + private String requestorId; private String controllerType; private String identityUrl; private String operationsTimeout; @@ -110,6 +111,14 @@ public class ApplicationControllerTaskRequest implements Serializable { this.newSoftwareVersion = newSoftwareVersion; } + public String getRequestorId() { + return requestorId; + } + + public void setRequestorId(String requestorId) { + this.requestorId = requestorId; + } + } diff --git a/common/src/main/java/org/onap/so/client/KeyStoreLoader.java b/common/src/main/java/org/onap/so/client/KeyStoreLoader.java new file mode 100644 index 0000000000..8279be8635 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/KeyStoreLoader.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Deutsche Telekom. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client; + +import java.io.FileInputStream; +import java.nio.file.Paths; +import java.security.KeyStore; + +public abstract class KeyStoreLoader { + + static final String SSL_KEY_STORE_KEY = "javax.net.ssl.keyStore"; + + static public KeyStore getKeyStore() { + KeyStore ks = null; + final char[] password = getSSlKeyStorePassword().toCharArray(); + try (FileInputStream fis = + new FileInputStream(Paths.get(System.getProperty(SSL_KEY_STORE_KEY)).normalize().toString())) { + ks = KeyStore.getInstance(KeyStore.getDefaultType()); + ks.load(fis, password); + } catch (final Exception e) { + return null; + } + + return ks; + } + + static public String getSSlKeyStorePassword() { + return System.getProperty("javax.net.ssl.keyStorePassword"); + } +} diff --git a/common/src/main/java/org/onap/so/client/RestClientSSL.java b/common/src/main/java/org/onap/so/client/RestClientSSL.java index f5737b862c..1e8953892e 100644 --- a/common/src/main/java/org/onap/so/client/RestClientSSL.java +++ b/common/src/main/java/org/onap/so/client/RestClientSSL.java @@ -20,9 +20,7 @@ package org.onap.so.client; -import java.io.FileInputStream; import java.net.URI; -import java.nio.file.Paths; import java.security.KeyStore; import java.security.NoSuchAlgorithmException; import java.util.Optional; @@ -33,10 +31,8 @@ import javax.ws.rs.client.ClientBuilder; public abstract class RestClientSSL extends RestClient { private static final String TRUE = "true"; - private static final String SSL_KEY_STORE_KEY = "javax.net.ssl.keyStore"; private static final String MSO_LOAD_SSL_CLIENT_KEYSTORE_KEY = "mso.load.ssl.client.keystore"; - protected RestClientSSL(RestProperties props, Optional<URI> path) { super(props, path); } @@ -52,9 +48,9 @@ public abstract class RestClientSSL extends RestClient { try { String loadSSLKeyStore = System.getProperty(RestClientSSL.MSO_LOAD_SSL_CLIENT_KEYSTORE_KEY); if (loadSSLKeyStore != null && loadSSLKeyStore.equalsIgnoreCase(TRUE)) { - KeyStore ks = getKeyStore(); + KeyStore ks = KeyStoreLoader.getKeyStore(); if (ks != null) { - client = ClientBuilder.newBuilder().keyStore(ks, getSSlKeyStorePassword()).build(); + client = ClientBuilder.newBuilder().keyStore(ks, KeyStoreLoader.getSSlKeyStorePassword()).build(); logger.info("RestClientSSL not using default SSL context - setting keystore here."); return client; } @@ -67,23 +63,4 @@ public abstract class RestClientSSL extends RestClient { } return client; } - - private KeyStore getKeyStore() { - KeyStore ks = null; - char[] password = getSSlKeyStorePassword().toCharArray(); - try (FileInputStream fis = new FileInputStream( - Paths.get(System.getProperty(RestClientSSL.SSL_KEY_STORE_KEY)).normalize().toString())) { - ks = KeyStore.getInstance(KeyStore.getDefaultType()); - - ks.load(fis, password); - } catch (Exception e) { - return null; - } - - return ks; - } - - private String getSSlKeyStorePassword() { - return System.getProperty("javax.net.ssl.keyStorePassword"); - } } diff --git a/common/src/main/java/org/onap/so/client/cds/CDSProcessingClient.java b/common/src/main/java/org/onap/so/client/cds/CDSProcessingClient.java index 7ef158996d..fa309b54fe 100644 --- a/common/src/main/java/org/onap/so/client/cds/CDSProcessingClient.java +++ b/common/src/main/java/org/onap/so/client/cds/CDSProcessingClient.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 - 2019 Bell Canada. + * Copyright (C) 2017 - 2019 Bell Canada, Deutsche Telekom. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +23,16 @@ package org.onap.so.client.cds; import io.grpc.ManagedChannel; import io.grpc.internal.DnsNameResolverProvider; import io.grpc.internal.PickFirstLoadBalancerProvider; +import io.grpc.netty.GrpcSslContexts; import io.grpc.netty.NettyChannelBuilder; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; import java.util.concurrent.CountDownLatch; +import javax.net.ssl.SSLException; +import javax.net.ssl.TrustManagerFactory; import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; +import org.onap.so.client.KeyStoreLoader; import org.onap.so.client.PreconditionFailedException; import org.onap.so.client.RestPropertiesLoader; import org.slf4j.Logger; @@ -73,10 +80,36 @@ public class CDSProcessingClient implements AutoCloseable { throw new PreconditionFailedException( "No RestProperty.CDSProperties implementation found on classpath, can't create client."); } - this.channel = NettyChannelBuilder.forAddress(props.getHost(), props.getPort()) + NettyChannelBuilder builder = NettyChannelBuilder.forAddress(props.getHost(), props.getPort()) .nameResolverFactory(new DnsNameResolverProvider()) - .loadBalancerFactory(new PickFirstLoadBalancerProvider()) - .intercept(new BasicAuthClientInterceptor(props)).usePlaintext().build(); + .loadBalancerFactory(new PickFirstLoadBalancerProvider()); + if (props.getUseSSL()) { + log.info("Configure SSL connection"); + KeyStore ks = KeyStoreLoader.getKeyStore(); + if (ks == null) { + log.error("Can't load KeyStore"); + throw new RuntimeException("Can't load KeyStore to create secure channel"); + } + try { + TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + tmf.init(ks); + builder.sslContext(GrpcSslContexts.forClient().trustManager(tmf).build()); + } catch (NoSuchAlgorithmException e) { + log.error("Can't get default TrustManager algorithm"); + throw new RuntimeException(e); + } catch (KeyStoreException e) { + log.error("TrustManagerFactory initialization failed"); + throw new RuntimeException(e); + } catch (SSLException e) { + log.error("SslContext build error"); + throw new RuntimeException(e); + } + } + if (props.getUseBasicAuth()) { + log.info("Configure Basic authentication"); + builder.intercept(new BasicAuthClientInterceptor(props)).usePlaintext(); + } + this.channel = builder.build(); this.handler = new CDSProcessingHandler(listener); log.info("CDSProcessingClient started"); } diff --git a/common/src/main/java/org/onap/so/client/cds/CDSProperties.java b/common/src/main/java/org/onap/so/client/cds/CDSProperties.java index 37a5c0bc18..db566fa3de 100644 --- a/common/src/main/java/org/onap/so/client/cds/CDSProperties.java +++ b/common/src/main/java/org/onap/so/client/cds/CDSProperties.java @@ -22,7 +22,6 @@ package org.onap.so.client.cds; import org.onap.so.client.RestProperties; - public interface CDSProperties extends RestProperties { String getHost(); @@ -32,4 +31,8 @@ public interface CDSProperties extends RestProperties { String getBasicAuth(); int getTimeout(); + + boolean getUseSSL(); + + boolean getUseBasicAuth(); } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/BadResponseException.java b/common/src/main/java/org/onap/so/client/exception/BadResponseException.java index 7b1066d48c..7b1066d48c 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/BadResponseException.java +++ b/common/src/main/java/org/onap/so/client/exception/BadResponseException.java diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/MapperException.java b/common/src/main/java/org/onap/so/client/exception/MapperException.java index 354c669d62..354c669d62 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/MapperException.java +++ b/common/src/main/java/org/onap/so/client/exception/MapperException.java diff --git a/common/src/main/java/org/onap/so/openpojo/rules/EqualsAndHashCodeTester.java b/common/src/main/java/org/onap/so/openpojo/rules/EqualsAndHashCodeTester.java index 6e2bc97ee9..84efa65a50 100644 --- a/common/src/main/java/org/onap/so/openpojo/rules/EqualsAndHashCodeTester.java +++ b/common/src/main/java/org/onap/so/openpojo/rules/EqualsAndHashCodeTester.java @@ -31,6 +31,8 @@ import java.util.List; import java.util.Set; import javax.persistence.GeneratedValue; import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; import org.hamcrest.Matcher; import com.openpojo.business.annotation.BusinessKey; import com.openpojo.random.RandomFactory; @@ -42,7 +44,6 @@ import com.openpojo.validation.utils.ValidationHelper; public class EqualsAndHashCodeTester implements Tester { - private final Matcher m; private boolean onlyDeclaredMethods = false; @@ -118,7 +119,6 @@ public class EqualsAndHashCodeTester implements Tester { } } - private Set<PojoField> hasIdOrBusinessKey(PojoClass pojoClass) { final Set<PojoField> fields = new HashSet<>(); diff --git a/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java b/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java index 840a978a61..fff82ea5bc 100644 --- a/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java +++ b/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java @@ -22,8 +22,16 @@ public class ExternalTaskServiceUtils { @Autowired public Environment env; - protected Set<ExternalTaskClient> taskClients = ConcurrentHashMap.newKeySet(); + private static final long DEFAULT_LOCK_DURATION_LONG = 2700000; + private static final long DEFAULT_LOCK_DURATION_MEDIUM = 900000; + private static final long DEFAULT_LOCK_DURATION_SHORT = 300000; + + private static final String LOCK_DURATION_LONG = "mso.workflow.topics.lockDurationLong"; + private static final String LOCK_DURATION_MEDIUM = "mso.workflow.topics.lockDurationMedium"; + private static final String LOCK_DURATION_SHORT = "mso.workflow.topics.lockDurationShort"; + + protected Set<ExternalTaskClient> taskClients = ConcurrentHashMap.newKeySet(); private static final Logger logger = LoggerFactory.getLogger(ExternalTaskServiceUtils.class); @@ -59,6 +67,11 @@ public class ExternalTaskServiceUtils { return lockDuration; } + public Long getLongLockDuration() { + Long lockDuration = Long.parseLong(env.getProperty("mso.long.lock-time", "600000")); + return lockDuration; + } + @ScheduledLogging @Scheduled(fixedDelay = 30000) public void checkAllClientsActive() { @@ -69,4 +82,16 @@ public class ExternalTaskServiceUtils { return taskClients; } + public long getLockDurationLong() { + return env.getProperty(LOCK_DURATION_LONG, Long.class, new Long(DEFAULT_LOCK_DURATION_LONG)); + } + + public long getLockDurationMedium() { + return env.getProperty(LOCK_DURATION_MEDIUM, Long.class, new Long(DEFAULT_LOCK_DURATION_MEDIUM)); + } + + public long getLockDurationShort() { + return env.getProperty(LOCK_DURATION_SHORT, Long.class, new Long(DEFAULT_LOCK_DURATION_SHORT)); + } + } diff --git a/common/src/test/java/org/onap/so/client/HttpClientTest.java b/common/src/test/java/org/onap/so/client/HttpClientTest.java index a01e2bb812..e9e8fe7853 100644 --- a/common/src/test/java/org/onap/so/client/HttpClientTest.java +++ b/common/src/test/java/org/onap/so/client/HttpClientTest.java @@ -40,7 +40,7 @@ public class HttpClientTest { private final HttpClientFactory httpClientFactory = new HttpClientFactory(); @Rule - public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicHttpsPort()); + public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort().dynamicHttpsPort()); @Test public void testPost_success() throws MalformedURLException { @@ -48,7 +48,7 @@ public class HttpClientTest { wireMockRule.stubFor(post(urlEqualTo("/services/sdnc/post")) .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(""))); - URL url = new URL("http://localhost:" + wireMockConfig().portNumber() + "/services/sdnc/post"); + URL url = new URL("http://localhost:" + wireMockRule.port() + "/services/sdnc/post"); HttpClient client = httpClientFactory.newJsonClient(url, ONAPComponents.BPMN); client.addBasicAuthHeader( @@ -67,7 +67,7 @@ public class HttpClientTest { wireMockRule.stubFor(post(urlEqualTo("/services/sdnc/post")) .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(""))); - URL url = new URL("http://localhost:" + wireMockConfig().portNumber() + "/services/sdnc/post"); + URL url = new URL("http://localhost:" + wireMockRule.port() + "/services/sdnc/post"); HttpClient client = httpClientFactory.newJsonClient(url, ONAPComponents.BPMN); client.addAdditionalHeader("Accept", "application/json"); @@ -85,7 +85,7 @@ public class HttpClientTest { wireMockRule.stubFor(post(urlEqualTo("/services/sdnc/post")) .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(""))); - URL url = new URL("http://localhost:" + wireMockConfig().portNumber() + "/services/sdnc/post"); + URL url = new URL("http://localhost:" + wireMockRule.port() + "/services/sdnc/post"); HttpClient client = httpClientFactory.newJsonClient(url, ONAPComponents.BPMN); client.addBasicAuthHeader("", "12345"); diff --git a/common/src/test/java/org/onap/so/client/cds/CDSProcessingClientTest.java b/common/src/test/java/org/onap/so/client/cds/CDSProcessingClientTest.java index 18ec9efa50..5792c28f5f 100644 --- a/common/src/test/java/org/onap/so/client/cds/CDSProcessingClientTest.java +++ b/common/src/test/java/org/onap/so/client/cds/CDSProcessingClientTest.java @@ -20,7 +20,6 @@ package org.onap.so.client.cds; - import static org.junit.Assert.*; import static org.mockito.Mockito.*; import io.grpc.inprocess.InProcessChannelBuilder; @@ -58,7 +57,6 @@ public class CDSProcessingClientTest { private CDSProcessingHandler handler; private CDSProcessingClient client; - private final MutableHandlerRegistry serviceRegistry = new MutableHandlerRegistry(); private final List<String> messagesDelivered = new ArrayList<>(); private final CountDownLatch allRequestsDelivered = new CountDownLatch(1); @@ -115,7 +113,6 @@ public class CDSProcessingClientTest { new CDSProcessingClient(listener); } - @Test public void testSendMessageFail() throws Exception { diff --git a/common/src/test/java/org/onap/so/client/cds/TestCDSPropertiesImpl.java b/common/src/test/java/org/onap/so/client/cds/TestCDSPropertiesImpl.java index 2834d37f1f..41238e539e 100644 --- a/common/src/test/java/org/onap/so/client/cds/TestCDSPropertiesImpl.java +++ b/common/src/test/java/org/onap/so/client/cds/TestCDSPropertiesImpl.java @@ -72,4 +72,14 @@ public class TestCDSPropertiesImpl implements CDSProperties { public int getTimeout() { return 60; } + + @Override + public boolean getUseSSL() { + return false; + } + + @Override + public boolean getUseBasicAuth() { + return true; + } } diff --git a/cxf-logging/pom.xml b/cxf-logging/pom.xml index c056daf6f8..cb0d126283 100644 --- a/cxf-logging/pom.xml +++ b/cxf-logging/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>so</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <name>CXFLogging</name> <description>Common CXF Logging Classes</description> diff --git a/deployment-configs/pom.xml b/deployment-configs/pom.xml index 002cd19f81..bc4df6ad36 100644 --- a/deployment-configs/pom.xml +++ b/deployment-configs/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>so</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>deployment-configs</artifactId> <name>deployment-configs</name> diff --git a/docs/conf.py b/docs/conf.py index 8f40e8b817..5371015c66 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -12,4 +12,4 @@ intersphinx_mapping = {} html_last_updated_fmt = '%d-%b-%y %H:%M' def setup(app): - app.add_stylesheet("css/ribbon_onap.css") + app.add_stylesheet("css/ribbon.css") diff --git a/docs/developer_info/Working_with_so_monitoring.rst b/docs/developer_info/Working_with_so_monitoring.rst new file mode 100644 index 0000000000..18b6d948c0 --- /dev/null +++ b/docs/developer_info/Working_with_so_monitoring.rst @@ -0,0 +1,70 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 +.. Copyright 2017 Huawei Technologies Co., Ltd. + +Working with SO Monitoring +========================== + +After the SO code is fully deployed, certain changes needs to be made in order to access the so-monitoring ui. + +1. Change the service type to NodePort +--------------------------------------- + +By default, the type of the so monitoring service is ClusterIP, which makes the Service only reachable from within the cluster. +This is changed to NodePort, which is used to expose the service at a static port . Hence we will be able to contact the NodePort Service, from outside the cluster, by requesting <NodeIP>:<NodePort>. + +Command used to get the service configuration of so monitoring is: + +**sudo kubectl edit svc so-monitoring -n onap** + +.. image:: ../images/nodeport.png + +2. Add the credentials to login +-------------------------------- + +The override.yaml needs to be added with the login credentials, that is the username and the password in encrypted form. + +.. code-block:: bash + + spring: + main: + allow-bean-definition-overriding: true + security: + usercredentials: + - + username: gui + password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' + role: GUI-Client + +This override.yaml can be directly edited in case of local setup using docker. + +When deploying in any environment using OOM, then after deployment the configmap needs to be edited. As configmap is the one reading the override.yaml. + +**Note** : Before deployment , if we add these changes in override.yaml ,then it may give parsing error in configmap while deployment. And after deployment the permissions on override.yaml don't allow us to edit it. So the best option is to edit the configmap using the below command and restart the pod. + +**kubectl -n onap edit configmap dev-so-monitoring-app-configmap** + +.. image:: ../images/configmap.png + +Special care needs to be given to the indentation. spring needs to be inline with the mso already present and others added accordingly. + +3. Login to SO Monitoring +------------------------- + +We need to first identify the external port which its mapped to using the following command : + +**sudo kubectl -n onap get svc | grep so-monitoring** + +.. image:: ../images/nodemap.png + +Then access the UI of so monitoring , for example by http://<IP>:30224/ + +username : gui, +password: password1$ + + +.. image:: ../images/ui.png + + + + diff --git a/docs/developer_info/developer_information.rst b/docs/developer_info/developer_information.rst index 10ea8360b9..63338de898 100644 --- a/docs/developer_info/developer_information.rst +++ b/docs/developer_info/developer_information.rst @@ -11,6 +11,7 @@ SO Developer Information Building_SO.rst Working_with_SO_Docker.rst + Working_with_so_monitoring.rst Camunda_Cockpit_Community_Edition.rst Camunda_Cockpit_Enterprise_Edition.rst Camunda_Modeler.rst diff --git a/docs/images/configmap.png b/docs/images/configmap.png Binary files differnew file mode 100644 index 0000000000..3683de3d57 --- /dev/null +++ b/docs/images/configmap.png diff --git a/docs/images/nodemap.png b/docs/images/nodemap.png Binary files differnew file mode 100644 index 0000000000..8dfda6ca12 --- /dev/null +++ b/docs/images/nodemap.png diff --git a/docs/images/nodeport.png b/docs/images/nodeport.png Binary files differnew file mode 100644 index 0000000000..53bc02f7f9 --- /dev/null +++ b/docs/images/nodeport.png diff --git a/docs/images/ui.png b/docs/images/ui.png Binary files differnew file mode 100644 index 0000000000..1c075bab22 --- /dev/null +++ b/docs/images/ui.png diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 00b9530655..ed8c7de674 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -9,7 +9,82 @@ Service Orchestrator Release Notes The SO provides the highest level of service orchestration in the ONAP architecture. -Version: 1.6.1 + + +Version: 1.6.4 +----------------------- + +:Release Date: 13th July 2020 + +**Docker Images** + +**Dockers released for SO:** + + - onap/so/api-handler-infra + - onap/so/bpmn-infra + - onap/so/catalog-db-adapter + - onap/so/openstack-adapter + - onap/so/request-db-adapter + - onap/so/sdc-controller + - onap/so/sdnc-adapter + - onap/so/so-monitoring + - onap/so/vfc-adapter + - onap/so/vnfm-adapter + - onap/so/ve-vnfm-adapter + - onap/so/nssmf-adapter + - onap/so/appc-orchestrator + +**Release Purpose** + +The main goal of the Frankfurt maintenance release was to: + + - Appc Orchestraor changes were merged in SO and OOM as part of the release. This also used for the inplace software update flows. + - MDONS had an issue in its delete flow that was addressed. + - Vnfm-Adapter was unable to communicate with ETSI-Catalog through MSB, as the MSB cert is changed during the RC2 and this impacted the SO and ETSI Catalog DB connectivity. + +**New Features** +--N/A-- +**Epics** +--N/A-- +**Stories** +--N/A-- +**Key Issues Addressed** + +- [`SO-2903 <https://jira.onap.org/browse/SO-2903>`__\ ] - Include so-appc-orchestrator with SO OOM. +- [`SO-2967 <https://jira.onap.org/browse/SO-2967>`__\ ] - Error in Delete MDONS service flow which causes No such property error. +- [`SO-2982 <https://jira.onap.org/browse/SO-2982>`__\ ] - Vnfm-Adapter unable to communicate with ETSI-Catalog through MSB. +- [`SO-3022 <https://jira.onap.org/browse/SO-3022>`__\ ] - Use BB-based VNF-InPlaceUpdate flow for inPlaceSoftwareUpdate requests. + + +**Security Notes** + + Quick Links: + + - `SO project page <https://wiki.onap.org/display/DW/Service+Orchestrator+Project>`_ + - `Passing Badge information for SO <https://bestpractices.coreinfrastructure.org/en/projects/1702>`_ + + +**Known Issues** + + +OJSI Issues + + N/A + +**Upgrade Notes** + + N/A + +**Deprecation Notes** + + N/A + +**Other** + + N/A +*************************************************************************************** + +Version: 1.6.3 ----------------------- :Release Date: @@ -224,7 +299,10 @@ Features Being considered for F release (As per the resource availability): **Known Issues** - N/A + +- [`SO-2903 <https://jira.onap.org/browse/SO-2903>`__\ ] - Include so-appc-orchestrator with SO OOM +Appc Orchestrator Pod release : Appc - Ochestrator code changes will be delivered as part of the patch on Frankfurt as the OOM changes were delayed. These would be release as part of the post release flows. + OJSI Issues diff --git a/graph-inventory/aai-client/pom.xml b/graph-inventory/aai-client/pom.xml index 8c7be3eb7e..dc9bf47070 100644 --- a/graph-inventory/aai-client/pom.xml +++ b/graph-inventory/aai-client/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>graph-inventory</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>aai-client</artifactId> <build> diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIClient.java index 1cd23614b5..1f747e6c8c 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIClient.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIClient.java @@ -21,11 +21,13 @@ package org.onap.aaiclient.client.aai; import java.net.URI; +import java.util.HashMap; +import java.util.Map; import javax.ws.rs.NotFoundException; import javax.ws.rs.core.UriBuilder; -import org.onap.so.client.RestClient; import org.onap.aaiclient.client.graphinventory.GraphInventoryClient; import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriComputationException; +import org.onap.so.client.RestClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,11 +38,20 @@ public class AAIClient extends GraphInventoryClient { protected AAIVersion version; protected AAIClient() { - super(AAIProperties.class); + super(AAIProperties.class, new HashMap<String, String>()); } protected AAIClient(AAIVersion version) { - super(AAIProperties.class); + super(AAIProperties.class, new HashMap<String, String>()); + this.version = version; + } + + protected AAIClient(Map<String, String> additionalHeaders) { + super(AAIProperties.class, additionalHeaders); + } + + protected AAIClient(AAIVersion version, Map<String, String> additionalHeaders) { + super(AAIProperties.class, additionalHeaders); this.version = version; } @@ -54,7 +65,7 @@ public class AAIClient extends GraphInventoryClient { protected RestClient createClient(URI uri) { try { - return new AAIRestClient(getRestProperties(), constructPath(uri)); + return new AAIRestClient(getRestProperties(), constructPath(uri), additionalHeaders); } catch (GraphInventoryUriComputationException | NotFoundException e) { logger.debug("failed to construct A&AI uri", e); throw e; diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIDSLQueryClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIDSLQueryClient.java index 238e87392f..378db87d9b 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIDSLQueryClient.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIDSLQueryClient.java @@ -26,16 +26,17 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.aaiclient.client.graphinventory.GraphInventoryQueryClient; import org.onap.aaiclient.client.graphinventory.entities.DSLQuery; import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventoryUri; +import com.google.common.collect.ImmutableMap; public class AAIDSLQueryClient extends GraphInventoryQueryClient<AAIDSLQueryClient, DSLQuery, AAIResultWrapper, AAIObjectType> { public AAIDSLQueryClient() { - super(new AAIClient()); + super(new AAIClient(ImmutableMap.of("X-DslApiVersion", "V2"))); } public AAIDSLQueryClient(AAIVersion version) { - super(new AAIClient(version)); + super(new AAIClient(version, ImmutableMap.of("X-DslApiVersion", "V2"))); } @Override @@ -53,5 +54,4 @@ public class AAIDSLQueryClient public AAIObjectType createType(String name, String uri) { return new AAIFluentTypeReverseLookup().fromName(name, uri); } - } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java index b3402fa221..2335a48d43 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java @@ -63,6 +63,7 @@ import org.onap.aai.domain.yang.ServiceSubscription; import org.onap.aai.domain.yang.SliceProfile; import org.onap.aai.domain.yang.SpPartner; import org.onap.aai.domain.yang.SriovPf; +import org.onap.aai.domain.yang.SriovVf; import org.onap.aai.domain.yang.Subnet; import org.onap.aai.domain.yang.Tenant; import org.onap.aai.domain.yang.TunnelXconnect; @@ -184,6 +185,8 @@ public class AAIObjectType implements AAIObjectBase, GraphInventoryObjectType, S new AAIObjectType(AAINamespaceConstants.NETWORK, AggregateRoute.class); public static final AAIObjectType L_INTERFACE = new AAIObjectType(AAIObjectType.VSERVER.uriTemplate(), LInterface.class); + public static final AAIObjectType SRIOV_VF = + new AAIObjectType(AAIObjectType.L_INTERFACE.uriTemplate(), SriovVf.class); public static final AAIObjectType SUB_L_INTERFACE = new AAIObjectType(AAIObjectType.L_INTERFACE.uriTemplate(), "/l-interfaces/l-interface/{sub-interface-name}", "sub-l-interface"); public static final AAIObjectType IMAGE = new AAIObjectType(AAIObjectType.CLOUD_REGION.uriTemplate(), Image.class); diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClient.java index 9a8a2a53c0..0f69b0cc8f 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClient.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClient.java @@ -23,18 +23,20 @@ package org.onap.aaiclient.client.aai; import java.net.URI; import java.util.Map; import java.util.Optional; -import org.onap.so.client.ResponseExceptionMapper; import org.onap.aaiclient.client.graphinventory.GraphInventoryPatchConverter; import org.onap.aaiclient.client.graphinventory.GraphInventoryRestClient; import org.onap.logging.filter.base.ONAPComponents; +import org.onap.so.client.ResponseExceptionMapper; public class AAIRestClient extends GraphInventoryRestClient { private final AAIProperties aaiProperties; + private final Map<String, String> additionalHeaders; - protected AAIRestClient(AAIProperties props, URI uri) { + protected AAIRestClient(AAIProperties props, URI uri, Map<String, String> additionalHeaders) { super(props, uri); this.aaiProperties = props; + this.additionalHeaders = additionalHeaders; } @Override @@ -46,6 +48,7 @@ public class AAIRestClient extends GraphInventoryRestClient { protected void initializeHeaderMap(Map<String, String> headerMap) { headerMap.put("X-FromAppId", aaiProperties.getSystemName()); headerMap.put("X-TransactionId", requestId); + headerMap.putAll(additionalHeaders); String auth = aaiProperties.getAuth(); String key = aaiProperties.getKey(); diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryClient.java index a2bb8bc141..f8f977d117 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryClient.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryClient.java @@ -21,20 +21,25 @@ package org.onap.aaiclient.client.graphinventory; import java.net.URI; +import java.util.Map; +import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventoryUri; +import org.onap.aaiclient.client.graphinventory.entities.uri.HttpAwareUri; import org.onap.so.client.RestClient; import org.onap.so.client.RestProperties; import org.onap.so.client.RestPropertiesLoader; -import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventoryUri; -import org.onap.aaiclient.client.graphinventory.entities.uri.HttpAwareUri; +import com.google.common.collect.ImmutableMap; public abstract class GraphInventoryClient { private RestProperties props; + protected final Map<String, String> additionalHeaders; - protected GraphInventoryClient(Class<? extends RestProperties> propertiesClass) { + protected GraphInventoryClient(Class<? extends RestProperties> propertiesClass, + Map<String, String> additionalHeaders) { RestProperties props = RestPropertiesLoader.getInstance().getNewImpl(propertiesClass); this.props = props; + this.additionalHeaders = additionalHeaders; } protected abstract URI constructPath(URI uri); @@ -64,4 +69,8 @@ public abstract class GraphInventoryClient { public abstract GraphInventoryVersion getVersion(); public abstract String getGraphDBName(); + + public Map<String, String> getAdditionalHeaders() { + return ImmutableMap.copyOf(this.additionalHeaders); + } } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryQueryClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryQueryClient.java index c749561e5f..a192e3828a 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryQueryClient.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryQueryClient.java @@ -138,4 +138,8 @@ public abstract class GraphInventoryQueryClient<S, I, Wrapper extends GraphInven } return clone; } + + public GraphInventoryClient getClient() { + return this.client; + } } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLNodeBase.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLNodeBase.java index c071e24391..5c88e8e42e 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLNodeBase.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLNodeBase.java @@ -22,13 +22,17 @@ package org.onap.aaiclient.client.graphinventory.entities; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; import java.util.List; +import java.util.stream.Collectors; import org.onap.aaiclient.client.aai.entities.QueryStep; import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectName; public abstract class DSLNodeBase<T extends DSLNodeBase<?>> implements QueryStep { protected final String nodeName; + protected final Collection<String> fields; protected final List<DSLNodeKey> nodeKeys; protected final StringBuilder query; protected boolean output = false; @@ -37,6 +41,7 @@ public abstract class DSLNodeBase<T extends DSLNodeBase<?>> implements QueryStep this.nodeName = ""; this.nodeKeys = new ArrayList<>(); this.query = new StringBuilder(); + this.fields = new LinkedHashSet<>(); } @@ -44,6 +49,7 @@ public abstract class DSLNodeBase<T extends DSLNodeBase<?>> implements QueryStep this.nodeName = name.typeName(); this.nodeKeys = new ArrayList<>(); this.query = new StringBuilder(); + this.fields = new LinkedHashSet<>(); query.append(nodeName); } @@ -51,6 +57,7 @@ public abstract class DSLNodeBase<T extends DSLNodeBase<?>> implements QueryStep this.nodeName = name.typeName(); this.nodeKeys = Arrays.asList(key); this.query = new StringBuilder(); + this.fields = new LinkedHashSet<>(); query.append(nodeName); } @@ -58,6 +65,7 @@ public abstract class DSLNodeBase<T extends DSLNodeBase<?>> implements QueryStep this.nodeName = copy.nodeName; this.nodeKeys = copy.nodeKeys; this.query = new StringBuilder(copy.query); + this.fields = copy.fields; this.output = copy.output; } @@ -67,6 +75,12 @@ public abstract class DSLNodeBase<T extends DSLNodeBase<?>> implements QueryStep return new DSLOutputNode(this); } + public DSLOutputNode output(String... fields) { + this.output = true; + this.fields.addAll(Arrays.asList(fields)); + return new DSLOutputNode(this); + } + public T and(DSLNodeKey... key) { this.nodeKeys.addAll(Arrays.asList(key)); @@ -77,7 +91,13 @@ public abstract class DSLNodeBase<T extends DSLNodeBase<?>> implements QueryStep public String build() { StringBuilder result = new StringBuilder(query); if (output) { - result.append("*"); + if (fields.isEmpty()) { + result.append("*"); + } else { + String items = + fields.stream().map(item -> String.format("'%s'", item)).collect(Collectors.joining(", ")); + result.append("{").append(items).append("}"); + } } for (DSLNodeKey key : nodeKeys) { result.append(key.build()); diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLQueryBuilder.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLQueryBuilder.java index 762203258a..c56ce0bfee 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLQueryBuilder.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLQueryBuilder.java @@ -24,6 +24,7 @@ import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.function.Consumer; import java.util.stream.Collectors; import org.onap.aaiclient.client.aai.entities.QueryStep; import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectName; @@ -49,9 +50,20 @@ public class DSLQueryBuilder<S, E> { } public DSLQueryBuilder<S, Node> output() { + callOnLambda(item -> item.output()); + return (DSLQueryBuilder<S, Node>) this; + } + + public DSLQueryBuilder<S, Node> output(String... fields) { + callOnLambda(item -> item.output(fields)); + return (DSLQueryBuilder<S, Node>) this; + } + + protected void callOnLambda(Consumer<DSLNodeBase> consumer) { + Object obj = steps.get(steps.size() - 1); if (obj instanceof DSLNodeBase) { - ((DSLNodeBase) steps.get(steps.size() - 1)).output(); + consumer.accept((DSLNodeBase) steps.get(steps.size() - 1)); } else if (obj.getClass().getName().contains("$$Lambda$")) { // process lambda expressions for (Field f : obj.getClass().getDeclaredFields()) { @@ -60,7 +72,7 @@ public class DSLQueryBuilder<S, E> { try { o = f.get(obj); if (o instanceof DSLQueryBuilder && ((DSLQueryBuilder) o).steps.get(0) instanceof DSLNodeBase) { - ((DSLNodeBase) ((DSLQueryBuilder) o).steps.get(0)).output(); + consumer.accept(((DSLNodeBase) ((DSLQueryBuilder) o).steps.get(0))); } } catch (IllegalArgumentException | IllegalAccessException e) { } @@ -68,7 +80,6 @@ public class DSLQueryBuilder<S, E> { break; } } - return (DSLQueryBuilder<S, Node>) this; } @SafeVarargs diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryRelationships.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryRelationships.java index 48feba25df..881b7e9a8e 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryRelationships.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryRelationships.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; import java.util.function.Predicate; +import java.util.function.UnaryOperator; import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider; import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectName; import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectType; @@ -56,6 +57,11 @@ public abstract class GraphInventoryRelationships<Wrapper extends GraphInventory return this.getAll(Optional.of(type)); } + public List<Wrapper> getByType(GraphInventoryObjectName type, UnaryOperator<Uri> func) { + + return this.getAll(Optional.of(type), func); + } + public List<Wrapper> getAll() { return this.getAll(Optional.empty()); @@ -99,6 +105,10 @@ public abstract class GraphInventoryRelationships<Wrapper extends GraphInventory protected List<Wrapper> getAll(final Optional<GraphInventoryObjectName> type) { + return getAll(type, UnaryOperator.identity()); + } + + protected List<Wrapper> getAll(final Optional<GraphInventoryObjectName> type, UnaryOperator<Uri> func) { List<Uri> relatedLinks; if (type.isPresent()) { relatedLinks = this.getRelatedUris(type.get()); @@ -107,7 +117,7 @@ public abstract class GraphInventoryRelationships<Wrapper extends GraphInventory } ArrayList<Wrapper> result = new ArrayList<>(); for (Uri link : relatedLinks) { - result.add(this.get(link)); + result.add(this.get(func.apply(link))); } return result; } diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIDSLQueryClientTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIDSLQueryClientTest.java new file mode 100644 index 0000000000..36fc1db57c --- /dev/null +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIDSLQueryClientTest.java @@ -0,0 +1,17 @@ +package org.onap.aaiclient.client.aai; + +import static org.junit.Assert.assertEquals; +import java.net.URISyntaxException; +import org.junit.Test; + +public class AAIDSLQueryClientTest { + + + + @Test + public void verifyHeadersTest() throws URISyntaxException { + + AAIDSLQueryClient client = new AAIDSLQueryClient(); + assertEquals("V2", client.getClient().getAdditionalHeaders().get("X-DslApiVersion")); + } +} diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIRestClientTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIRestClientTest.java index 86738beabb..b73454fe67 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIRestClientTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIRestClientTest.java @@ -20,6 +20,13 @@ package org.onap.aaiclient.client.aai; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor; +import static com.github.tomakehurst.wiremock.client.WireMock.matching; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; import static org.hamcrest.CoreMatchers.containsString; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; @@ -30,6 +37,7 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import java.net.URI; import java.net.URISyntaxException; +import java.util.HashMap; import javax.ws.rs.core.Response; import org.junit.Rule; import org.junit.Test; @@ -37,10 +45,12 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; -import org.onap.so.client.RestClientSSL; +import org.onap.aaiclient.client.defaultproperties.DefaultAAIPropertiesImpl; import org.onap.aaiclient.client.graphinventory.GraphInventoryPatchConverter; import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryPatchDepthExceededException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.tomakehurst.wiremock.junit.WireMockRule; +import com.google.common.collect.ImmutableMap; @RunWith(MockitoJUnitRunner.class) public class AAIRestClientTest { @@ -53,9 +63,12 @@ public class AAIRestClientTest { @Rule public ExpectedException thrown = ExpectedException.none(); + @Rule + public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); + @Test public void failPatchOnComplexObject() throws URISyntaxException { - AAIRestClient client = new AAIRestClient(props, new URI("")); + AAIRestClient client = new AAIRestClient(props, new URI(""), new HashMap<String, String>()); this.thrown.expect(GraphInventoryPatchDepthExceededException.class); this.thrown.expectMessage(containsString("Object exceeds allowed depth for update action")); client.patch( @@ -64,7 +77,7 @@ public class AAIRestClientTest { @Test public void verifyPatchValidation() throws URISyntaxException { - AAIRestClient client = new AAIRestClient(props, new URI("")); + AAIRestClient client = new AAIRestClient(props, new URI(""), new HashMap<String, String>()); AAIRestClient spy = spy(client); GraphInventoryPatchConverter patchValidatorMock = mock(GraphInventoryPatchConverter.class); doReturn(patchValidatorMock).when(spy).getPatchConverter(); @@ -73,4 +86,14 @@ public class AAIRestClientTest { spy.patch(payload); verify(patchValidatorMock, times(1)).convertPatchFormat(eq((Object) payload)); } + + @Test + public void verifyAdditionalHeadersTest() throws URISyntaxException { + AAIRestClient client = new AAIRestClient(new DefaultAAIPropertiesImpl(wireMockRule.port()), new URI("/test"), + ImmutableMap.of("test", "value")); + wireMockRule.stubFor(get(urlPathEqualTo("/test")).willReturn(aResponse().withStatus(200))); + client.get(); + wireMockRule.verify(getRequestedFor(urlPathEqualTo("/test")).withHeader("X-FromAppId", equalTo("MSO")) + .withHeader("X-TransactionId", matching(".*")).withHeader("test", equalTo("value"))); + } } diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/DSLQueryBuilderTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/DSLQueryBuilderTest.java index 965770c796..b0b0c6aca9 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/DSLQueryBuilderTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/DSLQueryBuilderTest.java @@ -26,6 +26,7 @@ import org.junit.Test; import org.onap.aaiclient.client.graphinventory.entities.DSLNodeKey; import org.onap.aaiclient.client.graphinventory.entities.DSLQueryBuilder; import org.onap.aaiclient.client.graphinventory.entities.DSLStartNode; +import org.onap.aaiclient.client.graphinventory.entities.Node; import org.onap.aaiclient.client.graphinventory.entities.Output; import org.onap.aaiclient.client.graphinventory.entities.Start; import org.onap.aaiclient.client.graphinventory.entities.TraversalBuilder; @@ -146,4 +147,23 @@ public class DSLQueryBuilderTest { "generic-vnf*('vnf-id', 'vnfId') > " + "[ pserver* > complex*, " + "vserver > pserver* > complex* ]", builder.build().get()); } + + @Test + public void selectOutputFilterTest() { + DSLQueryBuilder<Output, Output> builder = TraversalBuilder + .traversal(new DSLStartNode(AAIObjectType.CLOUD_REGION, __.key("cloud-owner", "CloudOwner")) + .output("cloud-region-id", "a", "b")); + builder.to(__.node(AAIObjectType.PSERVER)).output("x", "y", "z"); + + assertEquals("cloud-region{'cloud-region-id', 'a', 'b'}('cloud-owner', 'CloudOwner') > pserver{'x', 'y', 'z'}", + builder.build().toString()); + } + + @Test + public void selectOutputFilterOnNodeTest() { + DSLStartNode node = new DSLStartNode(AAIObjectType.CLOUD_REGION, __.key("cloud-owner", "CloudOwner")); + DSLQueryBuilder<Start, Node> builder = TraversalBuilder.fragment(node).output("cloud-region-id"); + + assertEquals("cloud-region{'cloud-region-id'}('cloud-owner', 'CloudOwner')", builder.build().toString()); + } } diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/RelationshipsTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/RelationshipsTest.java index 10162f83ee..9e106fab85 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/RelationshipsTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/RelationshipsTest.java @@ -21,12 +21,15 @@ package org.onap.aaiclient.client.aai.entities; import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.doReturn; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.Arrays; import java.util.List; import org.junit.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.Mockito; import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; @@ -53,4 +56,27 @@ public class RelationshipsTest { } + @Test + public void getByTypeTest() throws IOException { + final String content = new String(Files.readAllBytes(Paths.get(AAI_JSON_FILE_LOCATION + "e2e-complex.json"))); + + AAIResultWrapper wrapper = new AAIResultWrapper(content); + Relationships relationships = wrapper.getRelationships().get(); + + Relationships spy = Mockito.spy(relationships); + ArgumentCaptor<AAIResourceUri> argument = ArgumentCaptor.forClass(AAIResourceUri.class); + doReturn(new AAIResultWrapper("{}")).when(spy).get(argument.capture()); + + spy.getByType(AAIObjectType.VCE, uri -> uri.nodesOnly(true)); + + assertTrue(argument.getAllValues().stream().allMatch(item -> item.build().toString().contains("nodes-only"))); + + argument = ArgumentCaptor.forClass(AAIResourceUri.class); + + doReturn(new AAIResultWrapper("{}")).when(spy).get(argument.capture()); + spy.getByType(AAIObjectType.VCE); + + assertTrue(argument.getAllValues().stream().allMatch(item -> !item.build().toString().contains("?"))); + + } } diff --git a/graph-inventory/fluent-builder-maven-plugin/pom.xml b/graph-inventory/fluent-builder-maven-plugin/pom.xml index 7833bce48e..f0884758b8 100644 --- a/graph-inventory/fluent-builder-maven-plugin/pom.xml +++ b/graph-inventory/fluent-builder-maven-plugin/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>graph-inventory</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>fluent-builder-maven-plugin</artifactId> <packaging>maven-plugin</packaging> diff --git a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGenerator.java b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGenerator.java index 23a1a812df..4a8b7d90c6 100644 --- a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGenerator.java +++ b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGenerator.java @@ -325,13 +325,8 @@ public class FluentGenerator { String value; String name; - if (params.group(2) != null) { - name = params.group(2); - } else { - name = params.group(1); - } value = params.group(1); - + name = params.group(2); name = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, name); classFields.add(FieldSpec.builder(String.class, name, Modifier.PUBLIC, Modifier.FINAL) diff --git a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/Patterns.java b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/Patterns.java index 8be22e1dcc..d27794c127 100644 --- a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/Patterns.java +++ b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/Patterns.java @@ -7,5 +7,5 @@ public class Patterns { public static final Pattern pluralPattern = Pattern.compile(".*(?<partial>/(?<name>[^{]*$))"); public static final Pattern singularPattern = Pattern.compile(".*(?<partial>/(?<name>[^/{}]*)/\\{.*$)"); public static final Pattern topLevelPattern = Pattern.compile("^/([^/]+)/.*"); - public static final Pattern urlTemplatePattern = Pattern.compile("\\{([^}.]+(?:\\.([^}]+))?)\\}"); + public static final Pattern urlTemplatePattern = Pattern.compile("\\{((?:.+\\.)?([^}.]+))\\}"); } diff --git a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java index 42305488bc..ec09af8a4e 100644 --- a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java +++ b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java @@ -125,8 +125,6 @@ public class SwaggerConverter { } } - log.debug(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(output)); - for (Map.Entry<String, ObjectType> item : output.entrySet()) { if (item.getValue().getType().equals("plural")) { @@ -156,7 +154,7 @@ public class SwaggerConverter { Matcher templates = Patterns.urlTemplatePattern.matcher(item.getValue().getPartialUri()); List<String> localFields = new ArrayList<>(); while (templates.find()) { - localFields.add(templates.group(1)); + localFields.add(templates.group(2)); } item.getValue().setFields(item.getValue().getFields().stream() .filter(f -> localFields.contains(f.getName())).collect(Collectors.toList())); @@ -166,6 +164,8 @@ public class SwaggerConverter { output.values().stream().filter(item -> item.getType().equals("plural")) .forEach(item -> item.getChildren().clear()); + log.debug(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(output)); + return output; } } diff --git a/graph-inventory/pom.xml b/graph-inventory/pom.xml index 0f465b03b1..f5ccbc0244 100644 --- a/graph-inventory/pom.xml +++ b/graph-inventory/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>so</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>graph-inventory</artifactId> <packaging>pom</packaging> diff --git a/mso-api-handlers/mso-api-handler-common/.gitignore b/mso-api-handlers/mso-api-handler-common/.gitignore new file mode 100644 index 0000000000..da7560e07f --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/.gitignore @@ -0,0 +1 @@ +/.apt_generated_tests/ diff --git a/mso-api-handlers/mso-api-handler-common/pom.xml b/mso-api-handlers/mso-api-handler-common/pom.xml index 865de7998f..4e92775d02 100644 --- a/mso-api-handlers/mso-api-handler-common/pom.xml +++ b/mso-api-handlers/mso-api-handler-common/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>mso-api-handlers</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> @@ -23,7 +23,6 @@ <reflections-version>0.9.9-RC1</reflections-version> <paranamer-version>2.5.2</paranamer-version> <scannotation-version>1.0.3</scannotation-version> - <java.version>1.8</java.version> </properties> <dependencyManagement> <dependencies> diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/ResponseHandler.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/ResponseHandler.java index af1258e963..65e8b438ad 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/ResponseHandler.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/ResponseHandler.java @@ -32,6 +32,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; @@ -43,6 +44,7 @@ public class ResponseHandler { String responseBody = camundaResponse.getBody(); CamundaResponse response = null; ObjectMapper mapper = new ObjectMapper(); + mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); try { response = mapper.readValue(responseBody, CamundaResponse.class); } catch (IOException | NullPointerException e) { diff --git a/mso-api-handlers/mso-api-handler-infra/.gitignore b/mso-api-handlers/mso-api-handler-infra/.gitignore index ae3c172604..9920c72893 100644 --- a/mso-api-handlers/mso-api-handler-infra/.gitignore +++ b/mso-api-handlers/mso-api-handler-infra/.gitignore @@ -1 +1,2 @@ /bin/ +/.apt_generated_tests/ diff --git a/mso-api-handlers/mso-api-handler-infra/pom.xml b/mso-api-handlers/mso-api-handler-infra/pom.xml index 7d6bbc4fc4..542b8db932 100644 --- a/mso-api-handlers/mso-api-handler-infra/pom.xml +++ b/mso-api-handlers/mso-api-handler-infra/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>mso-api-handlers</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> @@ -25,7 +25,6 @@ <reflections-version>0.9.9-RC1</reflections-version> <paranamer-version>2.5.2</paranamer-version> <scannotation-version>1.0.3</scannotation-version> - <java.version>1.8</java.version> </properties> <dependencyManagement> <dependencies> @@ -53,10 +52,14 @@ <artifactId>camunda-engine</artifactId> </dependency> <dependency> + <groupId>org.javassist</groupId> + <artifactId>javassist</artifactId> + <version>3.25.0-GA</version> + </dependency> + <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> - <dependency> <groupId>io.swagger.core.v3</groupId> <artifactId>swagger-annotations</artifactId> @@ -127,6 +130,10 @@ <version>${json4s-core-version}</version> </dependency> <dependency> + <groupId>javax.xml.ws</groupId> + <artifactId>jaxws-api</artifactId> + </dependency> + <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> </dependency> @@ -151,7 +158,6 @@ <artifactId>mso-catalog-db</artifactId> <version>${project.version}</version> </dependency> - <!-- Test Dependencies --> <dependency> <groupId>pl.pragmatists</groupId> @@ -232,19 +238,38 @@ <dependency> <groupId>org.onap.aaf.authz</groupId> <artifactId>aaf-cadi-aaf</artifactId> - <version>2.1.9</version> + <version>${aaf.cadi.version}</version> <exclusions> <exclusion> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> </exclusion> + <exclusion> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + </exclusion> </exclusions> </dependency> + <dependency> + <groupId>javax.xml.bind</groupId> + <artifactId>jaxb-api</artifactId> + <version>2.3.0</version> + </dependency> + <dependency> + <groupId>com.sun.xml.bind</groupId> + <artifactId>jaxb-core</artifactId> + <version>2.3.0</version> + </dependency> + <dependency> + <groupId>com.sun.xml.bind</groupId> + <artifactId>jaxb-impl</artifactId> + <version>2.3.0</version> + </dependency> </dependencies> <build> <finalName>${project.artifactId}-${project.version}</finalName> - <pluginManagement> + <pluginManagement> <plugins> <plugin> <groupId>org.eclipse.m2e</groupId> @@ -311,6 +336,9 @@ <executions> <execution> <id>extract-docker-file</id> + <configuration> + <skip>false</skip> + </configuration> </execution> </executions> </plugin> @@ -320,9 +348,7 @@ <executions> <execution> <id>original</id> - <configuration> - <skip>false</skip> - </configuration> + <phase>package</phase> </execution> </executions> </plugin> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java index f39a95e92c..b59f298022 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java @@ -9,6 +9,8 @@ * ================================================================================ * Modifications Copyright (c) 2020 Nokia * ================================================================================ + * Modifications Copyright (c) 2020 Nordix + * ================================================================================ * 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 @@ -25,7 +27,28 @@ package org.onap.so.apihandlerinfra; +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import javax.transaction.Transactional; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.apache.http.HttpStatus; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandler.common.RequestClientParameter; import org.onap.so.apihandlerinfra.exceptions.ApiException; @@ -39,35 +62,13 @@ import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; -import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.serviceinstancebeans.ModelType; -import org.onap.so.serviceinstancebeans.RequestReferences; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; -import org.onap.so.serviceinstancebeans.ServiceInstancesResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import javax.transaction.Transactional; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.container.ContainerRequestContext; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.io.IOException; -import java.util.HashMap; -import io.swagger.v3.oas.annotations.OpenAPIDefinition; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.info.Info; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; @Component @Path("/onap/so/infra/instanceManagement") @@ -75,8 +76,8 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; description = "Infrastructure API Requests for Instance Management")) public class InstanceManagement { - private static Logger logger = LoggerFactory.getLogger(InstanceManagement.class); - private static String uriPrefix = "/instanceManagement/"; + private static final Logger LOG = LoggerFactory.getLogger(InstanceManagement.class); + private static final String URI_PREFIX = "/instanceManagement/"; private static final String SAVE_TO_DB = "save instance to db"; @Autowired @@ -102,13 +103,13 @@ public class InstanceManagement { @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, @PathParam("workflowUuid") String workflowUuid, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); + final String requestId = requestHandlerUtils.getRequestId(requestContext); + final Map<String, String> instanceIdMap = new HashMap<>(); instanceIdMap.put("serviceInstanceId", serviceInstanceId); instanceIdMap.put("vnfInstanceId", vnfInstanceId); instanceIdMap.put("workflowUuid", workflowUuid); return processCustomWorkflowRequest(request, Action.inPlaceSoftwareUpdate, instanceIdMap, version, requestId, - requestContext); + requestContext, true); } @POST @@ -122,34 +123,61 @@ public class InstanceManagement { @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("pnfName") String pnfName, @PathParam("workflowUuid") String workflowUuid, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); + final String requestId = requestHandlerUtils.getRequestId(requestContext); + final Map<String, String> instanceIdMap = new HashMap<>(); instanceIdMap.put("serviceInstanceId", serviceInstanceId); instanceIdMap.put("pnfName", pnfName); instanceIdMap.put("workflowUuid", workflowUuid); - return processPNFCustomWorkflowRequest(request, Action.forCustomWorkflow, instanceIdMap, version, requestId, - requestContext); + return processCustomWorkflowRequest(request, Action.forCustomWorkflow, instanceIdMap, version, requestId, + requestContext, false); + } + + @POST + @Path("/{version:[vV][1]}/serviceInstances/{serviceInstanceId}/workflows/{workflowUuid}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Operation(description = "Execute custom Service Level workflow", responses = @ApiResponse( + content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) + @Transactional + public Response executeServiceLevelCustomWorkflow(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("workflowUuid") String workflowUuid, + @Context ContainerRequestContext requestContext) throws ApiException { + final String requestId = requestHandlerUtils.getRequestId(requestContext); + final Map<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("workflowUuid", workflowUuid); + return processCustomWorkflowRequest(request, Action.forCustomWorkflow, instanceIdMap, version, requestId, + requestContext, false); } - private Response processCustomWorkflowRequest(String requestJSON, Actions action, - HashMap<String, String> instanceIdMap, String version, String requestId, - ContainerRequestContext requestContext) throws ApiException { - String serviceInstanceId; - boolean aLaCarte = true; - ServiceInstancesRequest sir; - String apiVersion = version.substring(1); + private Response processCustomWorkflowRequest(final String requestJSON, final Actions action, + final Map<String, String> instanceIdMap, final String version, final String requestId, + final ContainerRequestContext requestContext, final boolean aLaCarte) throws ApiException { + String pnfName = null; + String vnfType = null; + String workflowUuid = null; + String vnfInstanceId = null; + String svcInstanceId = null; + final String apiVersion = version.substring(1); - String requestUri = requestHandlerUtils.getRequestUri(requestContext, uriPrefix); + if (instanceIdMap != null && !instanceIdMap.isEmpty()) { + pnfName = instanceIdMap.get("pnfName"); + workflowUuid = instanceIdMap.get("workflowUuid"); + vnfInstanceId = instanceIdMap.get("vnfInstanceId"); + svcInstanceId = instanceIdMap.get("serviceInstanceId"); + } - sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, requestId, requestUri); - String requestScope = requestHandlerUtils.deriveRequestScope(action, sir, requestUri); - InfraActiveRequests currentActiveReq = - msoRequest.createRequestObject(sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope); + final String requestUri = requestHandlerUtils.getRequestUri(requestContext, URI_PREFIX); + final ServiceInstancesRequest svcInsReq = + requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, requestId, requestUri); + final String requestScope = requestHandlerUtils.deriveRequestScope(action, svcInsReq, requestUri); + InfraActiveRequests currentActiveReq = msoRequest.createRequestObject(svcInsReq, action, requestId, + Status.IN_PROGRESS, requestJSON, requestScope); try { requestHandlerUtils.validateHeaders(requestContext); } catch (ValidationException e) { - logger.error("Exception occurred", e); + LOG.error("Exception occurred", e); ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_VALIDATION_ERROR, ErrorCode.SchemaError) .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); @@ -160,42 +188,18 @@ public class InstanceManagement { throw validateException; } - requestHandlerUtils.parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, + requestHandlerUtils.parseRequest(svcInsReq, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, currentActiveReq); requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap); - String vnfType = msoRequest.getVnfType(sir, requestScope); - - if (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && vnfType != null) { + if (requestScope.equalsIgnoreCase(ModelType.vnf.name())) { + vnfType = msoRequest.getVnfType(svcInsReq, requestScope); currentActiveReq.setVnfType(vnfType); } checkDuplicateAndBuildError(action, instanceIdMap, requestScope, currentActiveReq); - - ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse(); - - RequestReferences referencesResponse = new RequestReferences(); - - referencesResponse.setRequestId(requestId); - - serviceResponse.setRequestReferences(referencesResponse); - boolean isBaseVfModule = false; - - String workflowUuid = null; - if (instanceIdMap != null) { - workflowUuid = instanceIdMap.get("workflowUuid"); - } - - RecipeLookupResult recipeLookupResult = getInstanceManagementWorkflowRecipe(currentActiveReq, workflowUuid); - - String serviceInstanceType = requestHandlerUtils.getServiceType(requestScope, sir, true); - - serviceInstanceId = requestHandlerUtils.setServiceInstanceId(requestScope, sir); - String vnfId = ""; - - if (sir.getVnfInstanceId() != null) { - vnfId = sir.getVnfInstanceId(); - } + final RecipeLookupResult recipeLookupResult = + getInstanceManagementWorkflowRecipe(currentActiveReq, workflowUuid); currentActiveReq = setWorkflowNameAndOperationName(currentActiveReq, workflowUuid); saveCurrentActiveRequest(currentActiveReq); @@ -203,11 +207,11 @@ public class InstanceManagement { RequestClientParameter requestClientParameter; try { requestClientParameter = new RequestClientParameter.Builder().setRequestId(requestId) - .setBaseVfModule(isBaseVfModule).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()) - .setRequestAction(action.toString()).setServiceInstanceId(serviceInstanceId).setVnfId(vnfId) - .setServiceType(serviceInstanceType).setVnfType(vnfType) + .setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.toString()) + .setServiceInstanceId(svcInstanceId).setVnfId(vnfInstanceId).setVnfType(vnfType) + .setPnfCorrelationId(pnfName).setApiVersion(apiVersion) .setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(requestJSON, null, aLaCarte, action)) - .setApiVersion(apiVersion).setALaCarte(aLaCarte).setRequestUri(requestUri).build(); + .setALaCarte(aLaCarte).setRequestUri(requestUri).build(); } catch (IOException e) { ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError) @@ -232,7 +236,7 @@ public class InstanceManagement { } } - private void checkDuplicateAndBuildError(Actions action, HashMap<String, String> instanceIdMap, String requestScope, + private void checkDuplicateAndBuildError(Actions action, Map<String, String> instanceIdMap, String requestScope, InfraActiveRequests currentActiveReq) throws ApiException { InfraActiveRequests dup = @@ -248,74 +252,6 @@ public class InstanceManagement { } } - private Response processPNFCustomWorkflowRequest(String requestJSON, Actions action, - HashMap<String, String> instanceIdMap, String version, String requestId, - ContainerRequestContext requestContext) throws ApiException { - boolean aLaCarte = false; - ServiceInstancesRequest sir; - String apiVersion = version.substring(1); - - String serviceInstanceId = ""; - String pnfName = ""; - String workflowUuid = ""; - if (instanceIdMap != null) { - serviceInstanceId = instanceIdMap.get("serviceInstanceId"); - pnfName = instanceIdMap.get("pnfName"); - workflowUuid = instanceIdMap.get("workflowUuid"); - } - - String requestUri = requestHandlerUtils.getRequestUri(requestContext, uriPrefix); - sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, requestId, requestUri); - sir.setServiceInstanceId(serviceInstanceId); - sir.setPnfName(pnfName); - String requestScope = ModelType.pnf.name(); - InfraActiveRequests currentActiveReq = - msoRequest.createRequestObject(sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope); - - try { - requestHandlerUtils.validateHeaders(requestContext); - } catch (ValidationException e) { - logger.error("Exception occurred", e); - ErrorLoggerInfo errorLoggerInfo = - new ErrorLoggerInfo.Builder(MessageEnum.APIH_VALIDATION_ERROR, ErrorCode.SchemaError) - .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - ValidateException validateException = - new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, - ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); - requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage()); - throw validateException; - } - - requestHandlerUtils.parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, - currentActiveReq); - requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap); - - checkDuplicateAndBuildError(action, instanceIdMap, requestScope, currentActiveReq); - - RecipeLookupResult recipeLookupResult = getInstanceManagementWorkflowRecipe(currentActiveReq, workflowUuid); - - currentActiveReq = setWorkflowNameAndOperationName(currentActiveReq, workflowUuid); - saveCurrentActiveRequest(currentActiveReq); - - RequestClientParameter requestClientParameter; - try { - requestClientParameter = new RequestClientParameter.Builder().setRequestId(requestId) - .setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.toString()) - .setServiceInstanceId(serviceInstanceId).setPnfCorrelationId(pnfName) - .setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(requestJSON, null, aLaCarte, action)) - .setApiVersion(apiVersion).setRequestUri(requestUri).build(); - } catch (IOException e) { - ErrorLoggerInfo errorLoggerInfo = - new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError) - .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), - HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo) - .build(); - } - return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, - recipeLookupResult.getOrchestrationURI(), requestScope); - } - private RecipeLookupResult getInstanceManagementWorkflowRecipe(InfraActiveRequests currentActiveReq, String workflowUuid) throws ApiException { RecipeLookupResult recipeLookupResult; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java index f3c3ec5ff1..4ac8b73698 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java @@ -154,9 +154,8 @@ public class MsoRequest { // Parse request JSON - public void parse(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMap, Actions action, - String version, String originalRequestJSON, int reqVersion, Boolean aLaCarteFlag) - throws ValidationException, IOException { + public void parse(ServiceInstancesRequest sir, Map<String, String> instanceIdMap, Actions action, String version, + String originalRequestJSON, int reqVersion, Boolean aLaCarteFlag) throws ValidationException, IOException { logger.debug("Validating the Service Instance request"); List<ValidationRule> rules = new ArrayList<>(); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java index a61975f529..a68309f199 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java @@ -261,8 +261,8 @@ public class RequestHandlerUtils extends AbstractRestHandler { } } - public InfraActiveRequests duplicateCheck(Actions action, HashMap<String, String> instanceIdMap, - String instanceName, String requestScope, InfraActiveRequests currentActiveReq) throws ApiException { + public InfraActiveRequests duplicateCheck(Actions action, Map<String, String> instanceIdMap, String instanceName, + String requestScope, InfraActiveRequests currentActiveReq) throws ApiException { InfraActiveRequests dup = null; try { if (!(instanceName == null && "service".equals(requestScope) && (action == Action.createInstance @@ -332,7 +332,7 @@ public class RequestHandlerUtils extends AbstractRestHandler { } } - public void parseRequest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMap, Actions action, + public void parseRequest(ServiceInstancesRequest sir, Map<String, String> instanceIdMap, Actions action, String version, String requestJSON, Boolean aLaCarte, String requestId, InfraActiveRequests currentActiveReq) throws ValidateException, RequestDbFailureException { int reqVersion = Integer.parseInt(version.substring(1)); @@ -354,7 +354,7 @@ public class RequestHandlerUtils extends AbstractRestHandler { } public void buildErrorOnDuplicateRecord(InfraActiveRequests currentActiveReq, Actions action, - HashMap<String, String> instanceIdMap, String instanceName, String requestScope, InfraActiveRequests dup) + Map<String, String> instanceIdMap, String instanceName, String requestScope, InfraActiveRequests dup) throws ApiException { String instance = null; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java index 357497591d..0f7cf5fc6a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java @@ -81,12 +81,13 @@ public class WorkflowSpecificationsHandler { @Transactional public Response queryWorkflowSpecifications(@QueryParam("vnfModelVersionId") String vnfModelVersionId, - @QueryParam("pnfModelVersionId") String pnfModelVersionId, @PathParam("version") String version) + @QueryParam("pnfModelVersionId") String pnfModelVersionId, + @QueryParam("resourceTarget") String resourceTarget, @PathParam("version") String version) throws Exception { String apiVersion = version.substring(1); List<Workflow> workflows = new ArrayList<>(); - if (vnfModelVersionId == null && pnfModelVersionId == null) { + if (vnfModelVersionId == null && pnfModelVersionId == null && resourceTarget == null) { workflows.addAll(queryWorkflowSpecificationsForAll()); } else { // 1. query workflow specifications for given vnfModelVersionId if need. @@ -106,6 +107,16 @@ public class WorkflowSpecificationsHandler { workflows.addAll(pnfWorkflows); } } + + // 3. query workflow specifications for given resourceTarget + if (resourceTarget != null) { + List<Workflow> workflowsForResourceTarget = queryWorkflowsForResourceTarget(resourceTarget); + logger.debug( + "Retrieved " + workflowsForResourceTarget.size() + " workflows for given resource target."); + if (workflowsForResourceTarget.size() > 0) { + workflows.addAll(workflowsForResourceTarget); + } + } } // Deduplication @@ -119,11 +130,16 @@ public class WorkflowSpecificationsHandler { apiVersion); } + /** + * @deprecated As of G release, workflows for all resource types (pnf,vnf,service) can be fetched using + * /workflowSpecifications/{version:[vV]1}/workflows?resourceTarget={resourceType} API + */ @Path("/{version:[vV]1}/pnfWorkflows") @GET @Operation(description = "Finds pnf workflow specifications", responses = @ApiResponse( content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) @Transactional + @Deprecated public Response getWorkflowsSpecForPnf(@PathParam("version") String version) throws Exception { final String pnf_resource = "pnf"; @@ -132,7 +148,7 @@ public class WorkflowSpecificationsHandler { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - List<Workflow> workflows = catalogDbClient.findWorkflowByResourceTarget(pnf_resource); + List<Workflow> workflows = queryWorkflowsForResourceTarget(pnf_resource); Optional<String> optional = getResponseByWorkflowSpec(workflows); return builder.buildResponse(HttpStatus.SC_OK, "", optional.isPresent() ? optional.get() : EMPTY_BODY, @@ -296,4 +312,11 @@ public class WorkflowSpecificationsHandler { List<Workflow> workflows = catalogDbClient.findWorkflowByPnfModelUUID(pnfModelVersionId); return workflows; } + + private List<Workflow> queryWorkflowsForResourceTarget(String resourceTarget) { + List<Workflow> workflows = catalogDbClient.findWorkflowByResourceTarget(resourceTarget); + return workflows; + } + + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java index fc0048bacf..70de94a3ef 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java @@ -148,7 +148,7 @@ public class AAIDataRetrieval { } public List<LInterface> getLinterfacesOfVnf(String vnfId) { - DSLStartNode startNode = new DSLStartNode(AAIObjectType.GENERIC_VNF, __.key("generic-vnf-id", vnfId)); + DSLStartNode startNode = new DSLStartNode(AAIObjectType.GENERIC_VNF, __.key("vnf-id", vnfId)); DSLQueryBuilder<Start, Node> builder = TraversalBuilder.fragment(startNode) .to(__.node(AAIObjectType.VSERVER).to(__.node(AAIObjectType.L_INTERFACE).output())); List<LInterface> linterfaces = diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java index e8046a2cd9..6e7947bb58 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java @@ -38,6 +38,7 @@ import org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFou import org.onap.so.constants.Status; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; +import org.onap.so.logger.HttpHeadersConstants; import org.onap.so.serviceinstancebeans.CloudConfiguration; import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.ModelType; @@ -436,7 +437,7 @@ public class BpmnRequestBuilder { RequestInfo requestInfo = new RequestInfo(); requestInfo.setSuppressRollback(false); requestInfo.setSource(MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME)); - requestInfo.setRequestorId(MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME)); + requestInfo.setRequestorId(MDC.get(HttpHeadersConstants.REQUESTOR_ID)); return requestInfo; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Network.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Network.java index 3104c8415f..81ad3106b0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Network.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Network.java @@ -32,7 +32,6 @@ import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import com.fasterxml.jackson.core.JsonProcessingException; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.apihandler.filters.ResponseUpdater; import org.onap.so.apihandlerinfra.Action; @@ -43,12 +42,14 @@ import org.onap.so.apihandlerinfra.infra.rest.exception.WorkflowEngineConnection import org.onap.so.apihandlerinfra.infra.rest.handler.NetworkRestHandler; import org.onap.so.db.catalog.beans.Recipe; import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.logger.HttpHeadersConstants; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.onap.so.serviceinstancebeans.ServiceInstancesResponse; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; +import com.fasterxml.jackson.core.JsonProcessingException; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; @@ -80,7 +81,7 @@ public class Network { ValidateException { String requestId = networkRestHandler.getRequestId(requestContext); - String requestorId = "Unknown"; + String requestorId = MDC.get(HttpHeadersConstants.REQUESTOR_ID); String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME); String requestURI = requestContext.getUriInfo().getAbsolutePath().toString(); InfraActiveRequests currentRequest = networkRestHandler.createInfraActiveRequestForDelete(requestId, diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/ServiceInstance.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/ServiceInstance.java index 7aaf470e18..515862e249 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/ServiceInstance.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/ServiceInstance.java @@ -32,7 +32,6 @@ import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import com.fasterxml.jackson.core.JsonProcessingException; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.apihandler.filters.ResponseUpdater; import org.onap.so.apihandlerinfra.Action; @@ -43,12 +42,14 @@ import org.onap.so.apihandlerinfra.infra.rest.exception.WorkflowEngineConnection import org.onap.so.apihandlerinfra.infra.rest.handler.ServiceInstanceRestHandler; import org.onap.so.db.catalog.beans.Recipe; import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.logger.HttpHeadersConstants; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.onap.so.serviceinstancebeans.ServiceInstancesResponse; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; +import com.fasterxml.jackson.core.JsonProcessingException; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; @@ -79,7 +80,7 @@ public class ServiceInstance { ValidateException { String requestId = requestHandler.getRequestId(requestContext); - String requestorId = "Unknown"; + String requestorId = MDC.get(HttpHeadersConstants.REQUESTOR_ID); String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME); String requestURI = requestContext.getUriInfo().getAbsolutePath().toString(); InfraActiveRequests currentRequest = requestHandler.createInfraActiveRequestForDelete(requestId, diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/VfModules.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/VfModules.java index ddbced98a4..81879c4281 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/VfModules.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/VfModules.java @@ -32,7 +32,6 @@ import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import com.fasterxml.jackson.core.JsonProcessingException; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.apihandler.filters.ResponseUpdater; import org.onap.so.apihandlerinfra.Action; @@ -43,6 +42,7 @@ import org.onap.so.apihandlerinfra.infra.rest.exception.WorkflowEngineConnection import org.onap.so.apihandlerinfra.infra.rest.handler.VFModuleRestHandler; import org.onap.so.db.catalog.beans.Recipe; import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.logger.HttpHeadersConstants; import org.onap.so.serviceinstancebeans.ModelType; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.onap.so.serviceinstancebeans.ServiceInstancesResponse; @@ -50,6 +50,7 @@ import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; +import com.fasterxml.jackson.core.JsonProcessingException; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; @@ -81,7 +82,7 @@ public class VfModules { ValidateException { String requestId = restHandler.getRequestId(requestContext); - String requestorId = "Unknown"; + String requestorId = MDC.get(HttpHeadersConstants.REQUESTOR_ID); String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME); String requestURL = requestContext.getUriInfo().getAbsolutePath().toString(); InfraActiveRequests currentRequest = restHandler.createInfraActiveRequestForDelete(requestId, diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Vnf.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Vnf.java index 68e6eb5858..f1331a3185 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Vnf.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Vnf.java @@ -32,7 +32,6 @@ import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import com.fasterxml.jackson.core.JsonProcessingException; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.apihandler.filters.ResponseUpdater; import org.onap.so.apihandlerinfra.exceptions.ValidateException; @@ -41,12 +40,14 @@ import org.onap.so.apihandlerinfra.infra.rest.exception.WorkflowEngineConnection import org.onap.so.apihandlerinfra.infra.rest.handler.VnfRestHandler; import org.onap.so.db.catalog.beans.Recipe; import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.logger.HttpHeadersConstants; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.onap.so.serviceinstancebeans.ServiceInstancesResponse; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; +import com.fasterxml.jackson.core.JsonProcessingException; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; @@ -77,7 +78,7 @@ public class Vnf { throws AAIEntityNotFound, JsonProcessingException, WorkflowEngineConnectionException, ValidateException { String requestId = vnfRestHandler.getRequestId(requestContext); - String requestorId = "Unknown"; + String requestorId = MDC.get(HttpHeadersConstants.REQUESTOR_ID); String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME); String requestURL = requestContext.getUriInfo().getAbsolutePath().toString(); InfraActiveRequests currentRequest = vnfRestHandler.createInfraActiveRequestForDelete(requestId, diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Volumes.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Volumes.java index b842580b3f..001a8069d9 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Volumes.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Volumes.java @@ -32,7 +32,6 @@ import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import com.fasterxml.jackson.core.JsonProcessingException; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.apihandler.filters.ResponseUpdater; import org.onap.so.apihandlerinfra.Action; @@ -44,6 +43,7 @@ import org.onap.so.apihandlerinfra.infra.rest.handler.VFModuleRestHandler; import org.onap.so.apihandlerinfra.infra.rest.handler.VolumeRestHandler; import org.onap.so.db.catalog.beans.Recipe; import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.logger.HttpHeadersConstants; import org.onap.so.serviceinstancebeans.ModelType; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.onap.so.serviceinstancebeans.ServiceInstancesResponse; @@ -51,6 +51,7 @@ import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; +import com.fasterxml.jackson.core.JsonProcessingException; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; @@ -85,7 +86,7 @@ public class Volumes { ValidateException { String requestId = volumeRestHandler.getRequestId(requestContext); - String requestorId = "Unknown"; + String requestorId = MDC.get(HttpHeadersConstants.REQUESTOR_ID); String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME); String requestURL = requestContext.getUriInfo().getAbsolutePath().toString(); InfraActiveRequests currentRequest = volumeRestHandler.createInfraActiveRequestForDelete(requestId, diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java index c806e9fc1b..fec512ac44 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java @@ -163,12 +163,14 @@ public abstract class AbstractRestHandler { try { URL aUrl = new URL(url); String aPath = aUrl.getPath(); - if (aPath.indexOf("/v") == -1) { - version = aPath.substring(aPath.indexOf("/V"), aPath.indexOf("/V") + 4); - } else { - version = aPath.substring(aPath.indexOf("/v"), aPath.indexOf("/v") + 4); - } - String selfLinkPath = Constants.ORCHESTRATION_REQUESTS_PATH.concat(version).concat(requestId); + int indexOfVersion = Math.max(aPath.indexOf("/V"), aPath.indexOf("/v")); + version = aPath.substring(indexOfVersion, indexOfVersion + 4); + + String pathWithSOAction = aPath.substring(0, indexOfVersion); + String pathWithoutSOAction = pathWithSOAction.substring(0, pathWithSOAction.lastIndexOf("/")); + + String selfLinkPath = + pathWithoutSOAction.concat(Constants.ORCHESTRATION_REQUESTS_PATH).concat(version).concat(requestId); selfLinkUrl = Optional.of(new URL(aUrl.getProtocol(), aUrl.getHost(), aUrl.getPort(), selfLinkPath)); } catch (Exception e) { selfLinkUrl = Optional.empty(); // ignore diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java index 89c5cbed9b..c875764b7b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java @@ -25,7 +25,7 @@ public class NetworkDeleteValidator implements RequestValidator { @Override public Optional<String> validate(Map<String, String> instanceIdMap, ServiceInstancesRequest request, - Map<String, String> queryParams) { + Map<String, String> queryParams, Actions action) { if (aaiDataRetrieval.isNetworkRelatedToModules(instanceIdMap.get("networkInstanceId"))) { return Optional.of("Cannot delete network it is still related to existing vf-modules"); } else { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java index 50938e6826..dc6d01ea8a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java @@ -39,5 +39,5 @@ public interface RequestValidator { public Optional<String> validate(Map<String, String> instanceIdMap, ServiceInstancesRequest request, - Map<String, String> queryParams); + Map<String, String> queryParams, Actions action); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidatorListenerRunner.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidatorListenerRunner.java index 3aba39b501..7ab761aeef 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidatorListenerRunner.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidatorListenerRunner.java @@ -73,8 +73,8 @@ public class RequestValidatorListenerRunner extends ListenerRunner { filterListeners(validators, (item -> item.shouldRunFor(requestURI, request, action))); List<Pair<String, Optional<String>>> results = new ArrayList<>(); - filtered.forEach(item -> results - .add(new Pair<>(item.getClass().getName(), item.validate(instanceIdMap, request, queryParams)))); + filtered.forEach(item -> results.add( + new Pair<>(item.getClass().getName(), item.validate(instanceIdMap, request, queryParams, action)))); return results.stream().filter(item -> item.getValue1().isPresent()).collect(Collectors.toList()); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java index 843d94ce6c..74dbf579c0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java @@ -34,7 +34,7 @@ public class ServiceInstanceDeleteValidator implements RequestValidator { @Override public Optional<String> validate(Map<String, String> instanceIdMap, ServiceInstancesRequest request, - Map<String, String> queryParams) { + Map<String, String> queryParams, Actions action) { if (aaiDataRetrieval.isServiceRelatedToGenericVnf(instanceIdMap.get("serviceInstanceId"))) { return Optional.of("Cannot delete service it is still related to existing vf-modules"); } else if (aaiDataRetrieval.isServiceRelatedToNetworks(instanceIdMap.get("serviceInstanceId"))) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java index a48fca8d0f..44bab7e087 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java @@ -24,7 +24,7 @@ public class VnfDeleteValidator implements RequestValidator { @Override public Optional<String> validate(Map<String, String> instanceIdMap, ServiceInstancesRequest request, - Map<String, String> queryParams) { + Map<String, String> queryParams, Actions action) { final Optional<String> volumeGroupIds = aaiDataRetrieval.getVolumeGroupIdsByVnfId(instanceIdMap.get("vnfInstanceId")); final Optional<String> vfModuleIds = aaiDataRetrieval.getVfModuleIdsByVnfId(instanceIdMap.get("vnfInstanceId")); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java index e3598af31d..550db19af4 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java @@ -24,7 +24,7 @@ public class VolumeGroupDeleteValidator implements RequestValidator { @Override public Optional<String> validate(Map<String, String> instanceIdMap, ServiceInstancesRequest request, - Map<String, String> queryParams) { + Map<String, String> queryParams, Actions action) { if (aaiDataRetrieval.isVolumeGroupRelatedToVFModule(instanceIdMap.get("volumeGroupInstanceId"))) { return Optional.of("Cannot delete volume group it is related to existing vf-modules"); } else { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java index 2cf01f9390..55a68ff7df 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java @@ -21,7 +21,7 @@ package org.onap.so.apihandlerinfra.validation; -import java.util.HashMap; +import java.util.Map; import org.onap.so.apihandler.common.CommonConstants; import org.onap.so.exceptions.ValidationException; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; @@ -31,6 +31,7 @@ public class InstanceIdMapValidation implements ValidationRule { private static final String Service_InstanceId = "serviceInstanceId"; private static final String Vnf_InstanceId = "vnfInstanceId"; + private static final String PNF_NAME = "pnfName"; private static final String vfModule_InstanceId = "vfModuleInstanceId"; private static final String volume_Group_InstanceId = "volumeGroupInstanceId"; @@ -39,7 +40,7 @@ public class InstanceIdMapValidation implements ValidationRule { @Override public ValidationInformation validate(ValidationInformation info) throws ValidationException { - HashMap<String, String> instanceIdMap = info.getInstanceIdMap(); + Map<String, String> instanceIdMap = info.getInstanceIdMap(); ServiceInstancesRequest sir = info.getSir(); if (instanceIdMap != null) { if (instanceIdMap.get(Service_InstanceId) != null) { @@ -90,6 +91,10 @@ public class InstanceIdMapValidation implements ValidationRule { } sir.setInstanceGroupId(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID)); } + + if (instanceIdMap.get(PNF_NAME) != null) { + sir.setPnfName(instanceIdMap.get(PNF_NAME)); + } } return info; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationInformation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationInformation.java index 68b2a78a85..ee4fde02eb 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationInformation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationInformation.java @@ -21,7 +21,7 @@ package org.onap.so.apihandlerinfra.validation; -import java.util.HashMap; +import java.util.Map; import org.onap.so.apihandlerinfra.Actions; import org.onap.so.serviceinstancebeans.LineOfBusiness; import org.onap.so.serviceinstancebeans.OwningEntity; @@ -34,7 +34,7 @@ import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; public class ValidationInformation { ServiceInstancesRequest sir; - HashMap<String, String> instanceIdMap; + Map<String, String> instanceIdMap; Actions action; int reqVersion; String requestScope; @@ -53,7 +53,7 @@ public class ValidationInformation { OwningEntity owningEntity; Service userParams; - public ValidationInformation(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMap, Actions action, + public ValidationInformation(ServiceInstancesRequest sir, Map<String, String> instanceIdMap, Actions action, int reqVersion, Boolean aLaCarteFlag, RequestParameters requestParameters) { this.sir = sir; this.instanceIdMap = instanceIdMap; @@ -71,11 +71,11 @@ public class ValidationInformation { this.sir = value; } - public HashMap<String, String> getInstanceIdMap() { + public Map<String, String> getInstanceIdMap() { return this.instanceIdMap; } - public void setInstanceIdMap(HashMap<String, String> value) { + public void setInstanceIdMap(Map<String, String> value) { this.instanceIdMap = value; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java index 5da16f4326..0ca98883c9 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java @@ -70,6 +70,10 @@ public abstract class BaseTest { return "http://localhost:" + port + uri; } + protected String createURLWithPort(String uri, String orchestrationPath) { + return "http://localhost:" + port + orchestrationPath + uri; + } + protected String createURLWithPort(String uri, int iPort) { return "http://localhost:" + iPort + uri; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java index 081f235db1..7b2e502892 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java @@ -29,10 +29,12 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; -import static org.onap.logging.filter.base.Constants.HttpHeaders.ONAP_REQUEST_ID; -import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID; import static org.onap.logging.filter.base.Constants.HttpHeaders.ONAP_PARTNER_NAME; +import static org.onap.logging.filter.base.Constants.HttpHeaders.ONAP_REQUEST_ID; import static org.onap.logging.filter.base.Constants.HttpHeaders.TRANSACTION_ID; +import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; @@ -46,7 +48,6 @@ import org.junit.Before; import org.junit.Test; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.db.request.beans.InfraActiveRequests; -import org.onap.so.logger.HttpHeadersConstants; import org.onap.so.serviceinstancebeans.RequestReferences; import org.onap.so.serviceinstancebeans.ServiceInstancesResponse; import org.springframework.beans.factory.annotation.Autowired; @@ -57,8 +58,6 @@ import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.util.ResourceUtils; import org.springframework.web.util.UriComponentsBuilder; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; public class InstanceManagementTest extends BaseTest { @@ -72,6 +71,7 @@ public class InstanceManagementTest extends BaseTest { private String wiremockPort; private final String instanceManagementUri = "/onap/so/infra/instanceManagement/"; + private final String orchestration_path = "/onap/so/infra"; private String uri; private URL selfLink; @@ -93,7 +93,7 @@ public class InstanceManagementTest extends BaseTest { headers.set(ONAP_PARTNER_NAME, "VID"); headers.set(REQUESTOR_ID, "xxxxxx"); try { // generate one-time port number to avoid RANDOM port number later. - initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH)); + initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH, orchestration_path)); initialPort = initialUrl.getPort(); } catch (MalformedURLException e) { e.printStackTrace(); @@ -208,6 +208,35 @@ public class InstanceManagementTest extends BaseTest { } @Test + public void executeServiceLevelCustomWorkflow() throws IOException { + wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/testingServiceLevelWorkflow")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + wireMockServer.stubFor(get(urlMatching( + ".*/workflow/search/findByArtifactUUID[?]artifactUUID=81526781-e55c-4cb7-adb3-97e09d9c76bf")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("workflow_ServiceLevel_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + // expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + requestReferences.setRequestSelfLink(createExpectedSelfLink("v1", "32807a28-1a14-4b88-b7b3-2950918aa76d")); + expectedResponse.setRequestReferences(requestReferences); + uri = instanceManagementUri + "v1" + + "/serviceInstances/5df8b6de-2083-11e7-93ae-92361f002676/workflows/81526781-e55c-4cb7-adb3-97e09d9c76bf"; + ResponseEntity<String> response = + sendRequest(inputStream("/ExecuteServiceLevelCustomWorkflow.json"), uri, HttpMethod.POST, headers); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + + @Test public void workflowAndOperationNameTest() { wireMockServer.stubFor(get(urlMatching( ".*/workflow/search/findByArtifactUUID[?]artifactUUID=71526781-e55c-4cb7-adb3-97e09d9c76be")) diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java index 9b892af869..7711608288 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java @@ -133,7 +133,6 @@ public class OrchestrationRequestsTest extends BaseTest { testResponse.getRequest().setRequestProcessingData(new ArrayList<RequestProcessingData>()); RequestProcessingData e = new RequestProcessingData(); e.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca714"); - e.setTag("pincFabricConfigRequest"); List<HashMap<String, String>> data = new ArrayList<HashMap<String, String>>(); HashMap<String, String> data1 = new HashMap<String, String>(); data1.put("requestAction", "assign"); @@ -210,7 +209,6 @@ public class OrchestrationRequestsTest extends BaseTest { testResponse.getRequest().setRequestProcessingData(new ArrayList<RequestProcessingData>()); RequestProcessingData e = new RequestProcessingData(); e.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca714"); - e.setTag("pincFabricConfigRequest"); List<HashMap<String, String>> data = new ArrayList<HashMap<String, String>>(); HashMap<String, String> data1 = new HashMap<String, String>(); data1.put("requestAction", "assign"); @@ -256,7 +254,6 @@ public class OrchestrationRequestsTest extends BaseTest { testResponse.getRequest().setRequestProcessingData(new ArrayList<RequestProcessingData>()); RequestProcessingData e = new RequestProcessingData(); e.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca714"); - e.setTag("pincFabricConfigRequest"); List<HashMap<String, String>> data = new ArrayList<HashMap<String, String>>(); HashMap<String, String> data1 = new HashMap<String, String>(); data1.put("requestAction", "assign"); @@ -463,13 +460,11 @@ public class OrchestrationRequestsTest extends BaseTest { HashMap<String, String> secondExpectedMap = new HashMap<>(); List<RequestProcessingData> expectedDataList = new ArrayList<>(); entry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca714"); - entry.setTag("pincFabricConfigRequest"); expectedMap.put("requestAction", "assign"); - expectedMap.put("pincFabricId", "testId"); + expectedMap.put("fabricId", "testId"); expectedList.add(expectedMap); entry.setDataPairs(expectedList); secondEntry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca715"); - secondEntry.setTag("pincFabricConfig"); secondExpectedMap.put("requestAction", "unassign"); secondExpectedList.add(secondExpectedMap); secondEntry.setDataPairs(secondExpectedList); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java index ef90b22b01..33d86a2cc6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java @@ -1,8 +1,6 @@ /*- * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +13,8 @@ * 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. + * + * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -97,6 +97,8 @@ public class ServiceInstancesTest extends BaseTest { private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/"; private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/"; + private final String orchestration_path = "/onap/so/infra"; + private String uri; private URL selfLink; private URL initialUrl; @@ -115,7 +117,7 @@ public class ServiceInstancesTest extends BaseTest { headers.set(ONAP_PARTNER_NAME, "VID"); headers.set(REQUESTOR_ID, "xxxxxx"); try { // generate one-time port number to avoid RANDOM port number later. - initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH)); + initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH, orchestration_path)); initialPort = initialUrl.getPort(); } catch (MalformedURLException e) { e.printStackTrace(); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java index 4ab88f40f6..1fa71cefc2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java @@ -58,6 +58,9 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest { @Autowired WorkflowSpecificationsHandler workflowSpecificationsHandler; + @Autowired + ObjectMapper mapper; + @Value("${wiremock.server.port}") private String wiremockPort; @@ -152,7 +155,6 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest { assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); WorkflowSpecifications expectedResponse = mapper.readValue( @@ -306,7 +308,6 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest { WorkflowSpecifications workflowSpecifications = workflowSpecificationsHandler.mapWorkflowsToWorkflowSpecifications(workflows); - ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); String workflowSpecificationsJson = mapper.writeValueAsString(workflowSpecifications); @@ -349,7 +350,6 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest { assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); WorkflowSpecifications expectedResponse = mapper.readValue( @@ -367,6 +367,52 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest { } @Test + public void queryWorkflowSpecificationsByResourceTarget_Test_Success() throws JSONException, IOException { + + String URL_PATH = basePath + "/v1/workflows"; + HttpHeaders headers = new HttpHeaders(); + headers.set("Accept", MediaType.APPLICATION_JSON); + headers.set("Content-Type", MediaType.APPLICATION_JSON); + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + String WORKFLOW_QUERY = "/workflow/search/findByResourceTarget[?]resourceTarget=service"; + String WORKFLOW_SPEC_QUERY = "/workflow/5/workflowActivitySpecSequence"; + String JSON_FILE_PATH = "src/test/resources/__files/catalogdb/WorkflowSpecificationsForService.json"; + String MOCK_RESP_FILE = "WorkflowSpecificationsForServiceWorkflows_Response.json"; + String MOCK_RESP_SPEC_FILE = "Empty_workflowActivitySpecSequence_Response.json"; + + wireMockServer.stubFor(get(urlMatching(WORKFLOW_QUERY)) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb(MOCK_RESP_FILE)) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + wireMockServer.stubFor(get(urlMatching(WORKFLOW_SPEC_QUERY)) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb(MOCK_RESP_SPEC_FILE)) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + UriComponentsBuilder builder = + UriComponentsBuilder.fromHttpUrl(createURLWithPort(URL_PATH)).queryParam("resourceTarget", "service"); + + ResponseEntity<String> response = + restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); + + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + WorkflowSpecifications expectedResponse = mapper + .readValue(new String(Files.readAllBytes(Paths.get(JSON_FILE_PATH))), WorkflowSpecifications.class); + WorkflowSpecifications realResponse = mapper.readValue(response.getBody(), WorkflowSpecifications.class); + + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); + assertThat(expectedResponse, sameBeanAs(realResponse)); + assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0)); + assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0)); + assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0)); + assertEquals("1.0.0", response.getHeaders().get("X-LatestVersion").get(0)); + } + + @Test public void testWorkflowSpecificationsForPnf_Success() throws JSONException, IOException { final String urlPath = basePath + "/v1/pnfWorkflows"; @@ -397,7 +443,6 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest { assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); WorkflowSpecifications expectedResponse = mapper.readValue( diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandlerTest.java index d39192cdf0..6c643c77d7 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandlerTest.java @@ -61,4 +61,15 @@ public class AbstractRestHandlerTest { restHandler.createResponse("instanceId", "requestId", mockRequestContext); assertThat(actualResponse, sameBeanAs(expectedResponse)); } + + @Test + public void test_buildSelfLinkUrl() throws MalformedURLException { + String initialLink = "http://some.domain.com:30277/onap/so/infra/serviceInstantiation/v7/serviceInstances"; + String requestId = "4d0437c3-ee48-4361-a4f7-e1613c82493a"; + Optional<URL> expectedLink = Optional.of(new URL( + "http://some.domain.com:30277/onap/so/infra/orchestrationRequests/v7/4d0437c3-ee48-4361-a4f7-e1613c82493a")); + Optional<URL> resultURL = restHandler.buildSelfLinkUrl(initialLink, requestId); + + assertThat(resultURL, sameBeanAs(expectedLink)); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/NetworkDeleteValidatorTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/NetworkDeleteValidatorTest.java index 7780f0ee2b..20ec6d6708 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/NetworkDeleteValidatorTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/NetworkDeleteValidatorTest.java @@ -58,7 +58,7 @@ public class NetworkDeleteValidatorTest { public void validateSuccessTest() { instanceIdMap.put("networkInstanceId", "1"); when(aaiDataRetrieval.isNetworkRelatedToModules("1")).thenReturn(false); - Optional<String> result = networkValidator.validate(instanceIdMap, null, null); + Optional<String> result = networkValidator.validate(instanceIdMap, null, null, null); assertEquals(false, result.isPresent()); } @@ -66,7 +66,7 @@ public class NetworkDeleteValidatorTest { public void validateFailureTest() { instanceIdMap.put("networkInstanceId", "1"); when(aaiDataRetrieval.isNetworkRelatedToModules("1")).thenReturn(true); - Optional<String> result = networkValidator.validate(instanceIdMap, null, null); + Optional<String> result = networkValidator.validate(instanceIdMap, null, null, null); assertEquals(true, result.isPresent()); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/ServiceInstanceDeleteValidatorTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/ServiceInstanceDeleteValidatorTest.java index f461df3720..c082c96074 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/ServiceInstanceDeleteValidatorTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/ServiceInstanceDeleteValidatorTest.java @@ -76,7 +76,7 @@ public class ServiceInstanceDeleteValidatorTest { when(aaiDataRetrieval.isServiceRelatedToGenericVnf("1")).thenReturn(false); when(aaiDataRetrieval.isServiceRelatedToNetworks("1")).thenReturn(false); when(aaiDataRetrieval.isServiceRelatedToConfiguration("1")).thenReturn(false); - Optional<String> result = serviceValidator.validate(instanceIdMap, null, null); + Optional<String> result = serviceValidator.validate(instanceIdMap, null, null, null); assertEquals(false, result.isPresent()); } @@ -84,7 +84,7 @@ public class ServiceInstanceDeleteValidatorTest { public void validateFailureVnfTest() { instanceIdMap.put("serviceInstanceId", "1"); when(aaiDataRetrieval.isServiceRelatedToGenericVnf("1")).thenReturn(true); - Optional<String> result = serviceValidator.validate(instanceIdMap, null, null); + Optional<String> result = serviceValidator.validate(instanceIdMap, null, null, null); assertEquals(true, result.isPresent()); } @@ -93,7 +93,7 @@ public class ServiceInstanceDeleteValidatorTest { instanceIdMap.put("serviceInstanceId", "1"); when(aaiDataRetrieval.isServiceRelatedToGenericVnf("1")).thenReturn(false); when(aaiDataRetrieval.isServiceRelatedToNetworks("1")).thenReturn(true); - Optional<String> result = serviceValidator.validate(instanceIdMap, null, null); + Optional<String> result = serviceValidator.validate(instanceIdMap, null, null, null); assertEquals(true, result.isPresent()); } @@ -103,7 +103,7 @@ public class ServiceInstanceDeleteValidatorTest { when(aaiDataRetrieval.isServiceRelatedToGenericVnf("1")).thenReturn(false); when(aaiDataRetrieval.isServiceRelatedToNetworks("1")).thenReturn(false); when(aaiDataRetrieval.isServiceRelatedToConfiguration("1")).thenReturn(true); - Optional<String> result = serviceValidator.validate(instanceIdMap, null, null); + Optional<String> result = serviceValidator.validate(instanceIdMap, null, null, null); assertEquals(true, result.isPresent()); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VnfDeleteValidatorTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VnfDeleteValidatorTest.java index 65ce355ad1..6eb6fc95d6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VnfDeleteValidatorTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VnfDeleteValidatorTest.java @@ -53,7 +53,7 @@ public class VnfDeleteValidatorTest { public void validateFailureVfModuleVnfTest() { instanceIdMap.put("vnfInstanceId", "1"); doReturn(Optional.of("test")).when(aaiDataRetrieval).getVfModuleIdsByVnfId("1"); - Optional<String> result = vnfValidator.validate(instanceIdMap, null, null); + Optional<String> result = vnfValidator.validate(instanceIdMap, null, null, null); assertEquals(true, result.isPresent()); } @@ -61,7 +61,7 @@ public class VnfDeleteValidatorTest { public void validateSuccessVfModuleVnfTest() { instanceIdMap.put("vnfInstanceId", "1"); doReturn(Optional.empty()).when(aaiDataRetrieval).getVfModuleIdsByVnfId("1"); - Optional<String> result = vnfValidator.validate(instanceIdMap, null, null); + Optional<String> result = vnfValidator.validate(instanceIdMap, null, null, null); assertEquals(false, result.isPresent()); } @@ -69,7 +69,7 @@ public class VnfDeleteValidatorTest { public void validateFailureVolumeGroupVnfTest() { instanceIdMap.put("vnfInstanceId", "1"); doReturn(Optional.of("test")).when(aaiDataRetrieval).getVolumeGroupIdsByVnfId("1"); - Optional<String> result = vnfValidator.validate(instanceIdMap, null, null); + Optional<String> result = vnfValidator.validate(instanceIdMap, null, null, null); assertEquals(true, result.isPresent()); } @@ -77,7 +77,7 @@ public class VnfDeleteValidatorTest { public void validateSuccessVolumeGroupVnfTest() { instanceIdMap.put("vnfInstanceId", "1"); doReturn(Optional.empty()).when(aaiDataRetrieval).getVolumeGroupIdsByVnfId("1"); - Optional<String> result = vnfValidator.validate(instanceIdMap, null, null); + Optional<String> result = vnfValidator.validate(instanceIdMap, null, null, null); assertEquals(false, result.isPresent()); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VolumeGroupDeleteValidatorTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VolumeGroupDeleteValidatorTest.java index 3d81ee66c9..7aa12a61a6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VolumeGroupDeleteValidatorTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VolumeGroupDeleteValidatorTest.java @@ -54,7 +54,7 @@ public class VolumeGroupDeleteValidatorTest { public void validateSuccessTest() { instanceIdMap.put("volumeGroupInstanceId", "1"); when(aaiDataRetrieval.isVolumeGroupRelatedToVFModule("1")).thenReturn(false); - Optional<String> result = volumeGroupDeleteValidator.validate(instanceIdMap, null, null); + Optional<String> result = volumeGroupDeleteValidator.validate(instanceIdMap, null, null, null); assertEquals(false, result.isPresent()); } @@ -62,7 +62,7 @@ public class VolumeGroupDeleteValidatorTest { public void validateFailureVnfTest() { instanceIdMap.put("volumeGroupInstanceId", "1"); when(aaiDataRetrieval.isVolumeGroupRelatedToVFModule("1")).thenReturn(true); - Optional<String> result = volumeGroupDeleteValidator.validate(instanceIdMap, null, null); + Optional<String> result = volumeGroupDeleteValidator.validate(instanceIdMap, null, null, null); assertEquals(true, result.isPresent()); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java index b21b468ce3..0b968520d6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java @@ -39,6 +39,7 @@ import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.onap.aaiclient.client.aai.AAIVersion; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandlerinfra.BaseTest; import org.onap.so.apihandlerinfra.exceptions.ApiException; @@ -46,7 +47,6 @@ import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest; import org.onap.so.apihandlerinfra.tenantisolationbeans.Distribution; import org.onap.so.apihandlerinfra.tenantisolationbeans.DistributionStatus; import org.onap.so.apihandlerinfra.tenantisolationbeans.Status; -import org.onap.aaiclient.client.aai.AAIVersion; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.beans.OperationalEnvDistributionStatus; import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/RequestProcessingData.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/RequestProcessingData.json index 79caa33419..a84b2dbe11 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/RequestProcessingData.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/RequestProcessingData.json @@ -4,21 +4,18 @@ "soRequestId": "00032ab7-na18-42e5-965d-8ea592502018", "groupingId": "7d2e8c07-4d10-456d-bddc-37abf38ca714", "name": "requestAction", - "value": "assign", - "tag": "pincFabricConfigRequest" + "value": "assign" },{ "id": 2, "soRequestId": "00032ab7-na18-42e5-965d-8ea592502018", "groupingId": "7d2e8c07-4d10-456d-bddc-37abf38ca714", - "name": "pincFabricId", - "value": "testId", - "tag": "pincFabricConfigRequest" + "name": "fabricId", + "value": "testId" },{ "id": 3, "soRequestId": "00032ab7-na18-42e5-965d-8ea592502018", "groupingId": "7d2e8c07-4d10-456d-bddc-37abf38ca715", "name": "requestAction", - "value": "unassign", - "tag": "pincFabricConfig" + "value": "unassign" } ]
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getRequestProcessingData.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getRequestProcessingData.json index af28007900..6ebe55201a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getRequestProcessingData.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getRequestProcessingData.json @@ -3,6 +3,5 @@ "soRequestId": "00032ab7-na18-42e5-965d-8ea592502018", "groupingId": "7d2e8c07-4d10-456d-bddc-37abf38ca714", "name": "requestAction", - "value": "assign", - "tag": "pincFabricConfigRequest" + "value": "assign" } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getRequestProcessingDataArray.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getRequestProcessingDataArray.json index c746020e7f..c3554c86a5 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getRequestProcessingDataArray.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getRequestProcessingDataArray.json @@ -3,6 +3,5 @@ "soRequestId": "00032ab7-na18-42e5-965d-8ea592502018", "groupingId": "7d2e8c07-4d10-456d-bddc-37abf38ca714", "name": "requestAction", - "value": "assign", - "tag": "pincFabricConfigRequest" + "value": "assign" }] diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ExecuteServiceLevelCustomWorkflow.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ExecuteServiceLevelCustomWorkflow.json new file mode 100644 index 0000000000..e466ac08a3 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ExecuteServiceLevelCustomWorkflow.json @@ -0,0 +1,39 @@ +{ + "requestDetails":{ + "subscriberInfo":{ + "globalSubscriberId":"Test" + }, + "requestInfo":{ + "suppressRollback": false, + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "requestorId": "demo", + "instanceName":"testInstanceName", + "source":"VID" + }, + "cloudConfiguration":{ + "lcpCloudRegionId": "RegionOne", + "tenantId": "7320ec4a5b9d4589ba7c4412ccfd290f", + "cloudOwner": "CloudOwner" + }, + "requestParameters":{ + "subscriptionServiceType": "test", + "userParams":[], + "aLaCarte": false, + "payload": "{\"k1\": \"v1\"}" + }, + "project":{ + "projectName": "PNFSWUProject" + }, + "owningEntity":{ + "owningEntityId":"67f2e84c-734d-4e90-a1e4-d2ffa2e75849", + "owningEntityName":"OE-Test" + }, + "modelInfo":{ + "modelVersion": "2.0", + "modelVersionId": "d88da85c-d9e8-4f73-b837-3a72a431622b", + "modelInvariantId": "fe41489e-1563-46a3-b90a-1db629e4375b", + "modelName": "Demo_svc", + "modelType": "service" + } + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForService.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForService.json new file mode 100644 index 0000000000..aaaad17470 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForService.json @@ -0,0 +1,20 @@ +{ + "workflowSpecificationList": [ + { + "workflowSpecification": { + "artifactInfo": { + "artifactType": "workflow", + "artifactUuid": "a1fe8726-66d5-3e7f-2212-7e5h662e9255", + "artifactName": "DummyServiceWorkflow", + "artifactVersion": "1.0", + "artifactDescription": "Dummy Service Workflow to test custom Service workflow", + "workflowName": "Dummy Service Workflow", + "operationName": "DummyServiceWorkflow", + "workflowSource": "native", + "workflowResourceTarget": "service" + }, + "workflowInputParameters": [] + } + } + ] +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForServiceWorkflows_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForServiceWorkflows_Response.json new file mode 100644 index 0000000000..9a836e033b --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForServiceWorkflows_Response.json @@ -0,0 +1,41 @@ +{ + "_embedded": { + "workflow": [ + { + "artifactChecksum": "MANUAL RECORD", + "artifactName": "DummyServiceWorkflow", + "artifactUUID": "a1fe8726-66d5-3e7f-2212-7e5h662e9255", + "body": null, + "created": "2020-06-29T08:28:15.000+0000", + "description": "Dummy Service Workflow to test custom Service workflow", + "id": 4, + "name": "Dummy Service Workflow", + "operationName": "DummyServiceWorkflow", + "pnfResourceWorkflow": null, + "resourceTarget": "service", + "source": "native", + "timeoutMinutes": null, + "version": 1.0, + "_links": { + "self": { + "href": "http://localhost:8090/workflow/search/findByResourceTarget?resourceTarget=service" + }, + "workflow": { + "href": "http://localhost:8090/workflow/5" + }, + "workflowActivitySpecSequence": { + "href": "http://localhost:8090/workflow/5/workflowActivitySpecSequence" + } + } + } + ] + }, + "_links": { + "self": { + "href": "http://localhost:8090/workflow/search/findByResourceTarget?resourceTarget=service" + }, + "workflowActivitySpecSequence": { + "href": "http://localhost:8090/workflow/5/workflowActivitySpecSequence" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_ServiceLevel_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_ServiceLevel_Response.json new file mode 100644 index 0000000000..133c724b43 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_ServiceLevel_Response.json @@ -0,0 +1,6 @@ +{ + "artifactUUID": "81526781-e55c-4cb7-adb3-97e09d9c76bf", + "artifactName": "testingServiceLevelWorkflow.bpmn", + "name": "testingServiceLevelWorkflow", + "operationName": "testServiceLevelOperation" +} diff --git a/mso-api-handlers/mso-requests-db-repositories/pom.xml b/mso-api-handlers/mso-requests-db-repositories/pom.xml index efc81384d4..8f623ad9e5 100644 --- a/mso-api-handlers/mso-requests-db-repositories/pom.xml +++ b/mso-api-handlers/mso-requests-db-repositories/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>mso-api-handlers</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>mso-requests-db-repositories</artifactId> diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvServiceModelStatusRepository.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvServiceModelStatusRepository.java index f0d717df3c..ea1aeb95a6 100644 --- a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvServiceModelStatusRepository.java +++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvServiceModelStatusRepository.java @@ -20,7 +20,6 @@ package org.onap.so.db.request.data.repository; -import java.util.List; import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; import org.onap.so.db.request.beans.OperationalEnvServiceModelStatusId; import org.springframework.data.jpa.repository.JpaRepository; @@ -35,7 +34,7 @@ public interface OperationalEnvServiceModelStatusRepository public OperationalEnvServiceModelStatus findOneByOperationalEnvIdAndRequestId(String operationalEnvId, String requestId); - public List<OperationalEnvServiceModelStatus> findAllByOperationalEnvIdAndRequestId( + public OperationalEnvServiceModelStatus[] findAllByOperationalEnvIdAndRequestId( @Param("OPERATIONAL_ENV_ID") String operationalEnvId, @Param("REQUEST_ID") String requestId); public OperationalEnvServiceModelStatus findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId( diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OrchestrationTaskRepository.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OrchestrationTaskRepository.java index 1093c79638..953361fd40 100644 --- a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OrchestrationTaskRepository.java +++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OrchestrationTaskRepository.java @@ -24,10 +24,9 @@ import org.onap.so.db.request.beans.OrchestrationTask; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.repository.query.Param; import org.springframework.data.rest.core.annotation.RepositoryRestResource; -import java.util.List; @RepositoryRestResource(collectionResourceRel = "orchestrationTask", path = "orchestrationTask") public interface OrchestrationTaskRepository extends JpaRepository<OrchestrationTask, String> { - public List<OrchestrationTask> findByStatus(@Param("status") String status); + public OrchestrationTask[] findByStatus(@Param("status") String status); } diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/RequestProcessingDataRepository.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/RequestProcessingDataRepository.java index cb02b7c491..21bc2a697a 100644 --- a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/RequestProcessingDataRepository.java +++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/RequestProcessingDataRepository.java @@ -37,11 +37,11 @@ public interface RequestProcessingDataRepository extends JpaRepository<RequestPr RequestProcessingData findOneBySoRequestIdAndName(@Param("SO_REQUEST_ID") String soRequestId, @Param("NAME") String name); - List<RequestProcessingData> findBySoRequestIdOrderByGroupingIdDesc(@Param("SO_REQUEST_ID") String soRequestId); + RequestProcessingData[] findBySoRequestIdOrderByGroupingIdDesc(@Param("SO_REQUEST_ID") String soRequestId); RequestProcessingData[] findBySoRequestIdAndIsDataInternalOrderByGroupingIdDesc( @Param("SO_REQUEST_ID") String soRequestId, @Param("IS_INTERNAL_DATA") Boolean isDataInternal); - List<RequestProcessingData> findByGroupingIdAndNameAndTag(@Param("GROUPING_ID") String groupingId, + RequestProcessingData[] findByGroupingIdAndNameAndTag(@Param("GROUPING_ID") String groupingId, @Param("NAME") String name, @Param("TAG") String tag); } diff --git a/mso-api-handlers/mso-requests-db/pom.xml b/mso-api-handlers/mso-requests-db/pom.xml index 37bb4175a5..6c1df3e450 100644 --- a/mso-api-handlers/mso-requests-db/pom.xml +++ b/mso-api-handlers/mso-requests-db/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>mso-api-handlers</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>mso-requests-db</artifactId> @@ -17,11 +17,6 @@ </properties> <dependencies> <dependency> - <groupId>uk.co.blackpepper.bowman</groupId> - <artifactId>bowman-client</artifactId> - <version>0.3.0</version> - </dependency> - <dependency> <groupId>org.onap.so</groupId> <artifactId>common</artifactId> <version>${project.version}</version> diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java index cf6cf687b0..cc721d38b6 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java @@ -40,8 +40,6 @@ import javax.persistence.TemporalType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.apache.commons.lang3.builder.ToStringBuilder; import org.onap.so.requestsdb.TimestampXMLAdapter; -import uk.co.blackpepper.bowman.annotation.LinkedResource; -import uk.co.blackpepper.bowman.annotation.ResourceId; @MappedSuperclass public abstract class InfraRequests implements java.io.Serializable { @@ -164,7 +162,6 @@ public abstract class InfraRequests implements java.io.Serializable { @JoinColumn(name = "SO_REQUEST_ID", referencedColumnName = "REQUEST_ID", updatable = false) private List<CloudApiRequests> cloudApiRequests = new ArrayList<>(); - @ResourceId public URI getRequestURI() { return URI.create(this.requestId); } @@ -443,7 +440,6 @@ public abstract class InfraRequests implements java.io.Serializable { return requestAction; } - @LinkedResource public List<CloudApiRequests> getCloudApiRequests() { return cloudApiRequests; } diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationalEnvServiceModelStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationalEnvServiceModelStatus.java index 2278c8cd9d..a7444a49d1 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationalEnvServiceModelStatus.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationalEnvServiceModelStatus.java @@ -22,6 +22,7 @@ package org.onap.so.db.request.beans; import java.io.Serializable; import java.util.Date; +import java.util.Objects; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; @@ -31,7 +32,6 @@ import javax.persistence.PreUpdate; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; -import java.util.Objects; import org.apache.commons.lang3.builder.ToStringBuilder; /** diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/RequestProcessingData.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/RequestProcessingData.java index e386789c7f..c52d311146 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/RequestProcessingData.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/RequestProcessingData.java @@ -48,7 +48,6 @@ import com.openpojo.business.annotation.BusinessKey; */ @Entity - @JsonInclude(Include.NON_NULL) @Table(name = "request_processing_data") public class RequestProcessingData implements Serializable { diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java index 6aa00caeed..17b22ec216 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java @@ -22,32 +22,26 @@ package org.onap.so.db.request.client; import java.net.URI; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.StreamSupport; import javax.annotation.PostConstruct; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriBuilder; import org.apache.http.HttpStatus; -import org.onap.logging.filter.spring.SpringClientPayloadFilter; import org.onap.so.db.request.beans.ArchivedInfraRequests; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.beans.OperationStatus; import org.onap.so.db.request.beans.OperationalEnvDistributionStatus; import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; +import org.onap.so.db.request.beans.OrchestrationTask; import org.onap.so.db.request.beans.RequestProcessingData; import org.onap.so.db.request.beans.ResourceOperationStatus; import org.onap.so.db.request.beans.SiteStatus; import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus; import org.onap.so.db.request.beans.WatchdogDistributionStatus; import org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup; -import org.onap.so.db.request.beans.OrchestrationTask; import org.onap.so.db.request.data.controller.InstanceNameDuplicateCheckRequest; -import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Primary; @@ -56,14 +50,9 @@ import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; -import org.springframework.http.client.BufferingClientHttpRequestFactory; -import org.springframework.http.client.ClientHttpRequestFactory; -import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.stereotype.Component; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; -import uk.co.blackpepper.bowman.ClientFactory; -import uk.co.blackpepper.bowman.Configuration; @Component("RequestsDbClient") @Primary @@ -166,25 +155,6 @@ public class RequestsDbClient { return endpoint; } - protected ClientFactory getClientFactory() { - URI baseUri = UriBuilder.fromUri(getEndpoint()).build(); - ClientHttpRequestFactory factory = - new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory()); - - return Configuration.builder().setBaseUri(baseUri).setClientHttpRequestFactory(factory) - .setRestTemplateConfigurer(restTemplate -> { - restTemplate.getInterceptors().add((new SOSpringClientFilter())); - restTemplate.getInterceptors().add((new SpringClientPayloadFilter())); - - restTemplate.getInterceptors().add((request, body, execution) -> { - - request.getHeaders().add(HttpHeaders.AUTHORIZATION, msoAdaptersAuth); - return execution.execute(request, body); - }); - }).build().buildClientFactory(); - } - - public List<InfraActiveRequests> getCloudOrchestrationFiltersFromInfraActive(Map<String, String> orchestrationMap) { URI uri = getUri(cloudOrchestrationFiltersFromInfraActive); HttpHeaders headers = getHttpHeaders(); @@ -201,30 +171,21 @@ public class RequestsDbClient { } public List<InfraActiveRequests> getInProgressVolumeGroupsAndVfModules() { - HttpHeaders headers = getHttpHeaders(); URI uri = getUri(endpoint + getInProgressVolumeGroupsAndVfModules); - HttpEntity<Map<String, List<String>>> entity = new HttpEntity<>(headers); - return restTemplate - .exchange(uri, HttpMethod.GET, entity, new ParameterizedTypeReference<List<InfraActiveRequests>>() {}) - .getBody(); + + return getMultipleResponse(uri, new ParameterizedTypeReference<List<InfraActiveRequests>>() {}); + } public InfraActiveRequests getInfraActiveRequestbyRequestId(String requestId) { - try { - HttpEntity<?> entity = getHttpEntity(); - InfraActiveRequests infraActiveRequests = - restTemplate.exchange(getUri(endpoint + "/infraActiveRequests/" + requestId), HttpMethod.GET, - entity, InfraActiveRequests.class).getBody(); - if (infraActiveRequests != null) { - infraActiveRequests.setRequestId(requestId); - } - return infraActiveRequests; - } catch (HttpClientErrorException e) { - if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { - return null; - } - throw e; + + + InfraActiveRequests infraActiveRequests = + getSingleResponse(getUri(endpoint + "/infraActiveRequests/" + requestId), InfraActiveRequests.class); + if (infraActiveRequests != null) { + infraActiveRequests.setRequestId(requestId); } + return infraActiveRequests; } public List<InfraActiveRequests> getOrchestrationFiltersFromInfraActive( @@ -238,9 +199,8 @@ public class RequestsDbClient { } public InfraActiveRequests checkVnfIdStatus(String operationalEnvironmentId) { - HttpEntity<?> entity = getHttpEntity(); URI uri = getUri(checkVnfIdStatus + operationalEnvironmentId); - return restTemplate.exchange(uri, HttpMethod.GET, entity, InfraActiveRequests.class).getBody(); + return getSingleResponse(uri, InfraActiveRequests.class); } public InfraActiveRequests checkInstanceNameDuplicate(Map<String, String> instanceIdMap, String instanceName, @@ -249,66 +209,40 @@ public class RequestsDbClient { URI uri = getUri(checkInstanceNameDuplicate); HttpEntity<InstanceNameDuplicateCheckRequest> entity = new HttpEntity<>( new InstanceNameDuplicateCheckRequest(instanceIdMap, instanceName, requestScope), headers); - try { - ResponseEntity<InfraActiveRequests> response = - restTemplate.exchange(uri, HttpMethod.POST, entity, InfraActiveRequests.class); - if (response != null && response.hasBody()) { - return restTemplate.exchange(uri, HttpMethod.POST, entity, InfraActiveRequests.class).getBody(); - } else { - return null; - } - } catch (HttpClientErrorException e) { - if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { - return null; - } - throw e; - } + + return postSingleResponse(uri, entity, InfraActiveRequests.class); } public OperationStatus getOneByServiceIdAndOperationId(String serviceId, String operationId) { - try { - HttpEntity<?> entity = getHttpEntity(); - OperationStatus operationStatus = restTemplate.exchange(getUri( - UriBuilder.fromUri(getUri(findOneByServiceIdAndOperationIdURI)).queryParam(SERVICE_ID, serviceId) - .queryParam(OPERATION_ID, operationId).build().toString()), - HttpMethod.GET, entity, OperationStatus.class).getBody(); - if (operationStatus != null) { - operationStatus.setServiceId(serviceId); - operationStatus.setOperationId(operationId); - } - - return operationStatus; - } catch (HttpClientErrorException e) { - if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { - return null; - } - throw e; + OperationStatus operationStatus = getSingleResponse( + getUri(UriBuilder.fromUri(getUri(findOneByServiceIdAndOperationIdURI)).queryParam(SERVICE_ID, serviceId) + .queryParam(OPERATION_ID, operationId).build().toString()), + OperationStatus.class); + if (operationStatus != null) { + operationStatus.setServiceId(serviceId); + operationStatus.setOperationId(operationId); } + return operationStatus; } public OperationalEnvServiceModelStatus findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId( String operationalEnvironmentId, String serviceModelVersionId, String requestId) { - try { - HttpEntity<?> entity = getHttpEntity(); - OperationalEnvServiceModelStatus modelStatus = restTemplate.exchange( - getUri(UriBuilder.fromUri(findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestIdURI) - .queryParam(OPERATIONAL_ENVIRONMENT_ID, operationalEnvironmentId) - .queryParam(SERVICE_MODEL_VERSION_ID, serviceModelVersionId) - .queryParam(REQUEST_ID, requestId).build().toString()), - HttpMethod.GET, entity, OperationalEnvServiceModelStatus.class).getBody(); - if (null != modelStatus) { - modelStatus.setOperationalEnvId(operationalEnvironmentId); - modelStatus.setServiceModelVersionId(serviceModelVersionId); - modelStatus.setRequestId(requestId); - } - return modelStatus; - } catch (HttpClientErrorException e) { - if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { - return null; - } - throw e; + + OperationalEnvServiceModelStatus modelStatus = + getSingleResponse( + getUri(UriBuilder.fromUri(findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestIdURI) + .queryParam(OPERATIONAL_ENVIRONMENT_ID, operationalEnvironmentId) + .queryParam(SERVICE_MODEL_VERSION_ID, serviceModelVersionId) + .queryParam(REQUEST_ID, requestId).build().toString()), + OperationalEnvServiceModelStatus.class); + if (null != modelStatus) { + modelStatus.setOperationalEnvId(operationalEnvironmentId); + modelStatus.setServiceModelVersionId(serviceModelVersionId); + modelStatus.setRequestId(requestId); } + return modelStatus; + } public List<OperationalEnvServiceModelStatus> getAllByOperationalEnvIdAndRequestId(String operationalEnvironmentId, @@ -320,30 +254,18 @@ public class RequestsDbClient { } public OperationalEnvDistributionStatus getDistributionStatusById(String distributionId) { - try { - HttpEntity<?> entity = getHttpEntity(); - OperationalEnvDistributionStatus distributionStatus = - restTemplate.exchange(getUri(operationalEnvDistributionStatusURI + distributionId), HttpMethod.GET, - entity, OperationalEnvDistributionStatus.class).getBody(); - if (null != distributionStatus) { - distributionStatus.setDistributionId(distributionId); - } - return distributionStatus; - } catch (HttpClientErrorException e) { - if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { - return null; - } - throw e; + + OperationalEnvDistributionStatus distributionStatus = getSingleResponse( + getUri(operationalEnvDistributionStatusURI + distributionId), OperationalEnvDistributionStatus.class); + if (null != distributionStatus) { + distributionStatus.setDistributionId(distributionId); } + return distributionStatus; + } private List<OperationalEnvServiceModelStatus> getMultipleOperationalEnvServiceModelStatus(URI uri) { - Iterable<OperationalEnvServiceModelStatus> iterable = - getClientFactory().create(OperationalEnvServiceModelStatus.class).getAll(uri); - List<OperationalEnvServiceModelStatus> serviceModelStatuses = new ArrayList<>(); - Iterator<OperationalEnvServiceModelStatus> statusIterator = iterable.iterator(); - statusIterator.forEachRemaining(serviceModelStatuses::add); - return serviceModelStatuses; + return getMultipleResponse(uri, new ParameterizedTypeReference<List<OperationalEnvServiceModelStatus>>() {}); } public void save(InfraActiveRequests infraActiveRequests) { @@ -376,38 +298,16 @@ public class RequestsDbClient { } public InfraActiveRequests getInfraActiveRequests(String requestId, String basicAuth, String host) { - RestTemplate template = new RestTemplate(); - HttpHeaders headers = new HttpHeaders(); - headers.set(HttpHeaders.AUTHORIZATION, basicAuth); - headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); - headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON); + URI uri = getUri(host + "/infraActiveRequests/" + requestId); - try { - InfraActiveRequests infraActiveRequests = template - .exchange(uri, HttpMethod.GET, new HttpEntity<>(headers), InfraActiveRequests.class).getBody(); - if (infraActiveRequests != null) { - infraActiveRequests.setRequestId(requestId); - } - return infraActiveRequests; - } catch (HttpClientErrorException e) { - if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { - return null; - } - throw e; - } + + return getSingleResponse(uri, InfraActiveRequests.class); } public void updateInfraActiveRequests(InfraActiveRequests request, String basicAuth, String host) { - RestTemplate template = new RestTemplate(); - template.getInterceptors().add(new SOSpringClientFilter()); - template.getInterceptors().add(new SpringClientPayloadFilter()); - HttpHeaders headers = new HttpHeaders(); - headers.set(HttpHeaders.AUTHORIZATION, basicAuth); - headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); - headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON); URI uri = getUri(host + "/infraActiveRequests/" + request.getRequestId()); - HttpEntity<InfraActiveRequests> entity = new HttpEntity<>(request, headers); - template.put(uri, entity); + HttpEntity<InfraActiveRequests> entity = new HttpEntity<>(request, getHttpHeaders()); + restTemplate.put(uri, entity); } protected URI getUri(String uri) { @@ -437,41 +337,30 @@ public class RequestsDbClient { public List<RequestProcessingData> getExternalRequestProcessingDataBySoRequestId(String soRequestId) { URI uri = getUri(UriBuilder.fromUri(getEndpoint() + findBySoRequestIdAndIsDataInternalOrderByGroupingIdDesc) .queryParam(SO_REQUEST_ID, soRequestId).queryParam(IS_INTERNAL_DATA, false).build().toString()); - ResponseEntity<RequestProcessingData[]> array = - restTemplate.exchange(uri, HttpMethod.GET, getHttpEntity(), RequestProcessingData[].class); - if (array != null) { - return Arrays.asList(array.getBody()); - } else { - return null; - } + return getMultipleResponse(uri, new ParameterizedTypeReference<List<RequestProcessingData>>() {}); } public RequestProcessingData getRequestProcessingDataBySoRequestIdAndNameAndGrouping(String soRequestId, String name, String groupingId) { - return getClientFactory().create(RequestProcessingData.class) - .get(getUri(UriBuilder.fromUri(endpoint + findBySoRequestIdAndGroupIdAndName) - .queryParam(SO_REQUEST_ID, soRequestId).queryParam(NAME, name) - .queryParam(GROUPING_ID, groupingId).build().toString())); + return getSingleResponse(getUri( + UriBuilder.fromUri(endpoint + findBySoRequestIdAndGroupIdAndName).queryParam(SO_REQUEST_ID, soRequestId) + .queryParam(NAME, name).queryParam(GROUPING_ID, groupingId).build().toString()), + RequestProcessingData.class); } public List<RequestProcessingData> getRequestProcessingDataByGroupingIdAndNameAndTag(String groupingId, String name, String tag) { - Iterable<RequestProcessingData> requestProcessingDataListIt = - getClientFactory().create(RequestProcessingData.class) - .getAll(getUri(UriBuilder.fromUri(endpoint + findByGroupingIdAndNameAndTag) - .queryParam(GROUPING_ID, groupingId).queryParam(NAME, name).queryParam(TAG, tag).build() - .toString())); - - List<RequestProcessingData> requestProcessingDataList = - StreamSupport.stream(requestProcessingDataListIt.spliterator(), false).collect(Collectors.toList()); - return requestProcessingDataList; + return getMultipleResponse( + getUri(UriBuilder.fromUri(endpoint + findByGroupingIdAndNameAndTag).queryParam(GROUPING_ID, groupingId) + .queryParam(NAME, name).queryParam(TAG, tag).build().toString()), + new ParameterizedTypeReference<List<RequestProcessingData>>() {}); } public RequestProcessingData getRequestProcessingDataBySoRequestIdAndName(String soRequestId, String name) { - return getClientFactory().create(RequestProcessingData.class) - .get(getUri(UriBuilder.fromUri(endpoint + findBySoRequestIdAndName) - .queryParam(SO_REQUEST_ID, soRequestId).queryParam(NAME, name).build().toString())); + return getSingleResponse(getUri(UriBuilder.fromUri(endpoint + findBySoRequestIdAndName) + .queryParam(SO_REQUEST_ID, soRequestId).queryParam(NAME, name).build().toString()), + RequestProcessingData.class); } @@ -491,26 +380,14 @@ public class RequestsDbClient { } private List<RequestProcessingData> getRequestProcessingData(URI uri) { - Iterable<RequestProcessingData> requestProcessingDataIterator = - getClientFactory().create(RequestProcessingData.class).getAll(uri); - List<RequestProcessingData> requestProcessingDataList = new ArrayList<>(); - Iterator<RequestProcessingData> it = requestProcessingDataIterator.iterator(); - it.forEachRemaining(requestProcessingDataList::add); - return requestProcessingDataList; + return getMultipleResponse(uri, new ParameterizedTypeReference<List<RequestProcessingData>>() {}); } public InfraActiveRequests findOneByRequestId(String requestId) { - try { - HttpEntity<?> entity = getHttpEntity(); - return restTemplate.exchange( - getUri(UriBuilder.fromUri(findOneByRequestId).queryParam(REQUEST_ID, requestId).build().toString()), - HttpMethod.GET, entity, InfraActiveRequests.class).getBody(); - } catch (HttpClientErrorException e) { - if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { - return null; - } - throw e; - } + return getSingleResponse( + getUri(UriBuilder.fromUri(findOneByRequestId).queryParam(REQUEST_ID, requestId).build().toString()), + InfraActiveRequests.class); + } // From and To are defaulted to ignore start/endtime on query to database @@ -525,11 +402,8 @@ public class RequestsDbClient { } public List<OrchestrationTask> getAllOrchestrationTasks() { - String url = UriBuilder.fromUri(getUri(orchestrationTasksURI)).build().toString(); - HttpEntity<?> entity = getHttpEntity(); - return restTemplate - .exchange(url, HttpMethod.GET, entity, new ParameterizedTypeReference<List<OrchestrationTask>>() {}) - .getBody(); + return getMultipleResponse(getUri(orchestrationTasksURI), + new ParameterizedTypeReference<List<OrchestrationTask>>() {}); } public OrchestrationTask getOrchestrationTask(String taskId) { @@ -605,4 +479,54 @@ public class RequestsDbClient { return new HttpEntity<>(headers); } + private <T> T getSingleResponse(URI uri, Class<T> clazz) { + try { + HttpEntity<?> entity = getHttpEntity(); + return restTemplate.exchange(uri, HttpMethod.GET, entity, clazz).getBody(); + } catch (HttpClientErrorException e) { + if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { + return null; + } + throw e; + } + } + + private <T> List<T> getMultipleResponse(URI uri, ParameterizedTypeReference<List<T>> type) { + try { + HttpEntity<?> entity = getHttpEntity(); + return restTemplate.exchange(uri, HttpMethod.GET, entity, type).getBody(); + } catch (HttpClientErrorException e) { + if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { + return new ArrayList<T>(); + } + throw e; + } + } + + private <T> T postSingleResponse(URI uri, HttpEntity<?> payload, Class<T> clazz) { + try { + HttpEntity<?> entity = new HttpEntity<>(payload.getBody(), getHttpHeaders()); + return restTemplate.exchange(uri, HttpMethod.POST, entity, clazz).getBody(); + } catch (HttpClientErrorException e) { + if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { + return null; + } + throw e; + } + } + + private <T> List<T> postMultipleResponse(URI uri, HttpEntity<?> payload, ParameterizedTypeReference<List<T>> type) { + try { + HttpEntity<?> entity = new HttpEntity<>(payload.getBody(), getHttpHeaders()); + ResponseEntity<List<T>> result = restTemplate.exchange(uri, HttpMethod.POST, entity, type); + + return result.getBody(); + } catch (HttpClientErrorException e) { + if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { + return new ArrayList<T>(); + } + throw e; + } + } + } diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/client/RequestDbClientTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/client/RequestDbClientTest.java index 0ad8d1458e..32886bf62e 100644 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/client/RequestDbClientTest.java +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/client/RequestDbClientTest.java @@ -1,11 +1,14 @@ package org.onap.so.db.request.client; +import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.times; +import static org.mockito.Mockito.when; import java.net.URI; +import java.util.ArrayList; +import java.util.List; import javax.ws.rs.core.UriBuilder; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; @@ -13,21 +16,14 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; -import org.onap.logging.filter.spring.SpringClientPayloadFilter; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.beans.RequestProcessingData; -import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter; -import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.http.client.BufferingClientHttpRequestFactory; -import org.springframework.http.client.ClientHttpRequestFactory; -import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestTemplate; -import uk.co.blackpepper.bowman.ClientFactory; -import uk.co.blackpepper.bowman.Configuration; @RunWith(MockitoJUnitRunner.class) @@ -61,12 +57,16 @@ public class RequestDbClientTest { @Test public void testGetRequestProcessingDataBySoRequestIdAndIsInternalData() { Mockito.doReturn("host").when(requestsDbClient).getEndpoint(); - requestsDbClient.getExternalRequestProcessingDataBySoRequestId("12345"); URI uri = URI.create(UriBuilder .fromUri("host/requestProcessingData/search/findBySoRequestIdAndIsDataInternalOrderByGroupingIdDesc") .queryParam("SO_REQUEST_ID", "12345").queryParam("IS_INTERNAL_DATA", false).build().toString()); - Mockito.verify(restTemplate, times(1)).exchange(eq(uri), eq(HttpMethod.GET), isA(HttpEntity.class), - eq(RequestProcessingData[].class)); + when(restTemplate.exchange(eq(uri), eq(HttpMethod.GET), isA(HttpEntity.class), + isA(ParameterizedTypeReference.class))).thenReturn( + new ResponseEntity<List<RequestProcessingData>>(new ArrayList<RequestProcessingData>(), + HttpStatus.NOT_FOUND)); + assertTrue(requestsDbClient.getExternalRequestProcessingDataBySoRequestId("12345").isEmpty()); + + } } diff --git a/mso-api-handlers/pom.xml b/mso-api-handlers/pom.xml index db939a6868..9463d5d6b6 100644 --- a/mso-api-handlers/pom.xml +++ b/mso-api-handlers/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>so</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>mso-api-handlers</artifactId> @@ -19,7 +19,6 @@ <module>mso-api-handler-common</module> <module>mso-api-handler-infra</module> </modules> - <dependencies> <dependency> <groupId>org.apache.httpcomponents</groupId> diff --git a/mso-catalog-db/pom.xml b/mso-catalog-db/pom.xml index 7444866315..ff88b81461 100644 --- a/mso-catalog-db/pom.xml +++ b/mso-catalog-db/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>so</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>mso-catalog-db</artifactId> @@ -35,29 +35,12 @@ </executions> </plugin> </plugins> - <pluginManagement> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>3.3</version> - <configuration> - <source>1.8</source> - <target>1.8</target> - <fork>true</fork> - <compilerArgs> - <arg>-parameters</arg> - </compilerArgs> - </configuration> - </plugin> - </plugins> - </pluginManagement> </build> <dependencies> <dependency> <groupId>uk.co.blackpepper.bowman</groupId> <artifactId>bowman-client</artifactId> - <version>0.3.0</version> + <version>${bowman.client.version}</version> </dependency> <dependency> <groupId>org.onap.so</groupId> @@ -74,11 +57,6 @@ <artifactId>mariadb-java-client</artifactId> </dependency> <dependency> - <groupId>com.openpojo</groupId> - <artifactId>openpojo</artifactId> - <version>0.8.6</version> - </dependency> - <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpec.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpec.java index 20c10748b6..0d14916ee2 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpec.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpec.java @@ -19,8 +19,10 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/activitySpec") @Table(name = "activity_spec") public class ActivitySpec implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecActivitySpecCategories.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecActivitySpecCategories.java index 062bdd6edc..d57996bbaa 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecActivitySpecCategories.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecActivitySpecCategories.java @@ -36,8 +36,10 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/activitySpecActivitySpecCategories") @Table(name = "activity_spec_to_activity_spec_categories") public class ActivitySpecActivitySpecCategories implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecActivitySpecParameters.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecActivitySpecParameters.java index f3e6a09b7f..ea407aeca5 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecActivitySpecParameters.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecActivitySpecParameters.java @@ -36,8 +36,10 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/activitySpecActivitySpecParameters") @Table(name = "activity_spec_to_activity_spec_parameters") public class ActivitySpecActivitySpecParameters implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecCategories.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecCategories.java index 2474d5cb8c..32c17f71b2 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecCategories.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecCategories.java @@ -11,8 +11,10 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/activitySpecCategories") @Table(name = "activity_spec_categories") public class ActivitySpecCategories implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecParameters.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecParameters.java index ed056400b2..cd5ed3dece 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecParameters.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecParameters.java @@ -15,8 +15,10 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/activitySpecParameters") @Table(name = "activity_spec_parameters") public class ActivitySpecParameters implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecUserParameters.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecUserParameters.java index d23c782a1a..7e825b3a0d 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecUserParameters.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecUserParameters.java @@ -36,8 +36,10 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/activitySpecUserParameters") @Table(name = "activity_spec_to_user_parameters") public class ActivitySpecUserParameters implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResource.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResource.java index c3a662d883..19e875f8bc 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResource.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResource.java @@ -39,8 +39,10 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/allottedResource") @Table(name = "allotted_resource") public class AllottedResource implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResourceCustomization.java index b3734caccc..2afb39f20e 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResourceCustomization.java @@ -39,8 +39,10 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/allottedResourceCustomization") @Table(name = "allotted_resource_customization") public class AllottedResourceCustomization implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ArRecipe.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ArRecipe.java index 176c02c8cd..c28a78a93a 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ArRecipe.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ArRecipe.java @@ -32,8 +32,10 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/arRecipe") @Table(name = "ar_recipe") public class ArRecipe implements Recipe, Serializable { private static final long serialVersionUID = 768026109321305392L; diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/BBNameSelectionReference.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/BBNameSelectionReference.java index 9b71c970a7..63dfa6180e 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/BBNameSelectionReference.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/BBNameSelectionReference.java @@ -31,8 +31,10 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/bbNameSelectionReference") @Table(name = "bbname_selection_reference") public class BBNameSelectionReference implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/BuildingBlockDetail.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/BuildingBlockDetail.java index f94b8155f8..14ec4b1ac1 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/BuildingBlockDetail.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/BuildingBlockDetail.java @@ -33,8 +33,10 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/buildingBlockDetail") @Table(name = "building_block_detail") public class BuildingBlockDetail implements Serializable { private static final long serialVersionUID = -2375223199178059155L; diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java index 7dd163bafa..61b0b11445 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java @@ -36,6 +36,7 @@ import javax.persistence.PrePersist; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import uk.co.blackpepper.bowman.annotation.RemoteResource; /** * EntityBean class for a CloudIdentity. This bean represents a cloud identity service instance (i.e. a DCP node) in the @@ -43,6 +44,7 @@ import javax.persistence.TemporalType; * */ @Entity +@RemoteResource("/cloudIdentity") @Table(name = "identity_services") public class CloudIdentity { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudSite.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudSite.java index 0d7fe7d38f..8e3f47552f 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudSite.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudSite.java @@ -51,8 +51,8 @@ import uk.co.blackpepper.bowman.annotation.ResourceId; * will be loaded via CloudConfig object, of which it is a component * */ -@RemoteResource("/cloudSite") @Entity +@RemoteResource("/cloudSite") @Table(name = "cloud_sites") @JsonAutoDetect(fieldVisibility = Visibility.ANY) public class CloudSite { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudifyManager.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudifyManager.java index a3df245ae6..33185b28c7 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudifyManager.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudifyManager.java @@ -34,6 +34,7 @@ import javax.persistence.PrePersist; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import uk.co.blackpepper.bowman.annotation.RemoteResource; /** * EntityBean class for a Cloudify Manager. This bean represents a Cloudify node through which TOSCA-based VNFs may be @@ -45,6 +46,7 @@ import javax.persistence.TemporalType; * @author JC1348 */ @Entity +@RemoteResource("/cloudifyManager") @Table(name = "cloudify_managers") public class CloudifyManager { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionNetworkResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionNetworkResourceCustomization.java index 566268ba57..f8d05b95a2 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionNetworkResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionNetworkResourceCustomization.java @@ -38,8 +38,10 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/collectionNetworkResourceCustomization") @Table(name = "collection_network_resource_customization") public class CollectionNetworkResourceCustomization implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResource.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResource.java index 9a92d0a64f..b8ec638180 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResource.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResource.java @@ -38,8 +38,10 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/collectionResource") @Table(name = "collection_resource") public class CollectionResource implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResourceCustomization.java index 8214c0a074..4a547b1a8d 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResourceCustomization.java @@ -43,8 +43,10 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/collectionResourceCustomization") @DiscriminatorColumn(name = "OBJECT_TYPE") @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @Table(name = "collection_resource_customization") diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResourceInstanceGroupCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResourceInstanceGroupCustomization.java index 4a72f9a3c2..f59ed73147 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResourceInstanceGroupCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResourceInstanceGroupCustomization.java @@ -39,8 +39,10 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/collectionResourceInstanceGroupCustomization") @IdClass(CollectionResourceInstanceGroupCustomizationId.class) @Table(name = "collection_resource_instance_group_customization") public class CollectionResourceInstanceGroupCustomization implements Serializable { @@ -60,10 +62,12 @@ public class CollectionResourceInstanceGroupCustomization implements Serializabl @Column(name = "INSTANCE_GROUP_MODEL_UUID") private String modelUUID; + @BusinessKey @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinColumn(name = "COLLECTION_RESOURCE_CUSTOMIZATION_MODEL_UUID", updatable = false, insertable = false) private CollectionResourceCustomization collectionResourceCust; + @BusinessKey @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinColumn(name = "INSTANCE_GROUP_MODEL_UUID", updatable = false, insertable = false) private InstanceGroup instanceGroup; diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ConfigurationResource.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ConfigurationResource.java index 9c2e1de244..731b237c98 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ConfigurationResource.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ConfigurationResource.java @@ -38,9 +38,11 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @JsonIgnoreProperties({"hibernateLazyInitializer", "handler"}) @Entity +@RemoteResource("/configurationResource") @Table(name = "configuration") public class ConfigurationResource implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ConfigurationResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ConfigurationResourceCustomization.java index 3be9e1f1e3..7f5d0f531d 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ConfigurationResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ConfigurationResourceCustomization.java @@ -41,8 +41,10 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/configurationResourceCustomization") @Table(name = "configuration_customization") public class ConfigurationResourceCustomization implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ControllerSelectionReference.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ControllerSelectionReference.java index ac0d09b13b..9b73997e36 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ControllerSelectionReference.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ControllerSelectionReference.java @@ -29,9 +29,11 @@ import com.openpojo.business.annotation.BusinessKey; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.EqualsBuilder; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @IdClass(ControllerSelectionReferenceId.class) @Entity +@RemoteResource("/controllerSelectionReference") @Table(name = "controller_selection_reference") public class ControllerSelectionReference implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcConfigurationCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcConfigurationCustomization.java index 97518ec81b..c5575b2adf 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcConfigurationCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcConfigurationCustomization.java @@ -41,8 +41,10 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import com.fasterxml.jackson.annotation.JsonFormat; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/cvnfcConfigurationCustomization") @Table(name = "cvnfc_configuration_customization") public class CvnfcConfigurationCustomization implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcCustomization.java index f5b5d7319d..822aa50b6e 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcCustomization.java @@ -43,8 +43,10 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import com.fasterxml.jackson.annotation.JsonFormat; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/cvnfcCustomization") @Table(name = "cvnfc_customization") public class CvnfcCustomization implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ExternalServiceToInternalService.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ExternalServiceToInternalService.java index f664e79702..f05934dd53 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ExternalServiceToInternalService.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ExternalServiceToInternalService.java @@ -31,8 +31,10 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/externalServiceToInternalService") @Table(name = "external_service_to_internal_model_mapping") public class ExternalServiceToInternalService implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatEnvironment.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatEnvironment.java index 511f7cf709..8ec6c88754 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatEnvironment.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatEnvironment.java @@ -34,8 +34,10 @@ import javax.persistence.TemporalType; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import com.openpojo.business.annotation.BusinessKey; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/heatEnvironment") @Table(name = "heat_environment") public class HeatEnvironment implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatFiles.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatFiles.java index 3badf2ae11..b1873eebdb 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatFiles.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatFiles.java @@ -34,8 +34,10 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/heatFiles") @Table(name = "heat_files") public class HeatFiles implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatTemplate.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatTemplate.java index 82725f089d..ac9af180a5 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatTemplate.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatTemplate.java @@ -43,8 +43,10 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/heatTemplate") @Table(name = "heat_template") public class HeatTemplate implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatTemplateParam.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatTemplateParam.java index 6abf695797..e7e8ee1f32 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatTemplateParam.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatTemplateParam.java @@ -30,9 +30,11 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @IdClass(HeatTemplateParamId.class) @Entity +@RemoteResource("/heatTemplateParam") @Table(name = "heat_template_params") public class HeatTemplateParam implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HomingInstance.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HomingInstance.java index 75871afe83..567ecae50d 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HomingInstance.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HomingInstance.java @@ -38,8 +38,8 @@ import java.net.URI; * homing * */ -@RemoteResource("/homingInstance") @Entity +@RemoteResource("/homingInstance") @Table(name = "homing_instances") public class HomingInstance { @JsonProperty diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/InstanceGroup.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/InstanceGroup.java index d226ffee13..9de53ab9dc 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/InstanceGroup.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/InstanceGroup.java @@ -46,8 +46,10 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/instanceGroup") @DiscriminatorColumn(name = "OBJECT_TYPE") @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @Table(name = "instance_group") diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Model.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Model.java index 0592e8f058..e0148705ed 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Model.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Model.java @@ -39,8 +39,10 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/model") @Table(name = "model") public class Model implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ModelRecipe.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ModelRecipe.java index 3f89e9db74..6ddda4c911 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ModelRecipe.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ModelRecipe.java @@ -34,8 +34,10 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/modelRecipe") @Table(name = "model_recipe") public class ModelRecipe implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkCollectionResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkCollectionResourceCustomization.java index bb9079be23..4be79aaddf 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkCollectionResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkCollectionResourceCustomization.java @@ -26,8 +26,10 @@ import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.OneToMany; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/networkCollectionResourceCustomization") @DiscriminatorValue(value = "NetworkCollection") public class NetworkCollectionResourceCustomization extends CollectionResourceCustomization { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkInstanceGroup.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkInstanceGroup.java index 24782efcf0..b3eb4e37f0 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkInstanceGroup.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkInstanceGroup.java @@ -22,8 +22,10 @@ package org.onap.so.db.catalog.beans; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/networkInstanceGroup") @DiscriminatorValue(value = "L3_NETWORK") public class NetworkInstanceGroup extends InstanceGroup { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkRecipe.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkRecipe.java index 7bdbe9cdba..dce940472e 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkRecipe.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkRecipe.java @@ -32,8 +32,10 @@ import javax.persistence.TemporalType; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import com.openpojo.business.annotation.BusinessKey; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/networkRecipe") @Table(name = "network_recipe") public class NetworkRecipe implements Serializable, Recipe { private static final long serialVersionUID = 768026109321305392L; diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkResource.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkResource.java index 6876200754..65444d0819 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkResource.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkResource.java @@ -41,8 +41,10 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/networkResource") @Table(name = "network_resource") public class NetworkResource implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkResourceCustomization.java index 21b1550cb5..b4ca14ba67 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkResourceCustomization.java @@ -38,8 +38,10 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/networkResourceCustomization") @Table(name = "network_resource_customization") public class NetworkResourceCustomization implements Serializable { public static final long serialVersionUID = -1322322139926390329L; diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatusStateTransitionDirective.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatusStateTransitionDirective.java index fd3f387e3f..e8795dc90c 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatusStateTransitionDirective.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatusStateTransitionDirective.java @@ -33,8 +33,10 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/orchestrationStatusStateTransitionDirective") @Table(name = "orchestration_status_state_transition_directive") public class OrchestrationStatusStateTransitionDirective implements Serializable { private static final long serialVersionUID = -4626396955833442376L; diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResource.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResource.java index cb3195bbac..0e15c00cfd 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResource.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResource.java @@ -32,8 +32,10 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/pnfResource") @Table(name = "pnf_resource") public class PnfResource implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceCustomization.java index db0e0abd3c..d26ce84505 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceCustomization.java @@ -32,8 +32,10 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/pnfResourceCustomization") @Table(name = "pnf_resource_customization") public class PnfResourceCustomization implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceWorkflow.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceWorkflow.java index 6e48938f19..b5d537c4c6 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceWorkflow.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceWorkflow.java @@ -16,8 +16,10 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/pnfResourceWorkflow") @Table(name = "pnf_resource_to_workflow") public class PnfResourceWorkflow implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java index 8222b72d8f..487b3c6ad9 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java @@ -44,8 +44,10 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import com.fasterxml.jackson.annotation.JsonFormat; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/service") @Table(name = "service") public class Service implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceProxyResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceProxyResourceCustomization.java index 60f6642823..7620a075ca 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceProxyResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceProxyResourceCustomization.java @@ -38,8 +38,10 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/serviceProxyResourceCustomization") @Table(name = "service_proxy_customization") public class ServiceProxyResourceCustomization implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceRecipe.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceRecipe.java index 9e98041cf8..45ac333682 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceRecipe.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceRecipe.java @@ -38,8 +38,10 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/serviceRecipe") @Table(name = "service_recipe") public class ServiceRecipe implements Serializable, Recipe { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/TempNetworkHeatTemplateLookup.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/TempNetworkHeatTemplateLookup.java index b037b926f1..85b89396e4 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/TempNetworkHeatTemplateLookup.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/TempNetworkHeatTemplateLookup.java @@ -29,8 +29,10 @@ import javax.persistence.Table; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import com.openpojo.business.annotation.BusinessKey; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/tempNetworkHeatTemplateLookup") @Table(name = "temp_network_heat_template_lookup") @IdClass(TempNetworkHeatTemplateLookupId.class) public class TempNetworkHeatTemplateLookup implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ToscaCsar.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ToscaCsar.java index 2f9b19ada0..426a3963ee 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ToscaCsar.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ToscaCsar.java @@ -38,8 +38,10 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import com.fasterxml.jackson.annotation.JsonIgnore; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/toscaCsar") @Table(name = "tosca_csar") public class ToscaCsar implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/UserParameters.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/UserParameters.java index 9ec61ff05f..c466fb1ede 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/UserParameters.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/UserParameters.java @@ -15,8 +15,10 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/userParameters") @Table(name = "user_parameters") public class UserParameters implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VFCInstanceGroup.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VFCInstanceGroup.java index ea7d1adad6..fa5a9a9bd2 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VFCInstanceGroup.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VFCInstanceGroup.java @@ -22,8 +22,10 @@ package org.onap.so.db.catalog.beans; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/vfcInstanceGroup") @DiscriminatorValue(value = "VNFC") public class VFCInstanceGroup extends InstanceGroup { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModule.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModule.java index 0c7820f5f0..a972dbcc66 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModule.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModule.java @@ -44,8 +44,10 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import com.fasterxml.jackson.annotation.JsonFormat; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/vfModule") @Table(name = "vf_module") public class VfModule implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModuleCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModuleCustomization.java index 83de95874c..5cacec7185 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModuleCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModuleCustomization.java @@ -43,8 +43,10 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import com.fasterxml.jackson.annotation.JsonFormat; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/vfModuleCustomization") @Table(name = "vf_module_customization") public class VfModuleCustomization implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfComponentsRecipe.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfComponentsRecipe.java index 89121bc7e1..7ccffa4f51 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfComponentsRecipe.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfComponentsRecipe.java @@ -31,8 +31,10 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/vnfComponentsRecipe") @Table(name = "vnf_components_recipe") public class VnfComponentsRecipe implements Serializable, Recipe { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfRecipe.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfRecipe.java index ef3d8761c1..187fbea15c 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfRecipe.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfRecipe.java @@ -35,8 +35,10 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/vnfRecipe") @Table(name = "vnf_recipe") public class VnfRecipe implements Serializable, Recipe { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResource.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResource.java index fb54449d5f..c553c48f58 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResource.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResource.java @@ -42,8 +42,10 @@ import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/vnfResource") @Table(name = "vnf_resource") public class VnfResource implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java index 8e1814f225..54d757ad05 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java @@ -44,8 +44,10 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import com.fasterxml.jackson.annotation.JsonFormat; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/vnfResourceCustomization") @Table(name = "vnf_resource_customization") public class VnfResourceCustomization implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceWorkflow.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceWorkflow.java index 21549e2646..5aee674d64 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceWorkflow.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceWorkflow.java @@ -36,8 +36,10 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/vnfResourceWorkflow") @Table(name = "vnf_resource_to_workflow") public class VnfResourceWorkflow implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcCustomization.java index 413efaf12c..5b6bded5c5 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcCustomization.java @@ -40,8 +40,10 @@ import javax.persistence.TemporalType; import java.io.Serializable; import java.util.Date; import java.util.List; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/vnfcCustomization") @Table(name = "vnfc_customization") public class VnfcCustomization implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomization.java index 0f760ac91a..a95b3542b3 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomization.java @@ -43,8 +43,10 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/vnfcInstanceGroupCustomization") @Table(name = "vnfc_instance_group_customization") public class VnfcInstanceGroupCustomization implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Workflow.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Workflow.java index fc1c753e85..05e8ddc501 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Workflow.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Workflow.java @@ -20,8 +20,10 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/workflow") @Table(name = "workflow") public class Workflow implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/WorkflowActivitySpecSequence.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/WorkflowActivitySpecSequence.java index e953ff2cd4..b3ffab6723 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/WorkflowActivitySpecSequence.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/WorkflowActivitySpecSequence.java @@ -36,9 +36,11 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/workflowActivitySpecSequence") @Table(name = "workflow_activity_spec_sequence") public class WorkflowActivitySpecSequence implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/macro/NorthBoundRequest.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/macro/NorthBoundRequest.java index 6319ae01eb..fa949d0cf2 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/macro/NorthBoundRequest.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/macro/NorthBoundRequest.java @@ -36,8 +36,10 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/northbound_request_ref_lookup") @Table(name = "northbound_request_ref_lookup") public class NorthBoundRequest implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/macro/OrchestrationFlow.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/macro/OrchestrationFlow.java index 91b74d4d6a..3a517c3ef4 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/macro/OrchestrationFlow.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/macro/OrchestrationFlow.java @@ -36,8 +36,10 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/orchestrationFlow") @Table(name = "orchestration_flow_reference") public class OrchestrationFlow implements Serializable { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/macro/RainyDayHandlerStatus.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/macro/RainyDayHandlerStatus.java index 39217c75fa..76d0368536 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/macro/RainyDayHandlerStatus.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/macro/RainyDayHandlerStatus.java @@ -31,8 +31,10 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; +import uk.co.blackpepper.bowman.annotation.RemoteResource; @Entity +@RemoteResource("/rainy_day_handler_macro") @Table(name = "rainy_day_handler_macro") public class RainyDayHandlerStatus implements Serializable { diff --git a/packages/docker/pom.xml b/packages/docker/pom.xml index 217a5fdb5c..c260e12123 100644 --- a/packages/docker/pom.xml +++ b/packages/docker/pom.xml @@ -6,7 +6,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>packages</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <packaging>pom</packaging> @@ -65,13 +65,11 @@ <groupId>io.fabric8</groupId> <artifactId>docker-maven-plugin</artifactId> <version>0.31.0</version> - - <configuration> + <configuration combine.self="override"> <verbose>true</verbose> <apiVersion>1.23</apiVersion> <pullRegistry>${docker.pull.registry}</pullRegistry> <pushRegistry>${docker.push.registry}</pushRegistry> - <images> <image> <name>${docker.image.prefix}/base-image:1.0</name> @@ -105,30 +103,6 @@ </build> </image> <image> - <name>${docker.image.prefix}/ve-vnfm-adapter</name> - <build> - <cleanup>try</cleanup> - <dockerFile>docker-files/Dockerfile.so-app</dockerFile> - <tags> - <tag>${project.version}</tag> - <tag>${project.version}-${maven.build.timestamp}</tag> - <tag>${project.docker.latesttag.version}</tag> - </tags> - <assembly> - <inline> - <dependencySets> - <dependencySet> - <includes> - <include>org.onap.so.adapters:etsi-sol002-adapter</include> - </includes> - <outputFileNameMapping>app.jar</outputFileNameMapping> - </dependencySet> - </dependencySets> - </inline> - </assembly> - </build> - </image> - <image> <name>${docker.image.prefix}/catalog-db-adapter</name> <build> <cleanup>try</cleanup> @@ -472,11 +446,6 @@ </dependency> <dependency> <groupId>org.onap.so.adapters</groupId> - <artifactId>etsi-sol002-adapter</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.onap.so.adapters</groupId> <artifactId>mso-catalog-db-adapter</artifactId> <version>${project.version}</version> </dependency> diff --git a/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image b/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image index e3eb954e1e..bf4a2fe01f 100644 --- a/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image +++ b/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image @@ -1,4 +1,4 @@ -FROM docker.io/openjdk:8-jdk-alpine +FROM docker.io/onap/integration-java11:7.0.0 ARG http_proxy ARG https_proxy diff --git a/packages/pom.xml b/packages/pom.xml index af302405cc..3df696c74b 100644 --- a/packages/pom.xml +++ b/packages/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>so</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>packages</artifactId> @@ -1,6 +1,5 @@ -<?xml version="1.0"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<?xml version="1.0" ?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.oparent</groupId> @@ -11,7 +10,7 @@ <groupId>org.onap.so</groupId> <artifactId>so</artifactId> <packaging>pom</packaging> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> <name>so</name> <description>This Maven project is responsible to build and package all child projects - contributions in the MSO project. This build can be configured to run Functional tests and to start/stop a jboss server + Mysql DB. @@ -29,6 +28,8 @@ <module>mso-api-handlers</module> <module>adapters</module> <module>asdc-controller</module> + <module>so-optimization-clients</module> + <module>so-sdn-clients</module> <module>bpmn</module> <module>cloudify-client</module> <module>cxf-logging</module> @@ -41,6 +42,7 @@ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <sonar.language>java</sonar.language> + <java.version>11</java.version> <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin> <sonar.surefire.reportsPath>${project.build.directory}/surefire-reports</sonar.surefire.reportsPath> <sonar.coverage.jacoco.xmlReportPaths>${project.reporting.outputDirectory}/jacoco-ut/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths> @@ -65,14 +67,16 @@ <snapshotNexusPath>content/repositories/snapshots/</snapshotNexusPath> <publicNexusPath>content/repositories/public/</publicNexusPath> <siteNexusPath>content/sites/site/org/onap/so/${project.version}/</siteNexusPath> - <cxf.version>3.2.6</cxf.version> + <cxf.version>3.3.3</cxf.version> <jax.ws.rs>2.1</jax.ws.rs> <springboot.version>2.1.5.RELEASE</springboot.version> <camunda.springboot.version>3.2.0</camunda.springboot.version> <format.skipValidate>false</format.skipValidate> <format.skipExecute>true</format.skipExecute> <io.fabric8.version>0.33.0</io.fabric8.version> - <appc.client.version>1.7.1</appc.client.version> + <appc.client.version>1.8.0-SNAPSHOT</appc.client.version> + <bowman.client.version>0.8.0</bowman.client.version> + <aaf.cadi.version>2.1.15</aaf.cadi.version> </properties> <distributionManagement> <repository> @@ -212,9 +216,10 @@ </resource> </resources> <plugins> - <!-- <plugin> <groupId>org.sonatype.plugins</groupId> <artifactId>nexus-staging-maven-plugin</artifactId> <version>1.6.7</version> - <extensions>true</extensions> <configuration> <nexusUrl>${nexusproxy}</nexusUrl> <stagingProfileId>176c31dfe190a</stagingProfileId> - <serverId>ecomp-staging</serverId> </configuration> </plugin> --> + <!-- <plugin> <groupId>org.sonatype.plugins</groupId> <artifactId>nexus-staging-maven-plugin</artifactId> + <version>1.6.7</version> <extensions>true</extensions> <configuration> <nexusUrl>${nexusproxy}</nexusUrl> + <stagingProfileId>176c31dfe190a</stagingProfileId> <serverId>ecomp-staging</serverId> + </configuration> </plugin> --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> @@ -227,18 +232,20 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>3.6.1</version> + <version>3.8.0</version> <configuration> <debug>true</debug> <compilerArgument>-Xlint</compilerArgument> <verbose>true</verbose> <showDeprecation>true</showDeprecation> <showWarnings>true</showWarnings> - <source>1.8</source> - <target>1.8</target> <compilerArgs> <arg>-parameters</arg> </compilerArgs> + <forceJavacCompilerUse>true</forceJavacCompilerUse> + <source>11</source> + <target>11</target> + <release>11</release> </configuration> </plugin> <plugin> @@ -327,7 +334,7 @@ <version>4.20</version> <configuration> <buildId>mso-${project.version}</buildId> - <source>1.8</source> + <source>${java.version}</source> </configuration> </plugin> <plugin> @@ -534,7 +541,7 @@ </plugins> <pluginManagement> <plugins> - <plugin> + <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> <version>1.0.0</version> @@ -554,7 +561,7 @@ <execute /> </action> </pluginExecution> - <pluginExecution> + <pluginExecution> <pluginExecutionFilter> <groupId>org.codehaus.gmaven</groupId> <artifactId>groovy-maven-plugin</artifactId> @@ -580,14 +587,17 @@ <skipBuild>${docker.skip.build}</skipBuild> <skipPush>${docker.skip.push}</skipPush> <dockerHost>${docker.newHost}</dockerHost> - <!-- 1. Update address to your local docker VM. 2. Add IP to your NO_PROXY environment variable --> + <!-- 1. Update address to your local docker VM. 2. Add IP to + your NO_PROXY environment variable --> <certPath>${docker.host.cert.path}</certPath> - <!-- Add -Ddocker.host.cert.pat="path to your local certs directory" to maven build command --> + <!-- Add -Ddocker.host.cert.pat="path to your local certs directory" + to maven build command --> <pushRegistry>${dockerPushRepo}</pushRegistry> - <!-- Update .m2/settings.xml Add server id settings.dockerRepository, username, and password --> + <!-- Update .m2/settings.xml Add server id settings.dockerRepository, + username, and password --> <pullRegistry>${dockerPullRepo}</pullRegistry> - <!-- If docker repo is not public. Update .m2/settings.xml Add server id settings.dockerRepository, username, - and password --> + <!-- If docker repo is not public. Update .m2/settings.xml Add + server id settings.dockerRepository, username, and password --> <images> <image> <alias>service</alias> @@ -611,7 +621,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.20</version> + <version>2.22.2</version> <configuration> <systemPropertyVariables> <so.log.level>DEBUG</so.log.level> @@ -625,7 +635,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> - <version>2.20</version> + <version>2.22.2</version> <configuration> <skip>true</skip> <systemPropertyVariables> @@ -644,6 +654,7 @@ <goal>unpack</goal> </goals> <configuration> + <skip>true</skip> <artifactItems> <artifactItem> <groupId>org.onap.so</groupId> @@ -665,12 +676,11 @@ <executions> <execution> <id>original</id> - <phase>package</phase> + <phase>none</phase> <goals> <goal>jar</goal> </goals> <configuration> - <skip>true</skip> <classifier>${originalClassifier}</classifier> <includes> <include>**</include> @@ -823,7 +833,7 @@ <dependency> <groupId>com.openpojo</groupId> <artifactId>openpojo</artifactId> - <version>0.8.10</version> + <version>0.8.13</version> </dependency> <dependency> <groupId>com.shazam</groupId> @@ -848,6 +858,12 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.ow2.asm</groupId> + <artifactId>asm</artifactId> + <version>7.0</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>com.googlecode.junit-toolbox</groupId> <artifactId>junit-toolbox</artifactId> <version>2.4</version> @@ -855,22 +871,20 @@ </dependencies> <dependencyManagement> <dependencies> - <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient --> - <!-- force use of version 4.5 everywhere in transient deps, aligned on WildFly 10 version --> <dependency> <groupId>org.onap.logging-analytics</groupId> <artifactId>logging-slf4j</artifactId> - <version>1.6.7-SNAPSHOT</version> + <version>1.6.7</version> </dependency> <dependency> <groupId>org.onap.logging-analytics</groupId> <artifactId>logging-filter-base</artifactId> - <version>1.6.7-SNAPSHOT</version> + <version>1.6.7</version> </dependency> <dependency> <groupId>org.onap.logging-analytics</groupId> <artifactId>logging-filter-spring</artifactId> - <version>1.6.7-SNAPSHOT</version> + <version>1.6.7</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> @@ -906,7 +920,7 @@ <dependency> <groupId>org.yaml</groupId> <artifactId>snakeyaml</artifactId> - <version>1.23</version> + <version>1.26</version> </dependency> <dependency> <groupId>javax.interceptor</groupId> diff --git a/so-monitoring/pom.xml b/so-monitoring/pom.xml index 206a0f2851..8c6d397bae 100644 --- a/so-monitoring/pom.xml +++ b/so-monitoring/pom.xml @@ -24,7 +24,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>so</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <groupId>org.onap.so.monitoring</groupId> @@ -34,8 +34,8 @@ <name>${project.artifactId}</name> <properties> - <java.version>1.8</java.version> - <version.java.compiler>1.8</version.java.compiler> + <java.version>11</java.version> + <version.java.compiler>11</version.java.compiler> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> </properties> diff --git a/so-monitoring/so-monitoring-handler/pom.xml b/so-monitoring/so-monitoring-handler/pom.xml index 176328a434..f199a9f91f 100644 --- a/so-monitoring/so-monitoring-handler/pom.xml +++ b/so-monitoring/so-monitoring-handler/pom.xml @@ -24,7 +24,7 @@ <parent> <groupId>org.onap.so.monitoring</groupId> <artifactId>so-monitoring</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>so-monitoring-handler</artifactId> <name>${project.artifactId}</name> @@ -32,8 +32,6 @@ <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - <java.version>1.8</java.version> - <openpojo.version>0.8.6</openpojo.version> </properties> @@ -81,7 +79,7 @@ <dependency> <groupId>nl.jqno.equalsverifier</groupId> <artifactId>equalsverifier</artifactId> - <version>2.5.1</version> + <version>3.4.1</version> <scope>test</scope> </dependency> <dependency> diff --git a/so-monitoring/so-monitoring-service/pom.xml b/so-monitoring/so-monitoring-service/pom.xml index 110c3fe863..6671ac56d4 100644 --- a/so-monitoring/so-monitoring-service/pom.xml +++ b/so-monitoring/so-monitoring-service/pom.xml @@ -24,7 +24,7 @@ <parent> <groupId>org.onap.so.monitoring</groupId> <artifactId>so-monitoring</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>so-monitoring-service</artifactId> <name>${project.artifactId}</name> diff --git a/so-monitoring/so-monitoring-ui/pom.xml b/so-monitoring/so-monitoring-ui/pom.xml index 6488c7d7df..71480416d3 100644 --- a/so-monitoring/so-monitoring-ui/pom.xml +++ b/so-monitoring/so-monitoring-ui/pom.xml @@ -24,7 +24,7 @@ <parent> <groupId>org.onap.so.monitoring</groupId> <artifactId>so-monitoring</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>so-monitoring-ui</artifactId> @@ -49,7 +49,7 @@ </goals> <phase>generate-resources</phase> <configuration> - <nodeVersion>v10.8.0</nodeVersion> + <nodeVersion>v10.15.3</nodeVersion> <yarnVersion>v1.7.0</yarnVersion> </configuration> </execution> diff --git a/so-optimization-clients/pom.xml b/so-optimization-clients/pom.xml new file mode 100644 index 0000000000..79b1f7d5a4 --- /dev/null +++ b/so-optimization-clients/pom.xml @@ -0,0 +1,89 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.onap.so</groupId> + <artifactId>so</artifactId> + <version>1.7.1-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <artifactId>so-optimization-clients</artifactId> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <executions> + <execution> + <id>integration-test</id> + <goals> + <goal>test</goal> + </goals> + <configuration> + <includes> + <include>**/IntegrationTestSuite.java</include> + </includes> + </configuration> + </execution> + </executions> + <configuration> + <parallel>suites</parallel> + </configuration> + </plugin> + </plugins> + </build> + <dependencyManagement> + <dependencies> + <dependency> + <!-- Import dependency management from Spring Boot --> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-dependencies</artifactId> + <version>${springboot.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + <dependencies> + <dependency> + <groupId>org.camunda.bpm.springboot</groupId> + <artifactId>camunda-bpm-spring-boot-starter</artifactId> + <version>${camunda.springboot.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.cloud</groupId> + <artifactId>spring-cloud-contract-wiremock</artifactId> + <version>1.2.4.RELEASE</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-configuration-processor</artifactId> + <optional>true</optional> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>common</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>ch.vorburger.mariaDB4j</groupId> + <artifactId>mariaDB4j</artifactId> + <version>2.2.3</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mariadb.jdbc</groupId> + <artifactId>mariadb-java-client</artifactId> + </dependency> + </dependencies> +</project> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofClient.java b/so-optimization-clients/src/main/java/org/onap/so/client/oof/OofClient.java index 8b0cf69f6c..71ecc5c478 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofClient.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/oof/OofClient.java @@ -21,7 +21,6 @@ package org.onap.so.client.oof; -import org.camunda.bpm.engine.delegate.BpmnError; import org.onap.so.client.BaseClient; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.oof.beans.OofProperties; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofValidator.java b/so-optimization-clients/src/main/java/org/onap/so/client/oof/OofValidator.java index abbf52e38c..2c22d9d09e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofValidator.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/oof/OofValidator.java @@ -27,7 +27,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import java.util.LinkedHashMap; -import static org.apache.commons.lang.StringUtils.isNotBlank; +import static org.apache.commons.lang3.StringUtils.isNotBlank; @Component diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/LicenseDemand.java b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/LicenseDemand.java index e64a5450b5..e64a5450b5 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/LicenseDemand.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/LicenseDemand.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/LicenseInfo.java b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/LicenseInfo.java index 74ff9339d3..74ff9339d3 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/LicenseInfo.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/LicenseInfo.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ModelInfo.java b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/ModelInfo.java index 433de22aba..433de22aba 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ModelInfo.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/ModelInfo.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofProperties.java b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/OofProperties.java index 84e29b6f2d..84e29b6f2d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofProperties.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/OofProperties.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequest.java b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/OofRequest.java index f8896240ba..f8896240ba 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequest.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/OofRequest.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequestParameters.java b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/OofRequestParameters.java index 6c9e45c787..6c9e45c787 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequestParameters.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/OofRequestParameters.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java index 631b3707d4..631b3707d4 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java index 7519e8c87e..7519e8c87e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/RequestInfo.java b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/RequestInfo.java index 0132ed56e9..0132ed56e9 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/RequestInfo.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/RequestInfo.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/Resource.java b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/Resource.java index 8d44c63571..8d44c63571 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/Resource.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/Resource.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ResourceModelInfo.java b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/ResourceModelInfo.java index 9d0352525d..9d0352525d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ResourceModelInfo.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/ResourceModelInfo.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ServiceInfo.java b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/ServiceInfo.java index db0e2acd60..db0e2acd60 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ServiceInfo.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/ServiceInfo.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/SubscriberInfo.java b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/SubscriberInfo.java index 8fef4c45e7..8fef4c45e7 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/SubscriberInfo.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/oof/beans/SubscriberInfo.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/SniroClient.java index c63cbc0b68..6930b6e0af 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/SniroClient.java @@ -23,10 +23,9 @@ package org.onap.so.client.sniro; import java.util.LinkedHashMap; -import org.camunda.bpm.engine.delegate.BpmnError; -import org.onap.so.bpmn.core.UrnPropertiesReader; import org.onap.so.client.BaseClient; import org.onap.so.client.exception.BadResponseException; +import org.onap.so.client.sniro.beans.ConductorProperties; import org.onap.so.client.sniro.beans.ManagerProperties; import org.onap.so.client.sniro.beans.SniroConductorRequest; import org.onap.so.client.sniro.beans.SniroManagerRequest; @@ -57,7 +56,6 @@ public class SniroClient { * @param homingRequest * @return * @throws BadResponseException - * @throws BpmnError */ public void postDemands(SniroManagerRequest homingRequest) throws BadResponseException { logger.trace("Started Sniro Client Post Demands"); @@ -95,14 +93,13 @@ public class SniroClient { */ public void postRelease(SniroConductorRequest releaseRequest) throws BadResponseException { logger.trace("Started Sniro Client Post Release"); - String url = UrnPropertiesReader.getVariable("sniro.conductor.host") - + UrnPropertiesReader.getVariable("sniro.conductor.uri"); + String url = ConductorProperties.getHost() + ConductorProperties.getUri(); logger.debug("Post release url: {}", url); logger.debug("Post release payload: {}", releaseRequest.toJsonString()); HttpHeaders header = new HttpHeaders(); header.setContentType(MediaType.APPLICATION_JSON); - header.set("Authorization", UrnPropertiesReader.getVariable("sniro.conductor.headers.auth")); + header.set("Authorization", ConductorProperties.getAuth()); BaseClient<String, LinkedHashMap<String, Object>> baseClient = new BaseClient<>(); baseClient.setTargetUrl(url); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroValidator.java b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/SniroValidator.java index eb73001f42..fc16125433 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroValidator.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/SniroValidator.java @@ -23,7 +23,7 @@ package org.onap.so.client.sniro; -import static org.apache.commons.lang.StringUtils.*; +import static org.apache.commons.lang3.StringUtils.*; import java.util.LinkedHashMap; import org.json.JSONObject; import org.onap.so.client.exception.BadResponseException; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Candidate.java b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/Candidate.java index 3127275b24..87e81ccaad 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Candidate.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/Candidate.java @@ -22,7 +22,6 @@ package org.onap.so.client.sniro.beans; import java.io.Serializable; import java.util.List; -import org.onap.so.bpmn.servicedecomposition.homingobjects.CandidateType; import com.fasterxml.jackson.annotation.JsonProperty; public class Candidate implements Serializable { diff --git a/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/CandidateType.java b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/CandidateType.java new file mode 100644 index 0000000000..3ef89184e2 --- /dev/null +++ b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/CandidateType.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.sniro.beans; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum CandidateType { + + + SERVICE_INSTANCE_ID("serviceInstanceId"), CLOUD_REGION_ID("cloudRegionId"), VNF_ID("vnfId"), VNF_NAME("vnfName"); + + private final String name; + + private CandidateType(String name) { + this.name = name; + } + + @Override + @JsonValue + public String toString() { + return name; + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ConductorProperties.java b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/ConductorProperties.java index 9ac8727a0f..0250ea06b4 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ConductorProperties.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/ConductorProperties.java @@ -20,42 +20,40 @@ package org.onap.so.client.sniro.beans; -import java.util.Map; -import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; +@Component @Configuration -@ConfigurationProperties(prefix = "sniro.conductor") public class ConductorProperties { - private String host; - private String uri; + private static Environment environment; - private Map<String, String> headers; - - - public String getHost() { - return host; - } - - public void setHost(String host) { - this.host = host; + @Autowired + public void setEnvironment(Environment environment) { + this.environment = environment; } - public String getUri() { - return uri; + public static String getHost() { + return getProperty("sniro.conductor.host"); } - public void setUri(String uri) { - this.uri = uri; + public static String getUri() { + return getProperty("sniro.conductor.uri"); } - public Map<String, String> getHeaders() { - return headers; + public static String getAuth() { + return getProperty("sniro.conductor.headers.auth"); } - public void setHeaders(Map<String, String> headers) { - this.headers = headers; + private static String getProperty(String variableName) { + if (environment != null) { + return environment.getProperty(variableName); + } else { + return null; + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Demand.java b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/Demand.java index 0cc993560d..0cc993560d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Demand.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/Demand.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/LicenseInfo.java b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/LicenseInfo.java index 9ab3ae673a..9ab3ae673a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/LicenseInfo.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/LicenseInfo.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ManagerProperties.java b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/ManagerProperties.java index 70b1a37b5e..70b1a37b5e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ManagerProperties.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/ManagerProperties.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ModelInfo.java b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/ModelInfo.java index 6c1932e344..6c1932e344 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ModelInfo.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/ModelInfo.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/PlacementInfo.java b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/PlacementInfo.java index bbbbf9cfd6..bbbbf9cfd6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/PlacementInfo.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/PlacementInfo.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/RequestInfo.java b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/RequestInfo.java index fc6aec7d14..fc6aec7d14 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/RequestInfo.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/RequestInfo.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Resource.java b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/Resource.java index b5d40a8e80..b5d40a8e80 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Resource.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/Resource.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ServiceInfo.java b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/ServiceInfo.java index 8b6f234c1e..8b6f234c1e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ServiceInfo.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/ServiceInfo.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SniroConductorRequest.java b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/SniroConductorRequest.java index b8896a2bab..b8896a2bab 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SniroConductorRequest.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/SniroConductorRequest.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SniroManagerRequest.java b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/SniroManagerRequest.java index 4babbe5c39..4babbe5c39 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SniroManagerRequest.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/SniroManagerRequest.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SubscriberInfo.java b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/SubscriberInfo.java index 35a4cac459..35a4cac459 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SubscriberInfo.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/beans/SubscriberInfo.java diff --git a/so-optimization-clients/src/test/java/org/onap/so/BaseIntegrationTest.java b/so-optimization-clients/src/test/java/org/onap/so/BaseIntegrationTest.java new file mode 100644 index 0000000000..7dccfd3208 --- /dev/null +++ b/so-optimization-clients/src/test/java/org/onap/so/BaseIntegrationTest.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so; + +import java.io.IOException; +import java.io.InputStream; +import org.junit.Before; +import org.junit.runner.RunWith; +import org.onap.so.client.oof.OofClient; +import org.onap.so.client.sniro.SniroClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.SpyBean; +import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; +import com.github.tomakehurst.wiremock.WireMockServer; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +@ContextConfiguration +@AutoConfigureWireMock(port = 0) +public abstract class BaseIntegrationTest { + + @Value("${wiremock.server.port}") + protected String wireMockPort; + + @SpyBean + protected SniroClient sniroClient; + + @SpyBean + protected OofClient oofClient; + + @Autowired + protected WireMockServer wireMockServer; + + @Before + public void baseTestBefore() { + wireMockServer.resetAll(); + } +} + + diff --git a/so-optimization-clients/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java b/so-optimization-clients/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java new file mode 100644 index 0000000000..62d9ecee44 --- /dev/null +++ b/so-optimization-clients/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so; + +import ch.vorburger.exec.ManagedProcessException; +import ch.vorburger.mariadb4j.DBConfigurationBuilder; +import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.jdbc.DataSourceBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import javax.sql.DataSource; + +@Configuration +@Profile({"test"}) +public class EmbeddedMariaDbConfig { + + @Bean + MariaDB4jSpringService mariaDB4jSpringService() { + MariaDB4jSpringService service = new MariaDB4jSpringService(); + + + service.getConfiguration().addArg("--lower_case_table_names=1"); + return service; + } + + @Bean + DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService, + @Value("${mariaDB4j.databaseName}") String databaseName, + @Value("${spring.datasource.username}") String datasourceUsername, + @Value("${spring.datasource.password}") String datasourcePassword, + @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException { + // Create our database with default root user and no password + mariaDB4jSpringService.getDB().createDB(databaseName); + + DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration(); + + return DataSourceBuilder.create().username(datasourceUsername).password(datasourcePassword) + .url(config.getURL(databaseName)).driverClassName(datasourceDriver).build(); + } +} diff --git a/so-optimization-clients/src/test/java/org/onap/so/IntegrationTestSuite.java b/so-optimization-clients/src/test/java/org/onap/so/IntegrationTestSuite.java new file mode 100644 index 0000000000..50bbc1845f --- /dev/null +++ b/so-optimization-clients/src/test/java/org/onap/so/IntegrationTestSuite.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so; + +import org.junit.runner.RunWith; +import com.googlecode.junittoolbox.SuiteClasses; +import com.googlecode.junittoolbox.WildcardPatternSuite; + +@RunWith(WildcardPatternSuite.class) +@SuiteClasses({"**/*IT.class"}) +public class IntegrationTestSuite { + +} diff --git a/so-optimization-clients/src/test/java/org/onap/so/TestApplication.java b/so-optimization-clients/src/test/java/org/onap/so/TestApplication.java new file mode 100644 index 0000000000..fe965b4444 --- /dev/null +++ b/so-optimization-clients/src/test/java/org/onap/so/TestApplication.java @@ -0,0 +1,43 @@ +package org.onap.so; +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + + + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.ComponentScan.Filter; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Profile; + +@SpringBootApplication +@Profile("test") +@ComponentScan(basePackages = {"org.onap.so"}, + excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)}) +public class TestApplication { + public static void main(String... args) { + SpringApplication.run(TestApplication.class, args); + System.getProperties().setProperty("mso.db", "MARIADB"); + System.getProperties().setProperty("server.name", "Springboot"); + + + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java b/so-optimization-clients/src/test/java/org/onap/so/client/oof/OofClientTestIT.java index 3ae0db627a..a54d34a944 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java +++ b/so-optimization-clients/src/test/java/org/onap/so/client/oof/OofClientTestIT.java @@ -23,7 +23,8 @@ package org.onap.so.client.oof; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static org.junit.Assert.assertEquals; +import java.util.ArrayList; +import java.util.List; import org.junit.Test; import org.onap.so.BaseIntegrationTest; import org.onap.so.client.exception.BadResponseException; @@ -40,8 +41,6 @@ import org.onap.so.client.oof.beans.SubscriberInfo; import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.beans.factory.annotation.Autowired; import com.fasterxml.jackson.core.JsonProcessingException; -import java.util.ArrayList; -import java.util.List; public class OofClientTestIT extends BaseIntegrationTest { @@ -150,7 +149,7 @@ public class OofClientTestIT extends BaseIntegrationTest { + " \"modelName\" : \"modelName\",\n" + " \"modelVersion\" : \"version\",\n" + " \"modelCustomizationName\" : \"modelCustomizationName\"\n" + " }\n" + " } ]\n" + " },\n" + " \"licenseInfo\" : { \n" + " \"licenseDemands\" : [ ]\n" + "}\n" + "}", - oofRequestOutput, false); + oofRequestOutput.replace("\r\n", "\n"), false); } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java b/so-optimization-clients/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java index 56c52388f8..56c52388f8 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java +++ b/so-optimization-clients/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java diff --git a/so-optimization-clients/src/test/resources/application-test.yaml b/so-optimization-clients/src/test/resources/application-test.yaml new file mode 100644 index 0000000000..75bd982d9b --- /dev/null +++ b/so-optimization-clients/src/test/resources/application-test.yaml @@ -0,0 +1,231 @@ +aai: + auth: 5A1272FE739BECA4D4374A86B25C021DFE6745E3BB7BE6836BF64A6059B8220E586C21FD7567AF41DB42571EB7 + endpoint: http://localhost:${wiremock.server.port} + pnfEntryNotificationTimeout: P14D +appc: + client: + key: iaEMAfjsVsZnraBP + response: + timeout: '120000' + secret: wcivUjsjXzmGFBfxMmyJu9dz + poolMembers: localhost:3904 + service: ueb + topic: + read: + name: APPC-TEST-AMDOCS2 + timeout: '120000' + write: APPC-TEST-AMDOCS1-DEV3 + sdnc: + read: SDNC-LCM-READ + write: SDNC-LCM-WRITE +log: + debug: + CompleteMsoProcess: 'true' + CreateNetworkInstanceInfra: 'true' + CreateServiceInstanceInfra: 'true' + DeleteNetworkInstanceInfra: 'true' + FalloutHandler: 'true' + UpdateNetworkInstanceInfra: 'true' + VnfAdapterRestV1: 'true' + sdncAdapter: 'true' + vnfAdapterCreateV1: 'true' + vnfAdapterRestV1: 'true' +pnf: + dmaap: + host: hostTest + port: 1234 + protocol: http + uriPathPrefix: events + topicName: pnfReady + consumerGroup: consumerGroup + consumerId: consumerId + topicListenerDelayInSeconds: 5 +mso: + naming: + endpoint: http://localhost:${wiremock.server.port}/web/service/v1/genNetworkElementName + auth: Basic YnBlbDptc28tZGItMTUwNyE= + adapters: + requestDb: + auth: Basic YnBlbDptc28tZGItMTUwNyE= + endpoint: http://localhost:8081 + completemsoprocess: + endpoint: http://localhost:${wiremock.server.port}/CompleteMsoProcess + db: + auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C + endpoint: http://localhost:${wiremock.server.port}/dbadapters/RequestsDbAdapter + spring: + endpoint: http://localhost:${wiremock.server.port} + network: + endpoint: http://localhost:${wiremock.server.port}/networks/NetworkAdapter + rest: + endpoint: http://localhost:${wiremock.server.port}/networks/rest/v1/networks + openecomp: + db: + endpoint: http://localhost:${wiremock.server.port}/dbadapters/RequestsDbAdapter + po: + auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C + password: 3141634BF7E070AA289CF2892C986C0B + sdnc: + endpoint: http://localhost:${wiremock.server.port}/SDNCAdapter + rest: + endpoint: http://localhost:${wiremock.server.port}/SDNCAdapter/v1/sdnc + timeout: PT60S + tenant: + endpoint: http://localhost:${wiremock.server.port}/tenantAdapterMock + vnf: + endpoint: http://localhost:${wiremock.server.port}/vnfs/VnfAdapter + rest: + endpoint: http://localhost:${wiremock.server.port}/services/rest/v1/vnfs + volume-groups: + rest: + endpoint: http://localhost:${wiremock.server.port}/services/rest/v1/volume-groups + vnf-async: + endpoint: http://localhost:${wiremock.server.port}/vnfs/VnfAdapterAsync + workflow: + message: + endpoint: http://localhost:${wiremock.server.port}/workflows/messages/message + + async: + core-pool-size: 50 + max-pool-size: 50 + queue-capacity: 500 + + bpmn: + optimisticlockingexception: + retrycount: '3' + cloudRegionIdsToSkipAddingVnfEdgesTo: test25Region1,test25Region2,test25Region99 + callbackRetryAttempts: '5' + catalog: + db: + endpoint: http://localhost:${wiremock.server.port}/ + spring: + endpoint: http://localhost:${wiremock.server.port} + correlation: + timeout: 60 + db: + auth: Basic YnBlbDptc28tZGItMTUwNyE= + default: + adapter: + namespace: http://org.onap.so + healthcheck: + log: + debug: 'false' + infra: + customer: + id: testCustIdInfra + logPath: logs + msoKey: 07a7159d3bf51a0e53be7a8f89699be7 + po: + timeout: PT60S + request: + db: + endpoint: http://localhost:${wiremock.server.port}/ + rollback: 'true' + site-name: localDevEnv + workflow: + default: + aai: + cloud-region: + version: '9' + generic-vnf: + version: '9' + global: + default: + aai: + namespace: http://org.openecomp.aai.inventory/ + version: '8' + message: + endpoint: http://localhost:${wiremock.server.port}/mso/WorkflowMesssage + notification: + name: GenericNotificationService + sdncadapter: + callback: http://localhost:${wiremock.server.port}/mso/SDNCAdapterCallbackService + vnfadapter: + create: + callback: http://localhost:${wiremock.server.port}/mso/vnfAdapterNotify + delete: + callback: http://localhost:${wiremock.server.port}/mso/vnfAdapterNotify + query: + callback: http://localhost:${wiremock.server.port}/mso/services/VNFAdapterQuerCallbackV1 + rollback: + callback: http://localhost:${wiremock.server.port}/mso/vnfAdapterNotify + global: + dmaap: + username: dmaapUsername + password: dmaapPassword + host: http://localhost:28090 + publisher: + topic: com.att.mso.asyncStatusUpdate +policy: + auth: Basic dGVzdHBkcDphbHBoYTEyMw== + client: + auth: Basic bTAzNzQzOnBvbGljeVIwY2sk + endpoint: https://localhost:8081/pdp/api/ + environment: TEST +sdnc: + auth: Basic YWRtaW46YWRtaW4= + host: http://localhost:${wiremock.server.port} + path: /restconf/operations/GENERIC-RESOURCE-API +sniro: + conductor: + enabled: true + host: http://localhost:${wiremock.server.port} + uri: /v1/release-orders + headers.auth: Basic dGVzdDp0ZXN0cHdk + manager: + timeout: PT30M + host: http://localhost:${wiremock.server.port} + uri.v1: /sniro/api/v2/placement + uri.v2: /sniro/api/placement/v2 + headers.auth: Basic dGVzdDp0ZXN0cHdk + headers.patchVersion: 1 + headers.minorVersion: 1 + headers.latestVersion: 2 +oof: + timeout: PT30M + host: http://localhost:${wiremock.server.port} + uri: /api/oof/v1/placement + headers.auth: Basic dGVzdDp0ZXN0cHdk +org: + onap: + so: + cloud-owner: CloudOwner +spring: + datasource: + jdbc-url: jdbc:mariadb://localhost:3307/camundabpmn + username: root + password: password + driver-class-name: org.mariadb.jdbc.Driver + initialization-mode: always + jpa: + generate-ddl: false + show-sql: false + hibernate: + ddl-auto: none + naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy + enable-lazy-load-no-trans: true + database-platform: org.hibernate.dialect.MySQL5InnoDBDialect +sdno: + health-check: + dmaap: + password: password + publisher: + topic: sdno.test-health-diagnostic-v02 + subscriber: + topic: sdno.test-health-diagnostic-v02 + username: username +mariaDB4j: + dataDir: + port: 3307 + databaseName: camundabpmn +camunda: + bpm: + metrics: + enabled: false + db-reporter-activate: false +# CDSProcessingClient +cds: + endpoint: localhost + port: 11012 + auth: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== + timeout: 60 diff --git a/so-optimization-clients/src/test/resources/schema.sql b/so-optimization-clients/src/test/resources/schema.sql new file mode 100644 index 0000000000..5ae6a2d972 --- /dev/null +++ b/so-optimization-clients/src/test/resources/schema.sql @@ -0,0 +1,1195 @@ + +USE `camundabpmn`; + + +create table ACT_GE_PROPERTY ( + NAME_ varchar(64), + VALUE_ varchar(300), + REV_ integer, + primary key (NAME_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + + +create table ACT_GE_BYTEARRAY ( + ID_ varchar(64), + REV_ integer, + NAME_ varchar(255), + DEPLOYMENT_ID_ varchar(64), + BYTES_ LONGBLOB, + GENERATED_ TINYINT, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RE_DEPLOYMENT ( + ID_ varchar(64), + NAME_ varchar(255), + DEPLOY_TIME_ timestamp(3), + SOURCE_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_EXECUTION ( + ID_ varchar(64), + REV_ integer, + PROC_INST_ID_ varchar(64), + BUSINESS_KEY_ varchar(255), + PARENT_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + SUPER_EXEC_ varchar(64), + SUPER_CASE_EXEC_ varchar(64), + CASE_INST_ID_ varchar(64), + ACT_ID_ varchar(255), + ACT_INST_ID_ varchar(64), + IS_ACTIVE_ TINYINT, + IS_CONCURRENT_ TINYINT, + IS_SCOPE_ TINYINT, + IS_EVENT_SCOPE_ TINYINT, + SUSPENSION_STATE_ integer, + CACHED_ENT_STATE_ integer, + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_JOB ( + ID_ varchar(64) NOT NULL, + REV_ integer, + TYPE_ varchar(255) NOT NULL, + LOCK_EXP_TIME_ timestamp(3) NULL, + LOCK_OWNER_ varchar(255), + EXCLUSIVE_ boolean, + EXECUTION_ID_ varchar(64), + PROCESS_INSTANCE_ID_ varchar(64), + PROCESS_DEF_ID_ varchar(64), + PROCESS_DEF_KEY_ varchar(255), + RETRIES_ integer, + EXCEPTION_STACK_ID_ varchar(64), + EXCEPTION_MSG_ varchar(4000), + DUEDATE_ timestamp(3) NULL, + REPEAT_ varchar(255), + HANDLER_TYPE_ varchar(255), + HANDLER_CFG_ varchar(4000), + DEPLOYMENT_ID_ varchar(64), + SUSPENSION_STATE_ integer NOT NULL DEFAULT 1, + JOB_DEF_ID_ varchar(64), + PRIORITY_ bigint NOT NULL DEFAULT 0, + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_JOBDEF ( + ID_ varchar(64) NOT NULL, + REV_ integer, + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + ACT_ID_ varchar(255), + JOB_TYPE_ varchar(255) NOT NULL, + JOB_CONFIGURATION_ varchar(255), + SUSPENSION_STATE_ integer, + JOB_PRIORITY_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RE_PROCDEF ( + ID_ varchar(64) not null, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) not null, + VERSION_ integer not null, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + HAS_START_FORM_KEY_ TINYINT, + SUSPENSION_STATE_ integer, + TENANT_ID_ varchar(64), + VERSION_TAG_ varchar(64), + HISTORY_TTL_ integer, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_TASK ( + ID_ varchar(64), + REV_ integer, + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_DEF_ID_ varchar(64), + NAME_ varchar(255), + PARENT_TASK_ID_ varchar(64), + DESCRIPTION_ varchar(4000), + TASK_DEF_KEY_ varchar(255), + OWNER_ varchar(255), + ASSIGNEE_ varchar(255), + DELEGATION_ varchar(64), + PRIORITY_ integer, + CREATE_TIME_ timestamp(3), + DUE_DATE_ datetime(3), + FOLLOW_UP_DATE_ datetime(3), + SUSPENSION_STATE_ integer, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_IDENTITYLINK ( + ID_ varchar(64), + REV_ integer, + GROUP_ID_ varchar(255), + TYPE_ varchar(255), + USER_ID_ varchar(255), + TASK_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_VARIABLE ( + ID_ varchar(64) not null, + REV_ integer, + TYPE_ varchar(255) not null, + NAME_ varchar(255) not null, + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + TASK_ID_ varchar(64), + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB, + TEXT2_ LONGBLOB, + VAR_SCOPE_ varchar(64) not null, + SEQUENCE_COUNTER_ bigint, + IS_CONCURRENT_LOCAL_ TINYINT, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_EVENT_SUBSCR ( + ID_ varchar(64) not null, + REV_ integer, + EVENT_TYPE_ varchar(255) not null, + EVENT_NAME_ varchar(255), + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + ACTIVITY_ID_ varchar(255), + CONFIGURATION_ varchar(255), + CREATED_ timestamp(3) not null, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_INCIDENT ( + ID_ varchar(64) not null, + REV_ integer not null, + INCIDENT_TIMESTAMP_ timestamp(3) not null, + INCIDENT_MSG_ varchar(4000), + INCIDENT_TYPE_ varchar(255) not null, + EXECUTION_ID_ varchar(64), + ACTIVITY_ID_ varchar(255), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + CAUSE_INCIDENT_ID_ varchar(64), + ROOT_CAUSE_INCIDENT_ID_ varchar(64), + CONFIGURATION_ varchar(255), + TENANT_ID_ varchar(64), + JOB_DEF_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_AUTHORIZATION ( + ID_ varchar(64) not null, + REV_ integer not null, + TYPE_ integer not null, + GROUP_ID_ varchar(255), + USER_ID_ varchar(255), + RESOURCE_TYPE_ integer not null, + RESOURCE_ID_ varchar(255), + PERMS_ integer, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_FILTER ( + ID_ varchar(64) not null, + REV_ integer not null, + RESOURCE_TYPE_ varchar(255) not null, + NAME_ varchar(255) not null, + OWNER_ varchar(255), + QUERY_ LONGTEXT not null, + PROPERTIES_ LONGTEXT, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_METER_LOG ( + ID_ varchar(64) not null, + NAME_ varchar(64) not null, + REPORTER_ varchar(255), + VALUE_ bigint, + TIMESTAMP_ timestamp(3), + MILLISECONDS_ bigint DEFAULT 0, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_EXT_TASK ( + ID_ varchar(64) not null, + REV_ integer not null, + WORKER_ID_ varchar(255), + TOPIC_NAME_ varchar(255), + RETRIES_ integer, + ERROR_MSG_ varchar(4000), + ERROR_DETAILS_ID_ varchar(64), + LOCK_EXP_TIME_ timestamp(3) NULL, + SUSPENSION_STATE_ integer, + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + ACT_ID_ varchar(255), + ACT_INST_ID_ varchar(64), + TENANT_ID_ varchar(64), + PRIORITY_ bigint NOT NULL DEFAULT 0, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_BATCH ( + ID_ varchar(64) not null, + REV_ integer not null, + TYPE_ varchar(255), + TOTAL_JOBS_ integer, + JOBS_CREATED_ integer, + JOBS_PER_SEED_ integer, + INVOCATIONS_PER_JOB_ integer, + SEED_JOB_DEF_ID_ varchar(64), + BATCH_JOB_DEF_ID_ varchar(64), + MONITOR_JOB_DEF_ID_ varchar(64), + SUSPENSION_STATE_ integer, + CONFIGURATION_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create index ACT_IDX_EXEC_BUSKEY on ACT_RU_EXECUTION(BUSINESS_KEY_); +create index ACT_IDX_EXEC_TENANT_ID on ACT_RU_EXECUTION(TENANT_ID_); +create index ACT_IDX_TASK_CREATE on ACT_RU_TASK(CREATE_TIME_); +create index ACT_IDX_TASK_ASSIGNEE on ACT_RU_TASK(ASSIGNEE_); +create index ACT_IDX_TASK_TENANT_ID on ACT_RU_TASK(TENANT_ID_); +create index ACT_IDX_IDENT_LNK_USER on ACT_RU_IDENTITYLINK(USER_ID_); +create index ACT_IDX_IDENT_LNK_GROUP on ACT_RU_IDENTITYLINK(GROUP_ID_); +create index ACT_IDX_EVENT_SUBSCR_CONFIG_ on ACT_RU_EVENT_SUBSCR(CONFIGURATION_); +create index ACT_IDX_EVENT_SUBSCR_TENANT_ID on ACT_RU_EVENT_SUBSCR(TENANT_ID_); +create index ACT_IDX_VARIABLE_TASK_ID on ACT_RU_VARIABLE(TASK_ID_); +create index ACT_IDX_VARIABLE_TENANT_ID on ACT_RU_VARIABLE(TENANT_ID_); +create index ACT_IDX_ATHRZ_PROCEDEF on ACT_RU_IDENTITYLINK(PROC_DEF_ID_); +create index ACT_IDX_INC_CONFIGURATION on ACT_RU_INCIDENT(CONFIGURATION_); +create index ACT_IDX_INC_TENANT_ID on ACT_RU_INCIDENT(TENANT_ID_); +-- CAM-5914 +create index ACT_IDX_JOB_EXECUTION_ID on ACT_RU_JOB(EXECUTION_ID_); +-- this index needs to be limited in mariadb see CAM-6938 +create index ACT_IDX_JOB_HANDLER on ACT_RU_JOB(HANDLER_TYPE_(100),HANDLER_CFG_(155)); +create index ACT_IDX_JOB_PROCINST on ACT_RU_JOB(PROCESS_INSTANCE_ID_); +create index ACT_IDX_JOB_TENANT_ID on ACT_RU_JOB(TENANT_ID_); +create index ACT_IDX_JOBDEF_TENANT_ID on ACT_RU_JOBDEF(TENANT_ID_); + +-- new metric milliseconds column +CREATE INDEX ACT_IDX_METER_LOG_MS ON ACT_RU_METER_LOG(MILLISECONDS_); +CREATE INDEX ACT_IDX_METER_LOG_NAME_MS ON ACT_RU_METER_LOG(NAME_, MILLISECONDS_); +CREATE INDEX ACT_IDX_METER_LOG_REPORT ON ACT_RU_METER_LOG(NAME_, REPORTER_, MILLISECONDS_); + +-- old metric timestamp column +CREATE INDEX ACT_IDX_METER_LOG_TIME ON ACT_RU_METER_LOG(TIMESTAMP_); +CREATE INDEX ACT_IDX_METER_LOG ON ACT_RU_METER_LOG(NAME_, TIMESTAMP_); + +create index ACT_IDX_EXT_TASK_TOPIC on ACT_RU_EXT_TASK(TOPIC_NAME_); +create index ACT_IDX_EXT_TASK_TENANT_ID on ACT_RU_EXT_TASK(TENANT_ID_); +create index ACT_IDX_EXT_TASK_PRIORITY ON ACT_RU_EXT_TASK(PRIORITY_); +create index ACT_IDX_EXT_TASK_ERR_DETAILS ON ACT_RU_EXT_TASK(ERROR_DETAILS_ID_); +create index ACT_IDX_AUTH_GROUP_ID ON ACT_RU_AUTHORIZATION(GROUP_ID_); +create index ACT_IDX_JOB_JOB_DEF_ID on ACT_RU_JOB(JOB_DEF_ID_); + +alter table ACT_GE_BYTEARRAY + add constraint ACT_FK_BYTEARR_DEPL + foreign key (DEPLOYMENT_ID_) + references ACT_RE_DEPLOYMENT (ID_); + +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION (ID_) on delete cascade on update cascade; + +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_PARENT + foreign key (PARENT_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_SUPER + foreign key (SUPER_EXEC_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_PROCDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF (ID_); + +alter table ACT_RU_IDENTITYLINK + add constraint ACT_FK_TSKASS_TASK + foreign key (TASK_ID_) + references ACT_RU_TASK (ID_); + +alter table ACT_RU_IDENTITYLINK + add constraint ACT_FK_ATHRZ_PROCEDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF(ID_); + +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_PROCDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF (ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION(ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_BYTEARRAY + foreign key (BYTEARRAY_ID_) + references ACT_GE_BYTEARRAY (ID_); + +alter table ACT_RU_JOB + add constraint ACT_FK_JOB_EXCEPTION + foreign key (EXCEPTION_STACK_ID_) + references ACT_GE_BYTEARRAY (ID_); + +alter table ACT_RU_EVENT_SUBSCR + add constraint ACT_FK_EVENT_EXEC + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION(ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_PROCDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF (ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_CAUSE + foreign key (CAUSE_INCIDENT_ID_) + references ACT_RU_INCIDENT (ID_) on delete cascade on update cascade; + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_RCAUSE + foreign key (ROOT_CAUSE_INCIDENT_ID_) + references ACT_RU_INCIDENT (ID_) on delete cascade on update cascade; + +alter table ACT_RU_EXT_TASK + add constraint ACT_FK_EXT_TASK_ERROR_DETAILS + foreign key (ERROR_DETAILS_ID_) + references ACT_GE_BYTEARRAY (ID_); + +create index ACT_IDX_INC_JOB_DEF on ACT_RU_INCIDENT(JOB_DEF_ID_); +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_JOB_DEF + foreign key (JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +alter table ACT_RU_AUTHORIZATION + add constraint ACT_UNIQ_AUTH_USER + unique (USER_ID_,TYPE_,RESOURCE_TYPE_,RESOURCE_ID_); + +alter table ACT_RU_AUTHORIZATION + add constraint ACT_UNIQ_AUTH_GROUP + unique (GROUP_ID_,TYPE_,RESOURCE_TYPE_,RESOURCE_ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_UNIQ_VARIABLE + unique (VAR_SCOPE_, NAME_); + +alter table ACT_RU_EXT_TASK + add constraint ACT_FK_EXT_TASK_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +create index ACT_IDX_BATCH_SEED_JOB_DEF ON ACT_RU_BATCH(SEED_JOB_DEF_ID_); +alter table ACT_RU_BATCH + add constraint ACT_FK_BATCH_SEED_JOB_DEF + foreign key (SEED_JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +create index ACT_IDX_BATCH_MONITOR_JOB_DEF ON ACT_RU_BATCH(MONITOR_JOB_DEF_ID_); +alter table ACT_RU_BATCH + add constraint ACT_FK_BATCH_MONITOR_JOB_DEF + foreign key (MONITOR_JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +create index ACT_IDX_BATCH_JOB_DEF ON ACT_RU_BATCH(BATCH_JOB_DEF_ID_); +alter table ACT_RU_BATCH + add constraint ACT_FK_BATCH_JOB_DEF + foreign key (BATCH_JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +-- indexes for deadlock problems - https://app.camunda.com/jira/browse/CAM-2567 -- +create index ACT_IDX_INC_CAUSEINCID on ACT_RU_INCIDENT(CAUSE_INCIDENT_ID_); +create index ACT_IDX_INC_EXID on ACT_RU_INCIDENT(EXECUTION_ID_); +create index ACT_IDX_INC_PROCDEFID on ACT_RU_INCIDENT(PROC_DEF_ID_); +create index ACT_IDX_INC_PROCINSTID on ACT_RU_INCIDENT(PROC_INST_ID_); +create index ACT_IDX_INC_ROOTCAUSEINCID on ACT_RU_INCIDENT(ROOT_CAUSE_INCIDENT_ID_); +-- index for deadlock problem - https://app.camunda.com/jira/browse/CAM-4440 -- +create index ACT_IDX_AUTH_RESOURCE_ID on ACT_RU_AUTHORIZATION(RESOURCE_ID_); +-- index to prevent deadlock on fk constraint - https://app.camunda.com/jira/browse/CAM-5440 -- +create index ACT_IDX_EXT_TASK_EXEC on ACT_RU_EXT_TASK(EXECUTION_ID_); + +-- indexes to improve deployment +create index ACT_IDX_BYTEARRAY_NAME on ACT_GE_BYTEARRAY(NAME_); +create index ACT_IDX_DEPLOYMENT_NAME on ACT_RE_DEPLOYMENT(NAME_); +create index ACT_IDX_DEPLOYMENT_TENANT_ID on ACT_RE_DEPLOYMENT(TENANT_ID_); +create index ACT_IDX_JOBDEF_PROC_DEF_ID ON ACT_RU_JOBDEF(PROC_DEF_ID_); +create index ACT_IDX_JOB_HANDLER_TYPE ON ACT_RU_JOB(HANDLER_TYPE_); +create index ACT_IDX_EVENT_SUBSCR_EVT_NAME ON ACT_RU_EVENT_SUBSCR(EVENT_NAME_); +create index ACT_IDX_PROCDEF_DEPLOYMENT_ID ON ACT_RE_PROCDEF(DEPLOYMENT_ID_); +create index ACT_IDX_PROCDEF_TENANT_ID ON ACT_RE_PROCDEF(TENANT_ID_); +create index ACT_IDX_PROCDEF_VER_TAG ON ACT_RE_PROCDEF(VERSION_TAG_); +-- create case definition table -- +create table ACT_RE_CASE_DEF ( + ID_ varchar(64) not null, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) not null, + VERSION_ integer not null, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + TENANT_ID_ varchar(64), + HISTORY_TTL_ integer, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create case execution table -- +create table ACT_RU_CASE_EXECUTION ( + ID_ varchar(64) NOT NULL, + REV_ integer, + CASE_INST_ID_ varchar(64), + SUPER_CASE_EXEC_ varchar(64), + SUPER_EXEC_ varchar(64), + BUSINESS_KEY_ varchar(255), + PARENT_ID_ varchar(64), + CASE_DEF_ID_ varchar(64), + ACT_ID_ varchar(255), + PREV_STATE_ integer, + CURRENT_STATE_ integer, + REQUIRED_ boolean, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create case sentry part table -- + +create table ACT_RU_CASE_SENTRY_PART ( + ID_ varchar(64) NOT NULL, + REV_ integer, + CASE_INST_ID_ varchar(64), + CASE_EXEC_ID_ varchar(64), + SENTRY_ID_ varchar(255), + TYPE_ varchar(255), + SOURCE_CASE_EXEC_ID_ varchar(64), + STANDARD_EVENT_ varchar(255), + SOURCE_ varchar(255), + VARIABLE_EVENT_ varchar(255), + VARIABLE_NAME_ varchar(255), + SATISFIED_ boolean, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create index on business key -- +create index ACT_IDX_CASE_EXEC_BUSKEY on ACT_RU_CASE_EXECUTION(BUSINESS_KEY_); + +-- create foreign key constraints on ACT_RU_CASE_EXECUTION -- +alter table ACT_RU_CASE_EXECUTION + add constraint ACT_FK_CASE_EXE_CASE_INST + foreign key (CASE_INST_ID_) + references ACT_RU_CASE_EXECUTION(ID_) on delete cascade on update cascade; + +alter table ACT_RU_CASE_EXECUTION + add constraint ACT_FK_CASE_EXE_PARENT + foreign key (PARENT_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +alter table ACT_RU_CASE_EXECUTION + add constraint ACT_FK_CASE_EXE_CASE_DEF + foreign key (CASE_DEF_ID_) + references ACT_RE_CASE_DEF(ID_); + +-- create foreign key constraints on ACT_RU_VARIABLE -- +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_CASE_EXE + foreign key (CASE_EXECUTION_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_CASE_INST + foreign key (CASE_INST_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +-- create foreign key constraints on ACT_RU_TASK -- +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_CASE_EXE + foreign key (CASE_EXECUTION_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_CASE_DEF + foreign key (CASE_DEF_ID_) + references ACT_RE_CASE_DEF(ID_); + +-- create foreign key constraints on ACT_RU_CASE_SENTRY_PART -- +alter table ACT_RU_CASE_SENTRY_PART + add constraint ACT_FK_CASE_SENTRY_CASE_INST + foreign key (CASE_INST_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +alter table ACT_RU_CASE_SENTRY_PART + add constraint ACT_FK_CASE_SENTRY_CASE_EXEC + foreign key (CASE_EXEC_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +create index ACT_IDX_CASE_DEF_TENANT_ID on ACT_RE_CASE_DEF(TENANT_ID_); +create index ACT_IDX_CASE_EXEC_TENANT_ID on ACT_RU_CASE_EXECUTION(TENANT_ID_); +-- create decision definition table -- +create table ACT_RE_DECISION_DEF ( + ID_ varchar(64) not null, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) not null, + VERSION_ integer not null, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + DEC_REQ_ID_ varchar(64), + DEC_REQ_KEY_ varchar(255), + TENANT_ID_ varchar(64), + HISTORY_TTL_ integer, + VERSION_TAG_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create decision requirements definition table -- +create table ACT_RE_DECISION_REQ_DEF ( + ID_ varchar(64) NOT NULL, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) NOT NULL, + VERSION_ integer NOT NULL, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +alter table ACT_RE_DECISION_DEF + add constraint ACT_FK_DEC_REQ + foreign key (DEC_REQ_ID_) + references ACT_RE_DECISION_REQ_DEF(ID_); + +create index ACT_IDX_DEC_DEF_TENANT_ID on ACT_RE_DECISION_DEF(TENANT_ID_); +create index ACT_IDX_DEC_DEF_REQ_ID on ACT_RE_DECISION_DEF(DEC_REQ_ID_); +create index ACT_IDX_DEC_REQ_DEF_TENANT_ID on ACT_RE_DECISION_REQ_DEF(TENANT_ID_); +create table ACT_HI_PROCINST ( + ID_ varchar(64) not null, + PROC_INST_ID_ varchar(64) not null, + BUSINESS_KEY_ varchar(255), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64) not null, + START_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + DURATION_ bigint, + START_USER_ID_ varchar(255), + START_ACT_ID_ varchar(255), + END_ACT_ID_ varchar(255), + SUPER_PROCESS_INSTANCE_ID_ varchar(64), + SUPER_CASE_INSTANCE_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + DELETE_REASON_ varchar(4000), + TENANT_ID_ varchar(64), + STATE_ varchar(255), + primary key (ID_), + unique (PROC_INST_ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_ACTINST ( + ID_ varchar(64) not null, + PARENT_ACT_INST_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64) not null, + PROC_INST_ID_ varchar(64) not null, + EXECUTION_ID_ varchar(64) not null, + ACT_ID_ varchar(255) not null, + TASK_ID_ varchar(64), + CALL_PROC_INST_ID_ varchar(64), + CALL_CASE_INST_ID_ varchar(64), + ACT_NAME_ varchar(255), + ACT_TYPE_ varchar(255) not null, + ASSIGNEE_ varchar(64), + START_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + DURATION_ bigint, + ACT_INST_STATE_ integer, + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_TASKINST ( + ID_ varchar(64) not null, + TASK_DEF_KEY_ varchar(255), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + NAME_ varchar(255), + PARENT_TASK_ID_ varchar(64), + DESCRIPTION_ varchar(4000), + OWNER_ varchar(255), + ASSIGNEE_ varchar(255), + START_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + DURATION_ bigint, + DELETE_REASON_ varchar(4000), + PRIORITY_ integer, + DUE_DATE_ datetime(3), + FOLLOW_UP_DATE_ datetime(3), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_VARINST ( + ID_ varchar(64) not null, + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + TASK_ID_ varchar(64), + NAME_ varchar(255) not null, + VAR_TYPE_ varchar(100), + REV_ integer, + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB, + TEXT2_ LONGBLOB, + TENANT_ID_ varchar(64), + STATE_ varchar(20), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_DETAIL ( + ID_ varchar(64) not null, + TYPE_ varchar(255) not null, + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + TASK_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + VAR_INST_ID_ varchar(64), + NAME_ varchar(255) not null, + VAR_TYPE_ varchar(255), + REV_ integer, + TIME_ datetime(3) not null, + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB, + TEXT2_ LONGBLOB, + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + OPERATION_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_IDENTITYLINK ( + ID_ varchar(64) not null, + TIMESTAMP_ timestamp(3) not null, + TYPE_ varchar(255), + USER_ID_ varchar(255), + GROUP_ID_ varchar(255), + TASK_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + OPERATION_TYPE_ varchar(64), + ASSIGNER_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_COMMENT ( + ID_ varchar(64) not null, + TYPE_ varchar(255), + TIME_ datetime(3) not null, + USER_ID_ varchar(255), + TASK_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + ACTION_ varchar(255), + MESSAGE_ varchar(4000), + FULL_MSG_ LONGBLOB, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_ATTACHMENT ( + ID_ varchar(64) not null, + REV_ integer, + USER_ID_ varchar(255), + NAME_ varchar(255), + DESCRIPTION_ varchar(4000), + TYPE_ varchar(255), + TASK_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + URL_ varchar(4000), + CONTENT_ID_ varchar(64), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_OP_LOG ( + ID_ varchar(64) not null, + DEPLOYMENT_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + TASK_ID_ varchar(64), + JOB_ID_ varchar(64), + JOB_DEF_ID_ varchar(64), + BATCH_ID_ varchar(64), + USER_ID_ varchar(255), + TIMESTAMP_ timestamp(3) not null, + OPERATION_TYPE_ varchar(64), + OPERATION_ID_ varchar(64), + ENTITY_TYPE_ varchar(30), + PROPERTY_ varchar(64), + ORG_VALUE_ varchar(4000), + NEW_VALUE_ varchar(4000), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_INCIDENT ( + ID_ varchar(64) not null, + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CREATE_TIME_ timestamp(3) not null, + END_TIME_ timestamp(3) null, + INCIDENT_MSG_ varchar(4000), + INCIDENT_TYPE_ varchar(255) not null, + ACTIVITY_ID_ varchar(255), + CAUSE_INCIDENT_ID_ varchar(64), + ROOT_CAUSE_INCIDENT_ID_ varchar(64), + CONFIGURATION_ varchar(255), + INCIDENT_STATE_ integer, + TENANT_ID_ varchar(64), + JOB_DEF_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_JOB_LOG ( + ID_ varchar(64) not null, + TIMESTAMP_ timestamp(3) not null, + JOB_ID_ varchar(64) not null, + JOB_DUEDATE_ timestamp(3) NULL, + JOB_RETRIES_ integer, + JOB_PRIORITY_ bigint NOT NULL DEFAULT 0, + JOB_EXCEPTION_MSG_ varchar(4000), + JOB_EXCEPTION_STACK_ID_ varchar(64), + JOB_STATE_ integer, + JOB_DEF_ID_ varchar(64), + JOB_DEF_TYPE_ varchar(255), + JOB_DEF_CONFIGURATION_ varchar(255), + ACT_ID_ varchar(255), + EXECUTION_ID_ varchar(64), + PROCESS_INSTANCE_ID_ varchar(64), + PROCESS_DEF_ID_ varchar(64), + PROCESS_DEF_KEY_ varchar(255), + DEPLOYMENT_ID_ varchar(64), + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_BATCH ( + ID_ varchar(64) not null, + TYPE_ varchar(255), + TOTAL_JOBS_ integer, + JOBS_PER_SEED_ integer, + INVOCATIONS_PER_JOB_ integer, + SEED_JOB_DEF_ID_ varchar(64), + MONITOR_JOB_DEF_ID_ varchar(64), + BATCH_JOB_DEF_ID_ varchar(64), + TENANT_ID_ varchar(64), + START_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_EXT_TASK_LOG ( + ID_ varchar(64) not null, + TIMESTAMP_ timestamp(3) not null, + EXT_TASK_ID_ varchar(64) not null, + RETRIES_ integer, + TOPIC_NAME_ varchar(255), + WORKER_ID_ varchar(255), + PRIORITY_ bigint NOT NULL DEFAULT 0, + ERROR_MSG_ varchar(4000), + ERROR_DETAILS_ID_ varchar(64), + ACT_ID_ varchar(255), + ACT_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + TENANT_ID_ varchar(64), + STATE_ integer, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create index ACT_IDX_HI_PRO_INST_END on ACT_HI_PROCINST(END_TIME_); +create index ACT_IDX_HI_PRO_I_BUSKEY on ACT_HI_PROCINST(BUSINESS_KEY_); +create index ACT_IDX_HI_PRO_INST_TENANT_ID on ACT_HI_PROCINST(TENANT_ID_); +create index ACT_IDX_HI_PRO_INST_PROC_DEF_KEY on ACT_HI_PROCINST(PROC_DEF_KEY_); + +create index ACT_IDX_HI_ACT_INST_START on ACT_HI_ACTINST(START_TIME_); +create index ACT_IDX_HI_ACT_INST_END on ACT_HI_ACTINST(END_TIME_); +create index ACT_IDX_HI_ACT_INST_PROCINST on ACT_HI_ACTINST(PROC_INST_ID_, ACT_ID_); +create index ACT_IDX_HI_ACT_INST_COMP on ACT_HI_ACTINST(EXECUTION_ID_, ACT_ID_, END_TIME_, ID_); +create index ACT_IDX_HI_ACT_INST_STATS on ACT_HI_ACTINST(PROC_DEF_ID_, ACT_ID_, END_TIME_, ACT_INST_STATE_); +create index ACT_IDX_HI_ACT_INST_TENANT_ID on ACT_HI_ACTINST(TENANT_ID_); +create index ACT_IDX_HI_ACT_INST_PROC_DEF_KEY on ACT_HI_ACTINST(PROC_DEF_KEY_); + +create index ACT_IDX_HI_TASK_INST_TENANT_ID on ACT_HI_TASKINST(TENANT_ID_); +create index ACT_IDX_HI_TASK_INST_PROC_DEF_KEY on ACT_HI_TASKINST(PROC_DEF_KEY_); +create index ACT_IDX_HI_TASKINST_PROCINST on ACT_HI_TASKINST(PROC_INST_ID_); +create index ACT_IDX_HI_TASKINSTID_PROCINST on ACT_HI_TASKINST(ID_,PROC_INST_ID_); + +create index ACT_IDX_HI_DETAIL_PROC_INST on ACT_HI_DETAIL(PROC_INST_ID_); +create index ACT_IDX_HI_DETAIL_ACT_INST on ACT_HI_DETAIL(ACT_INST_ID_); +create index ACT_IDX_HI_DETAIL_CASE_INST on ACT_HI_DETAIL(CASE_INST_ID_); +create index ACT_IDX_HI_DETAIL_CASE_EXEC on ACT_HI_DETAIL(CASE_EXECUTION_ID_); +create index ACT_IDX_HI_DETAIL_TIME on ACT_HI_DETAIL(TIME_); +create index ACT_IDX_HI_DETAIL_NAME on ACT_HI_DETAIL(NAME_); +create index ACT_IDX_HI_DETAIL_TASK_ID on ACT_HI_DETAIL(TASK_ID_); +create index ACT_IDX_HI_DETAIL_TENANT_ID on ACT_HI_DETAIL(TENANT_ID_); +create index ACT_IDX_HI_DETAIL_PROC_DEF_KEY on ACT_HI_DETAIL(PROC_DEF_KEY_); +create index ACT_IDX_HI_DETAIL_BYTEAR on ACT_HI_DETAIL(BYTEARRAY_ID_); + +create index ACT_IDX_HI_IDENT_LNK_USER on ACT_HI_IDENTITYLINK(USER_ID_); +create index ACT_IDX_HI_IDENT_LNK_GROUP on ACT_HI_IDENTITYLINK(GROUP_ID_); +create index ACT_IDX_HI_IDENT_LNK_TENANT_ID on ACT_HI_IDENTITYLINK(TENANT_ID_); +create index ACT_IDX_HI_IDENT_LNK_PROC_DEF_KEY on ACT_HI_IDENTITYLINK(PROC_DEF_KEY_); +create index ACT_IDX_HI_IDENT_LINK_TASK on ACT_HI_IDENTITYLINK(TASK_ID_); + +create index ACT_IDX_HI_PROCVAR_PROC_INST on ACT_HI_VARINST(PROC_INST_ID_); +create index ACT_IDX_HI_PROCVAR_NAME_TYPE on ACT_HI_VARINST(NAME_, VAR_TYPE_); +create index ACT_IDX_HI_CASEVAR_CASE_INST on ACT_HI_VARINST(CASE_INST_ID_); +create index ACT_IDX_HI_VAR_INST_TENANT_ID on ACT_HI_VARINST(TENANT_ID_); +create index ACT_IDX_HI_VAR_INST_PROC_DEF_KEY on ACT_HI_VARINST(PROC_DEF_KEY_); +create index ACT_IDX_HI_VARINST_BYTEAR on ACT_HI_VARINST(BYTEARRAY_ID_); + +create index ACT_IDX_HI_INCIDENT_TENANT_ID on ACT_HI_INCIDENT(TENANT_ID_); +create index ACT_IDX_HI_INCIDENT_PROC_DEF_KEY on ACT_HI_INCIDENT(PROC_DEF_KEY_); +create index ACT_IDX_HI_INCIDENT_PROCINST on ACT_HI_INCIDENT(PROC_INST_ID_); + +create index ACT_IDX_HI_JOB_LOG_PROCINST on ACT_HI_JOB_LOG(PROCESS_INSTANCE_ID_); +create index ACT_IDX_HI_JOB_LOG_PROCDEF on ACT_HI_JOB_LOG(PROCESS_DEF_ID_); +create index ACT_IDX_HI_JOB_LOG_TENANT_ID on ACT_HI_JOB_LOG(TENANT_ID_); +create index ACT_IDX_HI_JOB_LOG_JOB_DEF_ID on ACT_HI_JOB_LOG(JOB_DEF_ID_); +create index ACT_IDX_HI_JOB_LOG_PROC_DEF_KEY on ACT_HI_JOB_LOG(PROCESS_DEF_KEY_); +create index ACT_IDX_HI_JOB_LOG_EX_STACK on ACT_HI_JOB_LOG(JOB_EXCEPTION_STACK_ID_); + +create index ACT_HI_EXT_TASK_LOG_PROCINST on ACT_HI_EXT_TASK_LOG(PROC_INST_ID_); +create index ACT_HI_EXT_TASK_LOG_PROCDEF on ACT_HI_EXT_TASK_LOG(PROC_DEF_ID_); +create index ACT_HI_EXT_TASK_LOG_PROC_DEF_KEY on ACT_HI_EXT_TASK_LOG(PROC_DEF_KEY_); +create index ACT_HI_EXT_TASK_LOG_TENANT_ID on ACT_HI_EXT_TASK_LOG(TENANT_ID_); +create index ACT_IDX_HI_EXTTASKLOG_ERRORDET on ACT_HI_EXT_TASK_LOG(ERROR_DETAILS_ID_); + +create index ACT_IDX_HI_OP_LOG_PROCINST on ACT_HI_OP_LOG(PROC_INST_ID_); +create index ACT_IDX_HI_OP_LOG_PROCDEF on ACT_HI_OP_LOG(PROC_DEF_ID_); + +create index ACT_IDX_HI_COMMENT_TASK on ACT_HI_COMMENT(TASK_ID_); +create index ACT_IDX_HI_COMMENT_PROCINST on ACT_HI_COMMENT(PROC_INST_ID_); + +create index ACT_IDX_HI_ATTACHMENT_CONTENT on ACT_HI_ATTACHMENT(CONTENT_ID_); +create index ACT_IDX_HI_ATTACHMENT_PROCINST on ACT_HI_ATTACHMENT(PROC_INST_ID_); +create index ACT_IDX_HI_ATTACHMENT_TASK on ACT_HI_ATTACHMENT(TASK_ID_); +create table ACT_HI_CASEINST ( + ID_ varchar(64) not null, + CASE_INST_ID_ varchar(64) not null, + BUSINESS_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64) not null, + CREATE_TIME_ datetime(3) not null, + CLOSE_TIME_ datetime(3), + DURATION_ bigint, + STATE_ integer, + CREATE_USER_ID_ varchar(255), + SUPER_CASE_INSTANCE_ID_ varchar(64), + SUPER_PROCESS_INSTANCE_ID_ varchar(64), + TENANT_ID_ varchar(64), + primary key (ID_), + unique (CASE_INST_ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_CASEACTINST ( + ID_ varchar(64) not null, + PARENT_ACT_INST_ID_ varchar(64), + CASE_DEF_ID_ varchar(64) not null, + CASE_INST_ID_ varchar(64) not null, + CASE_ACT_ID_ varchar(255) not null, + TASK_ID_ varchar(64), + CALL_PROC_INST_ID_ varchar(64), + CALL_CASE_INST_ID_ varchar(64), + CASE_ACT_NAME_ varchar(255), + CASE_ACT_TYPE_ varchar(255), + CREATE_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + DURATION_ bigint, + STATE_ integer, + REQUIRED_ boolean, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create index ACT_IDX_HI_CAS_I_CLOSE on ACT_HI_CASEINST(CLOSE_TIME_); +create index ACT_IDX_HI_CAS_I_BUSKEY on ACT_HI_CASEINST(BUSINESS_KEY_); +create index ACT_IDX_HI_CAS_I_TENANT_ID on ACT_HI_CASEINST(TENANT_ID_); +create index ACT_IDX_HI_CAS_A_I_CREATE on ACT_HI_CASEACTINST(CREATE_TIME_); +create index ACT_IDX_HI_CAS_A_I_END on ACT_HI_CASEACTINST(END_TIME_); +create index ACT_IDX_HI_CAS_A_I_COMP on ACT_HI_CASEACTINST(CASE_ACT_ID_, END_TIME_, ID_); +create index ACT_IDX_HI_CAS_A_I_CASEINST on ACT_HI_CASEACTINST(CASE_INST_ID_, CASE_ACT_ID_); +create index ACT_IDX_HI_CAS_A_I_TENANT_ID on ACT_HI_CASEACTINST(TENANT_ID_); +-- create history decision instance table -- +create table ACT_HI_DECINST ( + ID_ varchar(64) NOT NULL, + DEC_DEF_ID_ varchar(64) NOT NULL, + DEC_DEF_KEY_ varchar(255) NOT NULL, + DEC_DEF_NAME_ varchar(255), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + ACT_ID_ varchar(255), + EVAL_TIME_ datetime(3) not null, + COLLECT_VALUE_ double, + USER_ID_ varchar(255), + ROOT_DEC_INST_ID_ varchar(64), + DEC_REQ_ID_ varchar(64), + DEC_REQ_KEY_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create history decision input table -- +create table ACT_HI_DEC_IN ( + ID_ varchar(64) NOT NULL, + DEC_INST_ID_ varchar(64) NOT NULL, + CLAUSE_ID_ varchar(64), + CLAUSE_NAME_ varchar(255), + VAR_TYPE_ varchar(100), + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB, + TEXT2_ LONGBLOB, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create history decision output table -- +create table ACT_HI_DEC_OUT ( + ID_ varchar(64) NOT NULL, + DEC_INST_ID_ varchar(64) NOT NULL, + CLAUSE_ID_ varchar(64), + CLAUSE_NAME_ varchar(255), + RULE_ID_ varchar(64), + RULE_ORDER_ integer, + VAR_NAME_ varchar(255), + VAR_TYPE_ varchar(100), + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB, + TEXT2_ LONGBLOB, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + + +create index ACT_IDX_HI_DEC_INST_ID on ACT_HI_DECINST(DEC_DEF_ID_); +create index ACT_IDX_HI_DEC_INST_KEY on ACT_HI_DECINST(DEC_DEF_KEY_); +create index ACT_IDX_HI_DEC_INST_PI on ACT_HI_DECINST(PROC_INST_ID_); +create index ACT_IDX_HI_DEC_INST_CI on ACT_HI_DECINST(CASE_INST_ID_); +create index ACT_IDX_HI_DEC_INST_ACT on ACT_HI_DECINST(ACT_ID_); +create index ACT_IDX_HI_DEC_INST_ACT_INST on ACT_HI_DECINST(ACT_INST_ID_); +create index ACT_IDX_HI_DEC_INST_TIME on ACT_HI_DECINST(EVAL_TIME_); +create index ACT_IDX_HI_DEC_INST_TENANT_ID on ACT_HI_DECINST(TENANT_ID_); +create index ACT_IDX_HI_DEC_INST_ROOT_ID on ACT_HI_DECINST(ROOT_DEC_INST_ID_); +create index ACT_IDX_HI_DEC_INST_REQ_ID on ACT_HI_DECINST(DEC_REQ_ID_); +create index ACT_IDX_HI_DEC_INST_REQ_KEY on ACT_HI_DECINST(DEC_REQ_KEY_); + + +create index ACT_IDX_HI_DEC_IN_INST on ACT_HI_DEC_IN(DEC_INST_ID_); +create index ACT_IDX_HI_DEC_IN_CLAUSE on ACT_HI_DEC_IN(DEC_INST_ID_, CLAUSE_ID_); + +create index ACT_IDX_HI_DEC_OUT_INST on ACT_HI_DEC_OUT(DEC_INST_ID_); +create index ACT_IDX_HI_DEC_OUT_RULE on ACT_HI_DEC_OUT(RULE_ORDER_, CLAUSE_ID_); + +-- mariadb_identity_7.8.0-ee + +create table ACT_ID_GROUP ( + ID_ varchar(64), + REV_ integer, + NAME_ varchar(255), + TYPE_ varchar(255), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_MEMBERSHIP ( + USER_ID_ varchar(64), + GROUP_ID_ varchar(64), + primary key (USER_ID_, GROUP_ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_USER ( + ID_ varchar(64), + REV_ integer, + FIRST_ varchar(255), + LAST_ varchar(255), + EMAIL_ varchar(255), + PWD_ varchar(255), + SALT_ varchar(255), + PICTURE_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_INFO ( + ID_ varchar(64), + REV_ integer, + USER_ID_ varchar(64), + TYPE_ varchar(64), + KEY_ varchar(255), + VALUE_ varchar(255), + PASSWORD_ LONGBLOB, + PARENT_ID_ varchar(255), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_TENANT ( + ID_ varchar(64), + REV_ integer, + NAME_ varchar(255), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_TENANT_MEMBER ( + ID_ varchar(64) not null, + TENANT_ID_ varchar(64) not null, + USER_ID_ varchar(64), + GROUP_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +alter table ACT_ID_MEMBERSHIP + add constraint ACT_FK_MEMB_GROUP + foreign key (GROUP_ID_) + references ACT_ID_GROUP (ID_); + +alter table ACT_ID_MEMBERSHIP + add constraint ACT_FK_MEMB_USER + foreign key (USER_ID_) + references ACT_ID_USER (ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_UNIQ_TENANT_MEMB_USER + unique (TENANT_ID_, USER_ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_UNIQ_TENANT_MEMB_GROUP + unique (TENANT_ID_, GROUP_ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_FK_TENANT_MEMB + foreign key (TENANT_ID_) + references ACT_ID_TENANT (ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_FK_TENANT_MEMB_USER + foreign key (USER_ID_) + references ACT_ID_USER (ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_FK_TENANT_MEMB_GROUP + foreign key (GROUP_ID_) + references ACT_ID_GROUP (ID_); + +ALTER TABLE ACT_GE_BYTEARRAY + ADD TYPE_ integer; + +ALTER TABLE ACT_GE_BYTEARRAY + ADD CREATE_TIME_ datetime(3); + +ALTER TABLE ACT_RE_PROCDEF + ADD STARTABLE_ BOOLEAN NOT NULL DEFAULT TRUE;
\ No newline at end of file diff --git a/so-sdn-clients/pom.xml b/so-sdn-clients/pom.xml new file mode 100644 index 0000000000..905c76d7ad --- /dev/null +++ b/so-sdn-clients/pom.xml @@ -0,0 +1,173 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.onap.so</groupId> + <artifactId>so</artifactId> + <version>1.7.1-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <artifactId>so-sdn-clients</artifactId> + <properties> + <sdnc.northbound.version>1.5.2</sdnc.northbound.version> + </properties> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <executions> + <execution> + <id>default-test</id> + <goals> + <goal>test</goal> + </goals> + <configuration> + <includes> + <include>**/UnitTestSuite.java</include> + </includes> + </configuration> + </execution> + <execution> + <id>integration-test</id> + <goals> + <goal>test</goal> + </goals> + <configuration> + <includes> + <include>**/IntegrationTestSuite.java</include> + </includes> + </configuration> + </execution> + </executions> + <configuration> + <parallel>suites</parallel> + </configuration> + </plugin> + </plugins> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <versionRange>[1.0.0,)</versionRange> + <goals> + <goal>unpack</goal> + </goals> + </pluginExecutionFilter> + <action> + <execute /> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> + <dependencyManagement> + <dependencies> + <dependency> + <!-- Import dependency management from Spring Boot --> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-dependencies</artifactId> + <version>${springboot.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + <dependencies> + <dependency> + <groupId>org.camunda.bpm.springboot</groupId> + <artifactId>camunda-bpm-spring-boot-starter</artifactId> + <version>${camunda.springboot.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.cloud</groupId> + <artifactId>spring-cloud-contract-wiremock</artifactId> + <version>1.2.4.RELEASE</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.onap.sdnc.northbound</groupId> + <artifactId>generic-resource-api-client</artifactId> + <version>${sdnc.northbound.version}</version> + <exclusions> + <exclusion> + <groupId>javax.ws.rs</groupId> + <artifactId>jsr311-api</artifactId> + </exclusion> + <exclusion> + <groupId>io.swagger</groupId> + <artifactId>swagger-annotations</artifactId> + </exclusion> + <exclusion> + <groupId>io.swagger</groupId> + <artifactId>swagger-models</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>ch.vorburger.mariaDB4j</groupId> + <artifactId>mariaDB4j</artifactId> + <version>2.2.3</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.6</version> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-configuration-processor</artifactId> + <optional>true</optional> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>common</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>aai-client</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.mariadb.jdbc</groupId> + <artifactId>mariadb-java-client</artifactId> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-common</artifactId> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-client</artifactId> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.inject</groupId> + <artifactId>jersey-hk2</artifactId> + <version>2.26</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.media</groupId> + <artifactId>jersey-media-json-jackson</artifactId> + </dependency> + </dependencies> +</project> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/SDNCClient.java index 7d2fc10d0b..7d2fc10d0b 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/SDNCClient.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java index 01ac675d83..01ac675d83 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java index 15076fa45a..15076fa45a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java index 2c8bdd931c..2c8bdd931c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java index d6216c509d..d6216c509d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java index 4edbf37bad..4edbf37bad 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java index ae9fe6ad70..ae9fe6ad70 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java index 9b857dc08c..9b857dc08c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidator.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOValidator.java index 83624dec63..d4af90267d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidator.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOValidator.java @@ -22,7 +22,6 @@ package org.onap.so.client.sdno; import java.io.IOException; import java.util.UUID; -import org.onap.aai.domain.yang.GenericVnf; public interface SDNOValidator { @@ -38,18 +37,4 @@ public interface SDNOValidator { */ public boolean healthDiagnostic(String vnfId, UUID uuid, String requestingUserId) throws IOException, Exception; - - /** - * Issues a health diagnostic request for a given GenericVnf to SDN-O - * - * @param genericVnf - * @param uuid - * @param requestingUserId - * @return diagnostic result - * @throws IOException - * @throws Exception - */ - public boolean healthDiagnostic(GenericVnf genericVnf, UUID uuid, String requestingUserId) - throws IOException, Exception; - } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java index 9fc95a6f3f..d2a87db70a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java @@ -61,18 +61,6 @@ public class SDNOValidatorImpl implements SDNOValidator { return status; } - @Override - public boolean healthDiagnostic(GenericVnf genericVnf, UUID uuid, String requestingUserId) - throws IOException, Exception { - - SDNO requestDiagnostic = buildRequestDiagnostic(genericVnf, uuid, requestingUserId); - ObjectMapper mapper = new ObjectMapper(); - String json = mapper.writeValueAsString(requestDiagnostic); - this.submitRequest(json); - boolean status = this.pollForResponse(uuid.toString()); - return status; - } - protected SDNO buildRequestDiagnostic(GenericVnf vnf, UUID uuid, String requestingUserId) { Optional<String> nfRole; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java index 7e98355b4d..7e98355b4d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Body.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/Body.java index 8c40b749a6..8c40b749a6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Body.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/Body.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Input.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/Input.java index c8122c06f6..c8122c06f6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Input.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/Input.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java index 485f64673f..485f64673f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java index b1b75ab412..b1b75ab412 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java index 8b84cf6659..8b84cf6659 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/SDNO.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/SDNO.java index 46e2c1d1fc..46e2c1d1fc 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/SDNO.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/SDNO.java diff --git a/so-sdn-clients/src/test/java/org/onap/so/BaseIntegrationTest.java b/so-sdn-clients/src/test/java/org/onap/so/BaseIntegrationTest.java new file mode 100644 index 0000000000..9c25b1f002 --- /dev/null +++ b/so-sdn-clients/src/test/java/org/onap/so/BaseIntegrationTest.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so; + +import java.io.IOException; +import java.io.InputStream; +import org.junit.Before; +import org.junit.runner.RunWith; +import org.onap.so.client.sdnc.SDNCClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.SpyBean; +import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; +import com.github.tomakehurst.wiremock.WireMockServer; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +@ContextConfiguration +@AutoConfigureWireMock(port = 0) +public abstract class BaseIntegrationTest { + + @Value("${wiremock.server.port}") + protected String wireMockPort; + + @SpyBean + protected SDNCClient SPY_sdncClient; + + @Autowired + protected WireMockServer wireMockServer; + + @Before + public void baseTestBefore() { + wireMockServer.resetAll(); + } + +} + + diff --git a/so-sdn-clients/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java b/so-sdn-clients/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java new file mode 100644 index 0000000000..62d9ecee44 --- /dev/null +++ b/so-sdn-clients/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so; + +import ch.vorburger.exec.ManagedProcessException; +import ch.vorburger.mariadb4j.DBConfigurationBuilder; +import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.jdbc.DataSourceBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import javax.sql.DataSource; + +@Configuration +@Profile({"test"}) +public class EmbeddedMariaDbConfig { + + @Bean + MariaDB4jSpringService mariaDB4jSpringService() { + MariaDB4jSpringService service = new MariaDB4jSpringService(); + + + service.getConfiguration().addArg("--lower_case_table_names=1"); + return service; + } + + @Bean + DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService, + @Value("${mariaDB4j.databaseName}") String databaseName, + @Value("${spring.datasource.username}") String datasourceUsername, + @Value("${spring.datasource.password}") String datasourcePassword, + @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException { + // Create our database with default root user and no password + mariaDB4jSpringService.getDB().createDB(databaseName); + + DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration(); + + return DataSourceBuilder.create().username(datasourceUsername).password(datasourcePassword) + .url(config.getURL(databaseName)).driverClassName(datasourceDriver).build(); + } +} diff --git a/so-sdn-clients/src/test/java/org/onap/so/IntegrationTestSuite.java b/so-sdn-clients/src/test/java/org/onap/so/IntegrationTestSuite.java new file mode 100644 index 0000000000..50bbc1845f --- /dev/null +++ b/so-sdn-clients/src/test/java/org/onap/so/IntegrationTestSuite.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so; + +import org.junit.runner.RunWith; +import com.googlecode.junittoolbox.SuiteClasses; +import com.googlecode.junittoolbox.WildcardPatternSuite; + +@RunWith(WildcardPatternSuite.class) +@SuiteClasses({"**/*IT.class"}) +public class IntegrationTestSuite { + +} diff --git a/so-sdn-clients/src/test/java/org/onap/so/TestApplication.java b/so-sdn-clients/src/test/java/org/onap/so/TestApplication.java new file mode 100644 index 0000000000..fe965b4444 --- /dev/null +++ b/so-sdn-clients/src/test/java/org/onap/so/TestApplication.java @@ -0,0 +1,43 @@ +package org.onap.so; +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + + + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.ComponentScan.Filter; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Profile; + +@SpringBootApplication +@Profile("test") +@ComponentScan(basePackages = {"org.onap.so"}, + excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)}) +public class TestApplication { + public static void main(String... args) { + SpringApplication.run(TestApplication.class, args); + System.getProperties().setProperty("mso.db", "MARIADB"); + System.getProperties().setProperty("server.name", "Springboot"); + + + } +} diff --git a/so-sdn-clients/src/test/java/org/onap/so/UnitTestSuite.java b/so-sdn-clients/src/test/java/org/onap/so/UnitTestSuite.java new file mode 100644 index 0000000000..890c81daeb --- /dev/null +++ b/so-sdn-clients/src/test/java/org/onap/so/UnitTestSuite.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so; + + +import org.junit.runner.RunWith; +import com.googlecode.junittoolbox.SuiteClasses; +import com.googlecode.junittoolbox.WildcardPatternSuite; + +@RunWith(WildcardPatternSuite.class) +@SuiteClasses({"**/*Test.class"}) +public class UnitTestSuite { + +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java b/so-sdn-clients/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java index a8816e1b04..a8816e1b04 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java +++ b/so-sdn-clients/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java b/so-sdn-clients/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java index 0b338bde1d..0b338bde1d 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java +++ b/so-sdn-clients/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java b/so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java index 750e578558..7345b8161b 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java +++ b/so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java @@ -33,7 +33,7 @@ public class SDNOHealthCheckClientTest { - private final String fileLocation = "src/test/resources/org/onap/so/client/sdno/health-check/"; + private final String fileLocation = "src/test/resources/__files/sdno/health-check/"; private static final String userId = "test-user"; private static final Optional<String> clliCode = Optional.of("test-clli"); private static final String requestId = "test-request-id"; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorIT.java b/so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOValidatorIT.java index b91f83c1b7..8d2993ec43 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorIT.java +++ b/so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOValidatorIT.java @@ -55,7 +55,7 @@ public class SDNOValidatorIT extends BaseIntegrationTest { @Mock private Consumer mrConsumer; private SDNOHealthCheckDmaapConsumer dmaapConsumer; - private final String fileLocation = "src/test/resources/org/onap/so/client/sdno/"; + private final String fileLocation = "src/test/resources/__files/sdno/client/"; private final String uuid = "xyz123"; @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorImplTest.java b/so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOValidatorImplTest.java index c2278c26f9..c2278c26f9 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorImplTest.java +++ b/so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOValidatorImplTest.java diff --git a/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiEcompModelInformation.json b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiEcompModelInformation.json new file mode 100644 index 0000000000..9c50c2f11b --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiEcompModelInformation.json @@ -0,0 +1,7 @@ +{ + "model-name" : "modelName", + "model-version" : "modelVersion", + "model-customization-uuid" : null, + "model-uuid" : "modelUuid", + "model-invariant-uuid" : "modelInvariantUuid" +}
\ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformation.json b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformation.json new file mode 100644 index 0000000000..91d64b98ca --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformation.json @@ -0,0 +1,54 @@ +{ + "service-information" : { + "onap-model-information" : { + "model-name" : "modelName", + "model-version" : "modelVersion", + "model-customization-uuid" : null, + "model-uuid" : "modelUuid", + "model-invariant-uuid" : "modelInvariantUuid" + }, + "subscriber-name" : null, + "subscription-service-type" : "productFamilyId", + "service-id" : null, + "global-customer-id" : "globalCustomerId", + "service-instance-id" : null + }, + "network-request-input" : { + "aic-clli" : null, + "aic-cloud-region" : null, + "tenant" : null, + "network-input-parameters" : { + "param" : [ { + "name" : "key1", + "value" : "value1" + } ] + }, + "network-name" : "TEST_NETWORK_NAME", + "network-instance-group-id" : "networkInstanceGroupId" + }, + "request-information" : { + "notification-url" : null, + "order-version" : null, + "request-action" : "CreateNetworkInstance", + "source" : "MSO", + "request-id" : "sdncReqId", + "order-number" : null + }, + "sdnc-request-header" : { + "svc-request-id" : "svcRequestId", + "svc-notification-url" : null, + "svc-action" : "assign" + }, + "network-information" : { + "onap-model-information" : { + "model-name" : "modelName", + "model-version" : "modelVersion", + "model-customization-uuid" : "modelCustomizationUUID", + "model-uuid" : "modelUuid", + "model-invariant-uuid" : "modelInvariantUuid" + }, + "from-preload": null, + "network-id" : "TEST_NETWORK_ID", + "network-type" : null + } +}
\ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformationNoNetworkName.json b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformationNoNetworkName.json new file mode 100644 index 0000000000..95a2af3880 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformationNoNetworkName.json @@ -0,0 +1,53 @@ +{ + "service-information" : { + "onap-model-information" : { + "model-name" : "modelName", + "model-version" : "modelVersion", + "model-customization-uuid" : null, + "model-uuid" : "modelUuid", + "model-invariant-uuid" : "modelInvariantUuid" + }, + "subscriber-name" : null, + "subscription-service-type" : "productFamilyId", + "service-id" : null, + "global-customer-id" : "globalCustomerId", + "service-instance-id" : null + }, + "network-request-input" : { + "aic-clli" : null, + "aic-cloud-region" : null, + "tenant" : null, + "network-input-parameters" : { + "param" : [ { + "name" : "key1", + "value" : "value1" + } ] + }, + "network-instance-group-id" : "networkInstanceGroupId" + }, + "request-information" : { + "notification-url" : null, + "order-version" : null, + "request-action" : "CreateNetworkInstance", + "source" : "MSO", + "request-id" : "sdncReqId", + "order-number" : null + }, + "sdnc-request-header" : { + "svc-request-id" : "svcRequestId", + "svc-notification-url" : null, + "svc-action" : "assign" + }, + "network-information" : { + "onap-model-information" : { + "model-name" : "modelName", + "model-version" : "modelVersion", + "model-customization-uuid" : "modelCustomizationUUID", + "model-uuid" : "modelUuid", + "model-invariant-uuid" : "modelInvariantUuid" + }, + "from-preload": null, + "network-id" : "TEST_NETWORK_ID", + "network-type" : null + } +}
\ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformationUnAssign.json b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformationUnAssign.json new file mode 100644 index 0000000000..a7cf1e1434 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformationUnAssign.json @@ -0,0 +1,54 @@ +{ + "service-information" : { + "onap-model-information" : { + "model-name" : "modelName", + "model-version" : "modelVersion", + "model-customization-uuid" : null, + "model-uuid" : "modelUuid", + "model-invariant-uuid" : "modelInvariantUuid" + }, + "subscriber-name" : null, + "subscription-service-type" : "productFamilyId", + "service-id" : null, + "global-customer-id" : "globalCustomerId", + "service-instance-id" : null + }, + "network-request-input" : { + "aic-clli" : null, + "aic-cloud-region" : null, + "tenant" : null, + "network-input-parameters" : { + "param" : [ { + "name" : "key1", + "value" : "value1" + } ] + }, + "network-name" : "TEST_NETWORK_NAME", + "network-instance-group-id" : "networkInstanceGroupId" + }, + "request-information" : { + "notification-url" : null, + "order-version" : null, + "request-action" : "DeleteNetworkInstance", + "source" : "MSO", + "request-id" : "sdncReqId", + "order-number" : null + }, + "sdnc-request-header" : { + "svc-request-id" : "svcRequestId", + "svc-notification-url" : null, + "svc-action" : "unassign" + }, + "network-information" : { + "onap-model-information" : { + "model-name" : "modelName", + "model-version" : "modelVersion", + "model-customization-uuid" : "modelCustomizationUUID", + "model-uuid" : "modelUuid", + "model-invariant-uuid" : "modelInvariantUuid" + }, + "from-preload": null, + "network-id" : "TEST_NETWORK_ID", + "network-type" : null + } +}
\ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationAssign.json b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationAssign.json new file mode 100644 index 0000000000..53c1997126 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationAssign.json @@ -0,0 +1,74 @@ +{ + "service-information" : { + "onap-model-information" : { + "model-name" : "serviceModelName", + "model-version" : "serviceModelVersion", + "model-customization-uuid" : null, + "model-uuid" : "serviceModelUuid", + "model-invariant-uuid" : "serviceModelInvariantUuid" + }, + "subscriber-name" : null, + "subscription-service-type" : "productFamilyId", + "service-id" : "serviceInstanceId", + "global-customer-id" : "globalCustomerId", + "service-instance-id" : "serviceInstanceId" + }, + "vf-module-request-input" : { + "aic-clli" : null, + "aic-cloud-region" : null, + "tenant" : null, + "vf-module-input-parameters" : { + "param" : [ { + "name" : "key1", + "value" : "value1" + }, + { + "name" : "key2", + "value" : "value2" + }, + { + "name" : "volume-group-id", + "value" : "volumeGroupId" + } ] + }, + "vf-module-name" : "testVfModuleName" + }, + "request-information" : { + "request-action" : "CreateVfModuleInstance", + "source" : "MSO", + "request-id" : "sdncReqId", + "order-number" : null, + "order-version" : null, + "notification-url" : null + }, + "sdnc-request-header" : { + "svc-request-id" : "svcRequestId", + "svc-notification-url" : "http://localhost:8080", + "svc-action" : "assign" + }, + "vf-module-information" : { + "onap-model-information" : { + "model-name" : "vfModuleModelName", + "model-version" : "vfModuleModelVersion", + "model-customization-uuid" : "vfModuleModelCustomizationUuid", + "model-uuid" : "vfModuleModelUuid", + "model-invariant-uuid" : "vfModuleModelInvariantUuid" + }, + "vf-module-id" : "testVfModuleId", + "from-preload" : true, + "vf-module-type": "vfModuleModelName" + + }, + "vnf-information" : { + "onap-model-information" : { + "model-name" : "vnfModelName", + "model-version" : "vnfModelVersion", + "model-customization-uuid" : "vnfModelCustomizationUuid", + "model-uuid" : "vnfModelUuid", + "model-invariant-uuid" : "vnfModelInvariantUuid" + }, + "vnf-id" : "testVnfId", + "vnf-type" : "testVnfType", + "vnf-name" : "testVnfName" + } +}
\ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationUnassign.json b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationUnassign.json new file mode 100644 index 0000000000..9f93c0df1f --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationUnassign.json @@ -0,0 +1,31 @@ +{ + "service-information" : { + "service-instance-id" : "serviceInstanceId", + "service-id" : "serviceInstanceId" + }, + "vf-module-request-input" : { + "vf-module-name" : "testVfModuleName", + "vf-module-input-parameters" : {} + }, + "request-information" : { + "request-action" : "DeleteVfModuleInstance", + "source" : "MSO", + "request-id" : "sdncReqId", + "order-number" : null, + "order-version" : null, + "notification-url" : null + }, + "sdnc-request-header" : { + "svc-request-id" : "svcRequestId", + "svc-notification-url" : "http://localhost:8080", + "svc-action" : "unassign" + }, + "vf-module-information" : { + "vf-module-id" : "testVfModuleId", + "from-preload": true + }, + "vnf-information" : { + "vnf-id" : "testVnfId", + "vnf-type" : "testVnfType" + } +}
\ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientGetResponse.json b/so-sdn-clients/src/test/resources/__files/SDNCClientGetResponse.json new file mode 100644 index 0000000000..a18b6aa54e --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientGetResponse.json @@ -0,0 +1,27 @@ +{ + "vnf-topology": { + "tenant": "0422ffb57ba042c0800a29dc85ca70f8", + "vnf-topology-identifier-structure": { + "vnf-id": "66dac89b-2a5b-4cb9-b22e-a7e4488fb3db", + "vnf-type": "InfraMSO_vSAMP10a_Service/InfraMSO_vSAMP10a-2 0", + "vnf-name": "MSO-DEV-VNF-1806HF1-InfraMSO_vSAMP10a-1XXX-GR_21" + }, + "aic-clli": "AUSTTXGR", + "vnf-resource-assignments": { + "availability-zones": { + "availability-zone": [ + "AZ-MN02" + ], + "max-count": 1 + } + }, + "aic-cloud-region": "mtn6", + "onap-model-information": { + "model-customization-uuid": "034226ae-879a-46b5-855c-d02babcb6cb6", + "model-uuid": "cb79c25f-b30d-4d95-afb5-97be4021f3db", + "model-invariant-uuid": "e93d3a7a-446d-486b-ae48-d474a9156064", + "model-name": "InfraMSO_vSAMP10a-2", + "model-version": "1.0" + } + } +}
\ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponse.json b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponse.json new file mode 100644 index 0000000000..0de25616e3 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponse.json @@ -0,0 +1,127 @@ +{ + "vnf-preload-list": [ + { + "vnf-name": "GENERIC_VNF_NAME", + "vnf-type": "SIMPLE", + "preload-data": + { + "network-topology-information": + { + }, + "vnf-topology-information": + { + "vnf-topology-identifier": + { + "service-type": "vCPE", + "vnf-type": "SIMPLE", + "vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-type": "SIMPLE" + }, + "vnf-parameters": [ + { + "vnf-parameter-name": "extra_console", + "vnf-parameter-value": "ttyS1" + }, + { + "vnf-parameter-name": "vnfUsername", + "vnf-parameter-value": "vnf_user" + }, + { + "vnf-parameter-name": "additionalParams", + "vnf-parameter-value": "{\"image_id\": \"DUMMYVNF\",\"instance_type\": \"m1.small\",\"ftp_address\": \"ftp://0.0.0.0:2100/\"}" + }, + { + "vnf-parameter-name": "fsb_admin_gateway_ip_1", + "vnf-parameter-value": "0.0.0.0" + }, + { + "vnf-parameter-name": "availability_zone_1" + }, + { + "vnf-parameter-name": "fsb_admin_gateway_ip_2" + }, + { + "vnf-parameter-name": "fsb_admin_prefix_length", + "vnf-parameter-value": "28" + }, + { + "vnf-parameter-name": "ONAPMME_OMCN_vLC_P4_prefix_length", + "vnf-parameter-value": "28" + }, + { + "vnf-parameter-name": "gpbs", + "vnf-parameter-value": "2" + }, + { + "vnf-parameter-name": "fsb_admin_ip_2", + "vnf-parameter-value": "192.0.0.1" + }, + { + "vnf-parameter-name": "internal_mtu", + "vnf-parameter-value": "1500" + }, + { + "vnf-parameter-name": "storage_drbd_sync_rate", + "vnf-parameter-value": "0" + }, + { + "vnf-parameter-name": "ONAPMME_MEDIA_vLC_P3_net_id", + "vnf-parameter-value": "ONAPMME_MEDIA_vLC_P3" + }, + { + "vnf-parameter-name": "extVirtualLinks", + "vnf-parameter-value": "[{\"id\":\"ac1ed33d-8dc1-4800-8ce8-309b99c38eec\",\"tenant\":{\"cloudOwner\":\"CloudOwner\",\"regionName\":\"RegionOne\",\"tenantId\":\"80c26954-2536-4bca-9e20-10f8a2c9c2ad\"},\"resourceId\":\"8ef8cd54-75fd-4372-a6dd-2e05ea8fbd9b\",\"extCps\":[{\"cpdId\":\"f449292f-2f0f-4656-baa3-a18d86bac80f\",\"cpConfig\":[{\"cpInstanceId\":\"07876709-b66f-465c-99a7-0f4d026197f2\",\"linkPortId\":null,\"cpProtocolData\":null}]}],\"extLinkPorts\":null}]" + }, + { + "vnf-parameter-name": "vnfIpAddress", + "vnf-parameter-value": "127.0.0.0" + }, + { + "vnf-parameter-name": "node_type", + "vnf-parameter-value": "sgsnl" + }, + { + "vnf-parameter-name": "ONAPMME_SIG_vLC_P2_net_id", + "vnf-parameter-value": "ONAPMME_SIG_vLC_P2" + }, + { + "vnf-parameter-name": "updateOss", + "vnf-parameter-value": "false" + }, + { + "vnf-parameter-name": "tmo", + "vnf-parameter-value": "0" + }, + { + "vnf-parameter-name": "ss7", + "vnf-parameter-value": "Not_Applicable" + }, + { + "vnf-parameter-name": "ONAPMME_OMCN_vLC_P4_net_id", + "vnf-parameter-value": "ONAPMME_OMCN_vLC_P4" + }, + { + "vnf-parameter-name": "key_name" + }, + { + "vnf-parameter-name": "fsb_admin_dns_server_ip_2" + }, + { + "vnf-parameter-name": "time_zone", + "vnf-parameter-value": "GMT" + }, + { + "vnf-parameter-name": "enableRollback", + "vnf-parameter-value": "false" + } + ] + }, + "oper-status": + { + "order-status": "PendingAssignment" + } + } + } + ] +} diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidAdditionalAndExtVmData.json b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidAdditionalAndExtVmData.json new file mode 100644 index 0000000000..c2cf2b2f28 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidAdditionalAndExtVmData.json @@ -0,0 +1,47 @@ +{ + "vnf-preload-list": [ + { + "vnf-name": "GENERIC_VNF_NAME", + "vnf-type": "SIMPLE", + "preload-data": + { + "network-topology-information": + { + }, + "vnf-topology-information": + { + "vnf-topology-identifier": + { + "service-type": "vCPE", + "vnf-type": "SIMPLE", + "vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-type": "SIMPLE" + }, + "vnf-parameters": [ + { + "vnf-parameter-name": "extra_console", + "vnf-parameter-value": "ttyS1" + }, + { + "vnf-parameter-name": "vnfUsername", + "vnf-parameter-value": "vnf_user" + }, + { + "vnf-parameter-name": "additionalParams", + "vnf-parameter-value": "[\"abc\"]" + }, + { + "vnf-parameter-name": "extVirtualLinks", + "vnf-parameter-value": "{\"def\":\"123\"}" + } + ] + }, + "oper-status": + { + "order-status": "PendingAssignment" + } + } + } + ] +} diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidData.json b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidData.json new file mode 100644 index 0000000000..552adb9125 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidData.json @@ -0,0 +1,39 @@ +{ + "vnf-preload-list": [ + { + "vnf-name": "GENERIC_VNF_NAME", + "vnf-type": "SIMPLE", + "preload-data": + { + "network-topology-information": + { + }, + "vnf-topology-information": + { + "vnf-topology-identifier": + { + "service-type": "vCPE", + "vnf-type": "SIMPLE", + "vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-type": "SIMPLE" + }, + "vnf-parameters": [ + { + "vnf-parameter-name": "extra_console", + "vnf-parameter-value": "ttyS1" + }, + { + "vnf-parameter-name": "vnfUsername", + "vnf-parameter-value": "vnf_user" + } + ] + }, + "oper-status": + { + "order-status": "PendingAssignment" + } + } + } + ] +} diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidVnfParamsTag.json b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidVnfParamsTag.json new file mode 100644 index 0000000000..e19ad1c9d3 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidVnfParamsTag.json @@ -0,0 +1,34 @@ +{ + "vnf-preload-list": [ + { + "vnf-name": "GENERIC_VNF_NAME", + "vnf-type": "SIMPLE", + "preload-data": + { + "network-topology-information": + { + }, + "vnf-topology-information": + { + "vnf-topology-identifier": + { + "service-type": "vCPE", + "vnf-type": "SIMPLE", + "vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-type": "SIMPLE" + }, + "vnf-parameters": [ + { + "hello": "world" + } + ] + }, + "oper-status": + { + "order-status": "PendingAssignment" + } + } + } + ] +} diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientPut200Response.json b/so-sdn-clients/src/test/resources/__files/SDNCClientPut200Response.json new file mode 100644 index 0000000000..286ce4c844 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientPut200Response.json @@ -0,0 +1,15 @@ +{ + "output": { + "svc-request-id": "5d24d40e-4c77-4c06-94a3-6d168c47a57c", + "network-response-information": { + "instance-id": "4063e0aa-af13-4872-8473-b40c94f9316b", + "object-path": "restconf/config/GENERIC-RESOURCE-API:services/service/2c9c7996-75a7-4f92-becc-9e13e8bd288a/service-data/networks/network/4063e0aa-af13-4872-8473-b40c94f9316b/network-data/network-topology/" + }, + "response-code": "200", + "service-response-information": { + "instance-id": "2c9c7996-75a7-4f92-becc-9e13e8bd288a" + }, + "response-message": "", + "ack-final-indicator": "Y" + } +} diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientPut200ResponseNotFinal.json b/so-sdn-clients/src/test/resources/__files/SDNCClientPut200ResponseNotFinal.json new file mode 100644 index 0000000000..deb4de0219 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientPut200ResponseNotFinal.json @@ -0,0 +1,15 @@ +{ + "output": { + "svc-request-id": "5d24d40e-4c77-4c06-94a3-6d168c47a57c", + "network-response-information": { + "instance-id": "4063e0aa-af13-4872-8473-b40c94f9316b", + "object-path": "restconf/config/GENERIC-RESOURCE-API:services/service/2c9c7996-75a7-4f92-becc-9e13e8bd288a/service-data/networks/network/4063e0aa-af13-4872-8473-b40c94f9316b/network-data/network-topology/" + }, + "response-code": "200", + "service-response-information": { + "instance-id": "2c9c7996-75a7-4f92-becc-9e13e8bd288a" + }, + "response-message": "", + "ack-final-indicator": "N" + } +} diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientPut404Response.json b/so-sdn-clients/src/test/resources/__files/SDNCClientPut404Response.json new file mode 100644 index 0000000000..cf0254886d --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientPut404Response.json @@ -0,0 +1,8 @@ +{ + "output": { + "svc-request-id": "086a7a09-1470-4977-8b3e-307488b8811a", + "response-code": "404", + "response-message": "invalid input: the service-instance does not have any service data in SDNC", + "ack-final-indicator": "Y" + } +} diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientResponseIncorrectPath.json b/so-sdn-clients/src/test/resources/__files/SDNCClientResponseIncorrectPath.json new file mode 100644 index 0000000000..7e263b4465 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientResponseIncorrectPath.json @@ -0,0 +1,29 @@ +{ + "vnf-topology": { + "tenant": "0422ffb57ba042c0800a29dc85ca70f8", + "vnf-topology-identifier-structure": { + "vnf-id": "66dac89b-2a5b-4cb9-b22e-a7e4488fb3db", + "vnf-type": "InfraMSO_vSAMP10a_Service/InfraMSO_vSAMP10a-2 0", + "vnf-name": "MSO-DEV-VNF-1806HF1-InfraMSO_vSAMP10a-1XXX-GR_21" + }, + "aic-clli": "AUSTTXGR", + "vnf-resource-assignments": { + "availability-zones": { + "availability-zone": [ + { + "test":"AZ-MN02" + } + ], + "max-count": 1 + } + }, + "aic-cloud-region": "mtn6", + "onap-model-information": { + "model-customization-uuid": "034226ae-879a-46b5-855c-d02babcb6cb6", + "model-uuid": "cb79c25f-b30d-4d95-afb5-97be4021f3db", + "model-invariant-uuid": "e93d3a7a-446d-486b-ae48-d474a9156064", + "model-name": "InfraMSO_vSAMP10a-2", + "model-version": "1.0" + } + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-failure.json b/so-sdn-clients/src/test/resources/__files/sdno/client/output-failure.json index 8cf0a820cd..8cf0a820cd 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-failure.json +++ b/so-sdn-clients/src/test/resources/__files/sdno/client/output-failure.json diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-success.json b/so-sdn-clients/src/test/resources/__files/sdno/client/output-success.json index a6794327d8..a6794327d8 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-success.json +++ b/so-sdn-clients/src/test/resources/__files/sdno/client/output-success.json diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/response.json b/so-sdn-clients/src/test/resources/__files/sdno/client/response.json index 2355e86938..2355e86938 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/response.json +++ b/so-sdn-clients/src/test/resources/__files/sdno/client/response.json diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-post-check-request.json b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-lport-mirror-post-check-request.json index 2c46b5a8cb..2c46b5a8cb 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-post-check-request.json +++ b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-lport-mirror-post-check-request.json diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-pre-check-request.json b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-lport-mirror-pre-check-request.json index bf168b0028..bf168b0028 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-pre-check-request.json +++ b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-lport-mirror-pre-check-request.json diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-post-check-request.json b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-port-mirror-post-check-request.json index 89e505e7d0..89e505e7d0 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-post-check-request.json +++ b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-port-mirror-post-check-request.json diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-pre-check-request.json b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-port-mirror-pre-check-request.json index 86897c8a1f..86897c8a1f 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-pre-check-request.json +++ b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-port-mirror-pre-check-request.json diff --git a/so-sdn-clients/src/test/resources/application-test.yaml b/so-sdn-clients/src/test/resources/application-test.yaml new file mode 100644 index 0000000000..b64fc3318b --- /dev/null +++ b/so-sdn-clients/src/test/resources/application-test.yaml @@ -0,0 +1,231 @@ +aai: + auth: 5A1272FE739BECA4D4374A86B25C021DFE6745E3BB7BE6836BF64A6059B8220E586C21FD7567AF41DB42571EB7 + endpoint: http://localhost:${wiremock.server.port} + pnfEntryNotificationTimeout: P14D +appc: + client: + key: iaEMAfjsVsZnraBP + response: + timeout: '120000' + secret: wcivUjsjXzmGFBfxMmyJu9dz + poolMembers: localhost:3904 + service: ueb + topic: + read: + name: APPC-TEST-AMDOCS2 + timeout: '120000' + write: APPC-TEST-AMDOCS1-DEV3 + sdnc: + read: SDNC-LCM-READ + write: SDNC-LCM-WRITE +log: + debug: + CompleteMsoProcess: 'true' + CreateNetworkInstanceInfra: 'true' + CreateServiceInstanceInfra: 'true' + DeleteNetworkInstanceInfra: 'true' + FalloutHandler: 'true' + UpdateNetworkInstanceInfra: 'true' + VnfAdapterRestV1: 'true' + sdncAdapter: 'true' + vnfAdapterCreateV1: 'true' + vnfAdapterRestV1: 'true' +pnf: + dmaap: + host: hostTest + port: 1234 + protocol: http + uriPathPrefix: events + topicName: pnfReady + consumerGroup: consumerGroup + consumerId: consumerId + topicListenerDelayInSeconds: 5 +mso: + naming: + endpoint: http://localhost:${wiremock.server.port}/web/service/v1/genNetworkElementName + auth: Basic YnBlbDptc28tZGItMTUwNyE= + adapters: + requestDb: + auth: Basic YnBlbDptc28tZGItMTUwNyE= + endpoint: http://localhost:8081 + completemsoprocess: + endpoint: http://localhost:${wiremock.server.port}/CompleteMsoProcess + db: + auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C + endpoint: http://localhost:${wiremock.server.port}/dbadapters/RequestsDbAdapter + spring: + endpoint: http://localhost:${wiremock.server.port} + network: + endpoint: http://localhost:${wiremock.server.port}/networks/NetworkAdapter + rest: + endpoint: http://localhost:${wiremock.server.port}/networks/rest/v1/networks + openecomp: + db: + endpoint: http://localhost:${wiremock.server.port}/dbadapters/RequestsDbAdapter + po: + auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C + password: 3141634BF7E070AA289CF2892C986C0B + sdnc: + endpoint: http://localhost:${wiremock.server.port}/SDNCAdapter + rest: + endpoint: http://localhost:${wiremock.server.port}/SDNCAdapter/v1/sdnc + timeout: PT60S + tenant: + endpoint: http://localhost:${wiremock.server.port}/tenantAdapterMock + vnf: + endpoint: http://localhost:${wiremock.server.port}/vnfs/VnfAdapter + rest: + endpoint: http://localhost:${wiremock.server.port}/services/rest/v1/vnfs + volume-groups: + rest: + endpoint: http://localhost:${wiremock.server.port}/services/rest/v1/volume-groups + vnf-async: + endpoint: http://localhost:${wiremock.server.port}/vnfs/VnfAdapterAsync + workflow: + message: + endpoint: http://localhost:${wiremock.server.port}/workflows/messages/message + + async: + core-pool-size: 50 + max-pool-size: 50 + queue-capacity: 500 + + bpmn: + optimisticlockingexception: + retrycount: '3' + cloudRegionIdsToSkipAddingVnfEdgesTo: test25Region1,test25Region2,test25Region99 + callbackRetryAttempts: '5' + catalog: + db: + endpoint: http://localhost:${wiremock.server.port}/ + spring: + endpoint: http://localhost:${wiremock.server.port} + correlation: + timeout: 60 + db: + auth: Basic YnBlbDptc28tZGItMTUwNyE= + default: + adapter: + namespace: http://org.onap.so + healthcheck: + log: + debug: 'false' + infra: + customer: + id: testCustIdInfra + logPath: logs + msoKey: 07a7159d3bf51a0e53be7a8f89699be7 + po: + timeout: PT60S + request: + db: + endpoint: http://localhost:${wiremock.server.port}/ + rollback: 'true' + site-name: localDevEnv + workflow: + default: + aai: + cloud-region: + version: '9' + generic-vnf: + version: '9' + global: + default: + aai: + namespace: http://org.openecomp.aai.inventory/ + version: '8' + message: + endpoint: http://localhost:${wiremock.server.port}/mso/WorkflowMesssage + notification: + name: GenericNotificationService + sdncadapter: + callback: http://localhost:${wiremock.server.port}/mso/SDNCAdapterCallbackService + vnfadapter: + create: + callback: http://localhost:${wiremock.server.port}/mso/vnfAdapterNotify + delete: + callback: http://localhost:${wiremock.server.port}/mso/vnfAdapterNotify + query: + callback: http://localhost:${wiremock.server.port}/mso/services/VNFAdapterQuerCallbackV1 + rollback: + callback: http://localhost:${wiremock.server.port}/mso/vnfAdapterNotify + global: + dmaap: + username: dmaapUsername + password: dmaapPassword + host: http://localhost:28090 + publisher: + topic: com.att.mso.asyncStatusUpdate +policy: + auth: Basic dGVzdHBkcDphbHBoYTEyMw== + client: + auth: Basic bTAzNzQzOnBvbGljeVIwY2sk + endpoint: https://localhost:8081/pdp/api/ + environment: TEST +sdnc: + auth: Basic YWRtaW46YWRtaW4= + host: http://localhost:${wiremock.server.port} + path: /restconf/operations/GENERIC-RESOURCE-API +sniro: + conductor: + enabled: true + host: http://localhost:${wiremock.server.port} + uri: /v1/release-orders + headers.auth: Basic dGVzdDp0ZXN0cHdk + manager: + timeout: PT30M + host: http://localhost:${wiremock.server.port} + uri.v1: /sniro/api/v2/placement + uri.v2: /sniro/api/placement/v2 + headers.auth: Basic dGVzdDp0ZXN0cHdk + headers.patchVersion: 1 + headers.minorVersion: 1 + headers.latestVersion: 2 +oof: + timeout: PT30M + host: http://localhost:${wiremock.server.port} + uri: /api/oof/v1/placement + headers.auth: Basic dGVzdDp0ZXN0cHdk +org: + onap: + so: + cloud-owner: att-aic +spring: + datasource: + jdbc-url: jdbc:mariadb://localhost:3307/camundabpmn + username: root + password: password + driver-class-name: org.mariadb.jdbc.Driver + initialization-mode: always + jpa: + generate-ddl: false + show-sql: false + hibernate: + ddl-auto: none + naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy + enable-lazy-load-no-trans: true + database-platform: org.hibernate.dialect.MySQL5InnoDBDialect +sdno: + health-check: + dmaap: + password: password + publisher: + topic: sdno.test-health-diagnostic-v02 + subscriber: + topic: sdno.test-health-diagnostic-v02 + username: username +mariaDB4j: + dataDir: + port: 3307 + databaseName: camundabpmn +camunda: + bpm: + metrics: + enabled: false + db-reporter-activate: false +# CDSProcessingClient +cds: + endpoint: localhost + port: 11012 + auth: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== + timeout: 60 diff --git a/so-sdn-clients/src/test/resources/dmaap.properties b/so-sdn-clients/src/test/resources/dmaap.properties new file mode 100644 index 0000000000..5593455da3 --- /dev/null +++ b/so-sdn-clients/src/test/resources/dmaap.properties @@ -0,0 +1,10 @@ +sdno.health-check.dmaap.username=testuser +sdno.health-check.dmaap.password=eHQ1cUJrOUc +sdno.health-check.dmaap.subscriber.topic=com.att.sdno.test-health-diagnostic-v02 +sdno.health-check.dmaap.publisher.topic=com.att.sdno.test-health-diagnostic-v02 +ruby.create-ticket-request.dmaap.username=testuser +ruby.create-ticket-request.dmaap.password=eHQ1cUJrOUc +ruby.create-ticket-request.publisher.topic=com.att.pdas.st1.msoCMFallout-v1 +ruby.create-ticket-request.dmaap.auth=81B7E3533B91A6706830611FB9A8ECE529BBCCE754B1F1520FA7C8698B42F97235BEFA993A387E664D6352C63A6185D68DA7F0B1D360637CBA102CB166E3E62C11EB1F75386D3506BCECE51E54 +sdno.health-check.dmaap.auth=81B7E3533B91A6706830611FB9A8ECE529BBCCE754B1F1520FA7C8698B42F97235BEFA993A387E664D6352C63A6185D68DA7F0B1D360637CBA102CB166E3E62C11EB1F75386D3506BCECE51E54 +mso.msoKey=07a7159d3bf51a0e53be7a8f89699be7
\ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/schema.sql b/so-sdn-clients/src/test/resources/schema.sql new file mode 100644 index 0000000000..5ae6a2d972 --- /dev/null +++ b/so-sdn-clients/src/test/resources/schema.sql @@ -0,0 +1,1195 @@ + +USE `camundabpmn`; + + +create table ACT_GE_PROPERTY ( + NAME_ varchar(64), + VALUE_ varchar(300), + REV_ integer, + primary key (NAME_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + + +create table ACT_GE_BYTEARRAY ( + ID_ varchar(64), + REV_ integer, + NAME_ varchar(255), + DEPLOYMENT_ID_ varchar(64), + BYTES_ LONGBLOB, + GENERATED_ TINYINT, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RE_DEPLOYMENT ( + ID_ varchar(64), + NAME_ varchar(255), + DEPLOY_TIME_ timestamp(3), + SOURCE_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_EXECUTION ( + ID_ varchar(64), + REV_ integer, + PROC_INST_ID_ varchar(64), + BUSINESS_KEY_ varchar(255), + PARENT_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + SUPER_EXEC_ varchar(64), + SUPER_CASE_EXEC_ varchar(64), + CASE_INST_ID_ varchar(64), + ACT_ID_ varchar(255), + ACT_INST_ID_ varchar(64), + IS_ACTIVE_ TINYINT, + IS_CONCURRENT_ TINYINT, + IS_SCOPE_ TINYINT, + IS_EVENT_SCOPE_ TINYINT, + SUSPENSION_STATE_ integer, + CACHED_ENT_STATE_ integer, + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_JOB ( + ID_ varchar(64) NOT NULL, + REV_ integer, + TYPE_ varchar(255) NOT NULL, + LOCK_EXP_TIME_ timestamp(3) NULL, + LOCK_OWNER_ varchar(255), + EXCLUSIVE_ boolean, + EXECUTION_ID_ varchar(64), + PROCESS_INSTANCE_ID_ varchar(64), + PROCESS_DEF_ID_ varchar(64), + PROCESS_DEF_KEY_ varchar(255), + RETRIES_ integer, + EXCEPTION_STACK_ID_ varchar(64), + EXCEPTION_MSG_ varchar(4000), + DUEDATE_ timestamp(3) NULL, + REPEAT_ varchar(255), + HANDLER_TYPE_ varchar(255), + HANDLER_CFG_ varchar(4000), + DEPLOYMENT_ID_ varchar(64), + SUSPENSION_STATE_ integer NOT NULL DEFAULT 1, + JOB_DEF_ID_ varchar(64), + PRIORITY_ bigint NOT NULL DEFAULT 0, + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_JOBDEF ( + ID_ varchar(64) NOT NULL, + REV_ integer, + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + ACT_ID_ varchar(255), + JOB_TYPE_ varchar(255) NOT NULL, + JOB_CONFIGURATION_ varchar(255), + SUSPENSION_STATE_ integer, + JOB_PRIORITY_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RE_PROCDEF ( + ID_ varchar(64) not null, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) not null, + VERSION_ integer not null, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + HAS_START_FORM_KEY_ TINYINT, + SUSPENSION_STATE_ integer, + TENANT_ID_ varchar(64), + VERSION_TAG_ varchar(64), + HISTORY_TTL_ integer, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_TASK ( + ID_ varchar(64), + REV_ integer, + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_DEF_ID_ varchar(64), + NAME_ varchar(255), + PARENT_TASK_ID_ varchar(64), + DESCRIPTION_ varchar(4000), + TASK_DEF_KEY_ varchar(255), + OWNER_ varchar(255), + ASSIGNEE_ varchar(255), + DELEGATION_ varchar(64), + PRIORITY_ integer, + CREATE_TIME_ timestamp(3), + DUE_DATE_ datetime(3), + FOLLOW_UP_DATE_ datetime(3), + SUSPENSION_STATE_ integer, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_IDENTITYLINK ( + ID_ varchar(64), + REV_ integer, + GROUP_ID_ varchar(255), + TYPE_ varchar(255), + USER_ID_ varchar(255), + TASK_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_VARIABLE ( + ID_ varchar(64) not null, + REV_ integer, + TYPE_ varchar(255) not null, + NAME_ varchar(255) not null, + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + TASK_ID_ varchar(64), + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB, + TEXT2_ LONGBLOB, + VAR_SCOPE_ varchar(64) not null, + SEQUENCE_COUNTER_ bigint, + IS_CONCURRENT_LOCAL_ TINYINT, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_EVENT_SUBSCR ( + ID_ varchar(64) not null, + REV_ integer, + EVENT_TYPE_ varchar(255) not null, + EVENT_NAME_ varchar(255), + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + ACTIVITY_ID_ varchar(255), + CONFIGURATION_ varchar(255), + CREATED_ timestamp(3) not null, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_INCIDENT ( + ID_ varchar(64) not null, + REV_ integer not null, + INCIDENT_TIMESTAMP_ timestamp(3) not null, + INCIDENT_MSG_ varchar(4000), + INCIDENT_TYPE_ varchar(255) not null, + EXECUTION_ID_ varchar(64), + ACTIVITY_ID_ varchar(255), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + CAUSE_INCIDENT_ID_ varchar(64), + ROOT_CAUSE_INCIDENT_ID_ varchar(64), + CONFIGURATION_ varchar(255), + TENANT_ID_ varchar(64), + JOB_DEF_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_AUTHORIZATION ( + ID_ varchar(64) not null, + REV_ integer not null, + TYPE_ integer not null, + GROUP_ID_ varchar(255), + USER_ID_ varchar(255), + RESOURCE_TYPE_ integer not null, + RESOURCE_ID_ varchar(255), + PERMS_ integer, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_FILTER ( + ID_ varchar(64) not null, + REV_ integer not null, + RESOURCE_TYPE_ varchar(255) not null, + NAME_ varchar(255) not null, + OWNER_ varchar(255), + QUERY_ LONGTEXT not null, + PROPERTIES_ LONGTEXT, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_METER_LOG ( + ID_ varchar(64) not null, + NAME_ varchar(64) not null, + REPORTER_ varchar(255), + VALUE_ bigint, + TIMESTAMP_ timestamp(3), + MILLISECONDS_ bigint DEFAULT 0, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_EXT_TASK ( + ID_ varchar(64) not null, + REV_ integer not null, + WORKER_ID_ varchar(255), + TOPIC_NAME_ varchar(255), + RETRIES_ integer, + ERROR_MSG_ varchar(4000), + ERROR_DETAILS_ID_ varchar(64), + LOCK_EXP_TIME_ timestamp(3) NULL, + SUSPENSION_STATE_ integer, + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + ACT_ID_ varchar(255), + ACT_INST_ID_ varchar(64), + TENANT_ID_ varchar(64), + PRIORITY_ bigint NOT NULL DEFAULT 0, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_BATCH ( + ID_ varchar(64) not null, + REV_ integer not null, + TYPE_ varchar(255), + TOTAL_JOBS_ integer, + JOBS_CREATED_ integer, + JOBS_PER_SEED_ integer, + INVOCATIONS_PER_JOB_ integer, + SEED_JOB_DEF_ID_ varchar(64), + BATCH_JOB_DEF_ID_ varchar(64), + MONITOR_JOB_DEF_ID_ varchar(64), + SUSPENSION_STATE_ integer, + CONFIGURATION_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create index ACT_IDX_EXEC_BUSKEY on ACT_RU_EXECUTION(BUSINESS_KEY_); +create index ACT_IDX_EXEC_TENANT_ID on ACT_RU_EXECUTION(TENANT_ID_); +create index ACT_IDX_TASK_CREATE on ACT_RU_TASK(CREATE_TIME_); +create index ACT_IDX_TASK_ASSIGNEE on ACT_RU_TASK(ASSIGNEE_); +create index ACT_IDX_TASK_TENANT_ID on ACT_RU_TASK(TENANT_ID_); +create index ACT_IDX_IDENT_LNK_USER on ACT_RU_IDENTITYLINK(USER_ID_); +create index ACT_IDX_IDENT_LNK_GROUP on ACT_RU_IDENTITYLINK(GROUP_ID_); +create index ACT_IDX_EVENT_SUBSCR_CONFIG_ on ACT_RU_EVENT_SUBSCR(CONFIGURATION_); +create index ACT_IDX_EVENT_SUBSCR_TENANT_ID on ACT_RU_EVENT_SUBSCR(TENANT_ID_); +create index ACT_IDX_VARIABLE_TASK_ID on ACT_RU_VARIABLE(TASK_ID_); +create index ACT_IDX_VARIABLE_TENANT_ID on ACT_RU_VARIABLE(TENANT_ID_); +create index ACT_IDX_ATHRZ_PROCEDEF on ACT_RU_IDENTITYLINK(PROC_DEF_ID_); +create index ACT_IDX_INC_CONFIGURATION on ACT_RU_INCIDENT(CONFIGURATION_); +create index ACT_IDX_INC_TENANT_ID on ACT_RU_INCIDENT(TENANT_ID_); +-- CAM-5914 +create index ACT_IDX_JOB_EXECUTION_ID on ACT_RU_JOB(EXECUTION_ID_); +-- this index needs to be limited in mariadb see CAM-6938 +create index ACT_IDX_JOB_HANDLER on ACT_RU_JOB(HANDLER_TYPE_(100),HANDLER_CFG_(155)); +create index ACT_IDX_JOB_PROCINST on ACT_RU_JOB(PROCESS_INSTANCE_ID_); +create index ACT_IDX_JOB_TENANT_ID on ACT_RU_JOB(TENANT_ID_); +create index ACT_IDX_JOBDEF_TENANT_ID on ACT_RU_JOBDEF(TENANT_ID_); + +-- new metric milliseconds column +CREATE INDEX ACT_IDX_METER_LOG_MS ON ACT_RU_METER_LOG(MILLISECONDS_); +CREATE INDEX ACT_IDX_METER_LOG_NAME_MS ON ACT_RU_METER_LOG(NAME_, MILLISECONDS_); +CREATE INDEX ACT_IDX_METER_LOG_REPORT ON ACT_RU_METER_LOG(NAME_, REPORTER_, MILLISECONDS_); + +-- old metric timestamp column +CREATE INDEX ACT_IDX_METER_LOG_TIME ON ACT_RU_METER_LOG(TIMESTAMP_); +CREATE INDEX ACT_IDX_METER_LOG ON ACT_RU_METER_LOG(NAME_, TIMESTAMP_); + +create index ACT_IDX_EXT_TASK_TOPIC on ACT_RU_EXT_TASK(TOPIC_NAME_); +create index ACT_IDX_EXT_TASK_TENANT_ID on ACT_RU_EXT_TASK(TENANT_ID_); +create index ACT_IDX_EXT_TASK_PRIORITY ON ACT_RU_EXT_TASK(PRIORITY_); +create index ACT_IDX_EXT_TASK_ERR_DETAILS ON ACT_RU_EXT_TASK(ERROR_DETAILS_ID_); +create index ACT_IDX_AUTH_GROUP_ID ON ACT_RU_AUTHORIZATION(GROUP_ID_); +create index ACT_IDX_JOB_JOB_DEF_ID on ACT_RU_JOB(JOB_DEF_ID_); + +alter table ACT_GE_BYTEARRAY + add constraint ACT_FK_BYTEARR_DEPL + foreign key (DEPLOYMENT_ID_) + references ACT_RE_DEPLOYMENT (ID_); + +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION (ID_) on delete cascade on update cascade; + +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_PARENT + foreign key (PARENT_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_SUPER + foreign key (SUPER_EXEC_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_PROCDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF (ID_); + +alter table ACT_RU_IDENTITYLINK + add constraint ACT_FK_TSKASS_TASK + foreign key (TASK_ID_) + references ACT_RU_TASK (ID_); + +alter table ACT_RU_IDENTITYLINK + add constraint ACT_FK_ATHRZ_PROCEDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF(ID_); + +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_PROCDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF (ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION(ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_BYTEARRAY + foreign key (BYTEARRAY_ID_) + references ACT_GE_BYTEARRAY (ID_); + +alter table ACT_RU_JOB + add constraint ACT_FK_JOB_EXCEPTION + foreign key (EXCEPTION_STACK_ID_) + references ACT_GE_BYTEARRAY (ID_); + +alter table ACT_RU_EVENT_SUBSCR + add constraint ACT_FK_EVENT_EXEC + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION(ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_PROCDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF (ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_CAUSE + foreign key (CAUSE_INCIDENT_ID_) + references ACT_RU_INCIDENT (ID_) on delete cascade on update cascade; + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_RCAUSE + foreign key (ROOT_CAUSE_INCIDENT_ID_) + references ACT_RU_INCIDENT (ID_) on delete cascade on update cascade; + +alter table ACT_RU_EXT_TASK + add constraint ACT_FK_EXT_TASK_ERROR_DETAILS + foreign key (ERROR_DETAILS_ID_) + references ACT_GE_BYTEARRAY (ID_); + +create index ACT_IDX_INC_JOB_DEF on ACT_RU_INCIDENT(JOB_DEF_ID_); +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_JOB_DEF + foreign key (JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +alter table ACT_RU_AUTHORIZATION + add constraint ACT_UNIQ_AUTH_USER + unique (USER_ID_,TYPE_,RESOURCE_TYPE_,RESOURCE_ID_); + +alter table ACT_RU_AUTHORIZATION + add constraint ACT_UNIQ_AUTH_GROUP + unique (GROUP_ID_,TYPE_,RESOURCE_TYPE_,RESOURCE_ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_UNIQ_VARIABLE + unique (VAR_SCOPE_, NAME_); + +alter table ACT_RU_EXT_TASK + add constraint ACT_FK_EXT_TASK_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +create index ACT_IDX_BATCH_SEED_JOB_DEF ON ACT_RU_BATCH(SEED_JOB_DEF_ID_); +alter table ACT_RU_BATCH + add constraint ACT_FK_BATCH_SEED_JOB_DEF + foreign key (SEED_JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +create index ACT_IDX_BATCH_MONITOR_JOB_DEF ON ACT_RU_BATCH(MONITOR_JOB_DEF_ID_); +alter table ACT_RU_BATCH + add constraint ACT_FK_BATCH_MONITOR_JOB_DEF + foreign key (MONITOR_JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +create index ACT_IDX_BATCH_JOB_DEF ON ACT_RU_BATCH(BATCH_JOB_DEF_ID_); +alter table ACT_RU_BATCH + add constraint ACT_FK_BATCH_JOB_DEF + foreign key (BATCH_JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +-- indexes for deadlock problems - https://app.camunda.com/jira/browse/CAM-2567 -- +create index ACT_IDX_INC_CAUSEINCID on ACT_RU_INCIDENT(CAUSE_INCIDENT_ID_); +create index ACT_IDX_INC_EXID on ACT_RU_INCIDENT(EXECUTION_ID_); +create index ACT_IDX_INC_PROCDEFID on ACT_RU_INCIDENT(PROC_DEF_ID_); +create index ACT_IDX_INC_PROCINSTID on ACT_RU_INCIDENT(PROC_INST_ID_); +create index ACT_IDX_INC_ROOTCAUSEINCID on ACT_RU_INCIDENT(ROOT_CAUSE_INCIDENT_ID_); +-- index for deadlock problem - https://app.camunda.com/jira/browse/CAM-4440 -- +create index ACT_IDX_AUTH_RESOURCE_ID on ACT_RU_AUTHORIZATION(RESOURCE_ID_); +-- index to prevent deadlock on fk constraint - https://app.camunda.com/jira/browse/CAM-5440 -- +create index ACT_IDX_EXT_TASK_EXEC on ACT_RU_EXT_TASK(EXECUTION_ID_); + +-- indexes to improve deployment +create index ACT_IDX_BYTEARRAY_NAME on ACT_GE_BYTEARRAY(NAME_); +create index ACT_IDX_DEPLOYMENT_NAME on ACT_RE_DEPLOYMENT(NAME_); +create index ACT_IDX_DEPLOYMENT_TENANT_ID on ACT_RE_DEPLOYMENT(TENANT_ID_); +create index ACT_IDX_JOBDEF_PROC_DEF_ID ON ACT_RU_JOBDEF(PROC_DEF_ID_); +create index ACT_IDX_JOB_HANDLER_TYPE ON ACT_RU_JOB(HANDLER_TYPE_); +create index ACT_IDX_EVENT_SUBSCR_EVT_NAME ON ACT_RU_EVENT_SUBSCR(EVENT_NAME_); +create index ACT_IDX_PROCDEF_DEPLOYMENT_ID ON ACT_RE_PROCDEF(DEPLOYMENT_ID_); +create index ACT_IDX_PROCDEF_TENANT_ID ON ACT_RE_PROCDEF(TENANT_ID_); +create index ACT_IDX_PROCDEF_VER_TAG ON ACT_RE_PROCDEF(VERSION_TAG_); +-- create case definition table -- +create table ACT_RE_CASE_DEF ( + ID_ varchar(64) not null, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) not null, + VERSION_ integer not null, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + TENANT_ID_ varchar(64), + HISTORY_TTL_ integer, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create case execution table -- +create table ACT_RU_CASE_EXECUTION ( + ID_ varchar(64) NOT NULL, + REV_ integer, + CASE_INST_ID_ varchar(64), + SUPER_CASE_EXEC_ varchar(64), + SUPER_EXEC_ varchar(64), + BUSINESS_KEY_ varchar(255), + PARENT_ID_ varchar(64), + CASE_DEF_ID_ varchar(64), + ACT_ID_ varchar(255), + PREV_STATE_ integer, + CURRENT_STATE_ integer, + REQUIRED_ boolean, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create case sentry part table -- + +create table ACT_RU_CASE_SENTRY_PART ( + ID_ varchar(64) NOT NULL, + REV_ integer, + CASE_INST_ID_ varchar(64), + CASE_EXEC_ID_ varchar(64), + SENTRY_ID_ varchar(255), + TYPE_ varchar(255), + SOURCE_CASE_EXEC_ID_ varchar(64), + STANDARD_EVENT_ varchar(255), + SOURCE_ varchar(255), + VARIABLE_EVENT_ varchar(255), + VARIABLE_NAME_ varchar(255), + SATISFIED_ boolean, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create index on business key -- +create index ACT_IDX_CASE_EXEC_BUSKEY on ACT_RU_CASE_EXECUTION(BUSINESS_KEY_); + +-- create foreign key constraints on ACT_RU_CASE_EXECUTION -- +alter table ACT_RU_CASE_EXECUTION + add constraint ACT_FK_CASE_EXE_CASE_INST + foreign key (CASE_INST_ID_) + references ACT_RU_CASE_EXECUTION(ID_) on delete cascade on update cascade; + +alter table ACT_RU_CASE_EXECUTION + add constraint ACT_FK_CASE_EXE_PARENT + foreign key (PARENT_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +alter table ACT_RU_CASE_EXECUTION + add constraint ACT_FK_CASE_EXE_CASE_DEF + foreign key (CASE_DEF_ID_) + references ACT_RE_CASE_DEF(ID_); + +-- create foreign key constraints on ACT_RU_VARIABLE -- +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_CASE_EXE + foreign key (CASE_EXECUTION_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_CASE_INST + foreign key (CASE_INST_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +-- create foreign key constraints on ACT_RU_TASK -- +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_CASE_EXE + foreign key (CASE_EXECUTION_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_CASE_DEF + foreign key (CASE_DEF_ID_) + references ACT_RE_CASE_DEF(ID_); + +-- create foreign key constraints on ACT_RU_CASE_SENTRY_PART -- +alter table ACT_RU_CASE_SENTRY_PART + add constraint ACT_FK_CASE_SENTRY_CASE_INST + foreign key (CASE_INST_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +alter table ACT_RU_CASE_SENTRY_PART + add constraint ACT_FK_CASE_SENTRY_CASE_EXEC + foreign key (CASE_EXEC_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +create index ACT_IDX_CASE_DEF_TENANT_ID on ACT_RE_CASE_DEF(TENANT_ID_); +create index ACT_IDX_CASE_EXEC_TENANT_ID on ACT_RU_CASE_EXECUTION(TENANT_ID_); +-- create decision definition table -- +create table ACT_RE_DECISION_DEF ( + ID_ varchar(64) not null, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) not null, + VERSION_ integer not null, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + DEC_REQ_ID_ varchar(64), + DEC_REQ_KEY_ varchar(255), + TENANT_ID_ varchar(64), + HISTORY_TTL_ integer, + VERSION_TAG_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create decision requirements definition table -- +create table ACT_RE_DECISION_REQ_DEF ( + ID_ varchar(64) NOT NULL, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) NOT NULL, + VERSION_ integer NOT NULL, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +alter table ACT_RE_DECISION_DEF + add constraint ACT_FK_DEC_REQ + foreign key (DEC_REQ_ID_) + references ACT_RE_DECISION_REQ_DEF(ID_); + +create index ACT_IDX_DEC_DEF_TENANT_ID on ACT_RE_DECISION_DEF(TENANT_ID_); +create index ACT_IDX_DEC_DEF_REQ_ID on ACT_RE_DECISION_DEF(DEC_REQ_ID_); +create index ACT_IDX_DEC_REQ_DEF_TENANT_ID on ACT_RE_DECISION_REQ_DEF(TENANT_ID_); +create table ACT_HI_PROCINST ( + ID_ varchar(64) not null, + PROC_INST_ID_ varchar(64) not null, + BUSINESS_KEY_ varchar(255), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64) not null, + START_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + DURATION_ bigint, + START_USER_ID_ varchar(255), + START_ACT_ID_ varchar(255), + END_ACT_ID_ varchar(255), + SUPER_PROCESS_INSTANCE_ID_ varchar(64), + SUPER_CASE_INSTANCE_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + DELETE_REASON_ varchar(4000), + TENANT_ID_ varchar(64), + STATE_ varchar(255), + primary key (ID_), + unique (PROC_INST_ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_ACTINST ( + ID_ varchar(64) not null, + PARENT_ACT_INST_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64) not null, + PROC_INST_ID_ varchar(64) not null, + EXECUTION_ID_ varchar(64) not null, + ACT_ID_ varchar(255) not null, + TASK_ID_ varchar(64), + CALL_PROC_INST_ID_ varchar(64), + CALL_CASE_INST_ID_ varchar(64), + ACT_NAME_ varchar(255), + ACT_TYPE_ varchar(255) not null, + ASSIGNEE_ varchar(64), + START_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + DURATION_ bigint, + ACT_INST_STATE_ integer, + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_TASKINST ( + ID_ varchar(64) not null, + TASK_DEF_KEY_ varchar(255), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + NAME_ varchar(255), + PARENT_TASK_ID_ varchar(64), + DESCRIPTION_ varchar(4000), + OWNER_ varchar(255), + ASSIGNEE_ varchar(255), + START_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + DURATION_ bigint, + DELETE_REASON_ varchar(4000), + PRIORITY_ integer, + DUE_DATE_ datetime(3), + FOLLOW_UP_DATE_ datetime(3), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_VARINST ( + ID_ varchar(64) not null, + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + TASK_ID_ varchar(64), + NAME_ varchar(255) not null, + VAR_TYPE_ varchar(100), + REV_ integer, + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB, + TEXT2_ LONGBLOB, + TENANT_ID_ varchar(64), + STATE_ varchar(20), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_DETAIL ( + ID_ varchar(64) not null, + TYPE_ varchar(255) not null, + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + TASK_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + VAR_INST_ID_ varchar(64), + NAME_ varchar(255) not null, + VAR_TYPE_ varchar(255), + REV_ integer, + TIME_ datetime(3) not null, + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB, + TEXT2_ LONGBLOB, + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + OPERATION_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_IDENTITYLINK ( + ID_ varchar(64) not null, + TIMESTAMP_ timestamp(3) not null, + TYPE_ varchar(255), + USER_ID_ varchar(255), + GROUP_ID_ varchar(255), + TASK_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + OPERATION_TYPE_ varchar(64), + ASSIGNER_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_COMMENT ( + ID_ varchar(64) not null, + TYPE_ varchar(255), + TIME_ datetime(3) not null, + USER_ID_ varchar(255), + TASK_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + ACTION_ varchar(255), + MESSAGE_ varchar(4000), + FULL_MSG_ LONGBLOB, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_ATTACHMENT ( + ID_ varchar(64) not null, + REV_ integer, + USER_ID_ varchar(255), + NAME_ varchar(255), + DESCRIPTION_ varchar(4000), + TYPE_ varchar(255), + TASK_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + URL_ varchar(4000), + CONTENT_ID_ varchar(64), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_OP_LOG ( + ID_ varchar(64) not null, + DEPLOYMENT_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + TASK_ID_ varchar(64), + JOB_ID_ varchar(64), + JOB_DEF_ID_ varchar(64), + BATCH_ID_ varchar(64), + USER_ID_ varchar(255), + TIMESTAMP_ timestamp(3) not null, + OPERATION_TYPE_ varchar(64), + OPERATION_ID_ varchar(64), + ENTITY_TYPE_ varchar(30), + PROPERTY_ varchar(64), + ORG_VALUE_ varchar(4000), + NEW_VALUE_ varchar(4000), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_INCIDENT ( + ID_ varchar(64) not null, + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CREATE_TIME_ timestamp(3) not null, + END_TIME_ timestamp(3) null, + INCIDENT_MSG_ varchar(4000), + INCIDENT_TYPE_ varchar(255) not null, + ACTIVITY_ID_ varchar(255), + CAUSE_INCIDENT_ID_ varchar(64), + ROOT_CAUSE_INCIDENT_ID_ varchar(64), + CONFIGURATION_ varchar(255), + INCIDENT_STATE_ integer, + TENANT_ID_ varchar(64), + JOB_DEF_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_JOB_LOG ( + ID_ varchar(64) not null, + TIMESTAMP_ timestamp(3) not null, + JOB_ID_ varchar(64) not null, + JOB_DUEDATE_ timestamp(3) NULL, + JOB_RETRIES_ integer, + JOB_PRIORITY_ bigint NOT NULL DEFAULT 0, + JOB_EXCEPTION_MSG_ varchar(4000), + JOB_EXCEPTION_STACK_ID_ varchar(64), + JOB_STATE_ integer, + JOB_DEF_ID_ varchar(64), + JOB_DEF_TYPE_ varchar(255), + JOB_DEF_CONFIGURATION_ varchar(255), + ACT_ID_ varchar(255), + EXECUTION_ID_ varchar(64), + PROCESS_INSTANCE_ID_ varchar(64), + PROCESS_DEF_ID_ varchar(64), + PROCESS_DEF_KEY_ varchar(255), + DEPLOYMENT_ID_ varchar(64), + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_BATCH ( + ID_ varchar(64) not null, + TYPE_ varchar(255), + TOTAL_JOBS_ integer, + JOBS_PER_SEED_ integer, + INVOCATIONS_PER_JOB_ integer, + SEED_JOB_DEF_ID_ varchar(64), + MONITOR_JOB_DEF_ID_ varchar(64), + BATCH_JOB_DEF_ID_ varchar(64), + TENANT_ID_ varchar(64), + START_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_EXT_TASK_LOG ( + ID_ varchar(64) not null, + TIMESTAMP_ timestamp(3) not null, + EXT_TASK_ID_ varchar(64) not null, + RETRIES_ integer, + TOPIC_NAME_ varchar(255), + WORKER_ID_ varchar(255), + PRIORITY_ bigint NOT NULL DEFAULT 0, + ERROR_MSG_ varchar(4000), + ERROR_DETAILS_ID_ varchar(64), + ACT_ID_ varchar(255), + ACT_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + TENANT_ID_ varchar(64), + STATE_ integer, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create index ACT_IDX_HI_PRO_INST_END on ACT_HI_PROCINST(END_TIME_); +create index ACT_IDX_HI_PRO_I_BUSKEY on ACT_HI_PROCINST(BUSINESS_KEY_); +create index ACT_IDX_HI_PRO_INST_TENANT_ID on ACT_HI_PROCINST(TENANT_ID_); +create index ACT_IDX_HI_PRO_INST_PROC_DEF_KEY on ACT_HI_PROCINST(PROC_DEF_KEY_); + +create index ACT_IDX_HI_ACT_INST_START on ACT_HI_ACTINST(START_TIME_); +create index ACT_IDX_HI_ACT_INST_END on ACT_HI_ACTINST(END_TIME_); +create index ACT_IDX_HI_ACT_INST_PROCINST on ACT_HI_ACTINST(PROC_INST_ID_, ACT_ID_); +create index ACT_IDX_HI_ACT_INST_COMP on ACT_HI_ACTINST(EXECUTION_ID_, ACT_ID_, END_TIME_, ID_); +create index ACT_IDX_HI_ACT_INST_STATS on ACT_HI_ACTINST(PROC_DEF_ID_, ACT_ID_, END_TIME_, ACT_INST_STATE_); +create index ACT_IDX_HI_ACT_INST_TENANT_ID on ACT_HI_ACTINST(TENANT_ID_); +create index ACT_IDX_HI_ACT_INST_PROC_DEF_KEY on ACT_HI_ACTINST(PROC_DEF_KEY_); + +create index ACT_IDX_HI_TASK_INST_TENANT_ID on ACT_HI_TASKINST(TENANT_ID_); +create index ACT_IDX_HI_TASK_INST_PROC_DEF_KEY on ACT_HI_TASKINST(PROC_DEF_KEY_); +create index ACT_IDX_HI_TASKINST_PROCINST on ACT_HI_TASKINST(PROC_INST_ID_); +create index ACT_IDX_HI_TASKINSTID_PROCINST on ACT_HI_TASKINST(ID_,PROC_INST_ID_); + +create index ACT_IDX_HI_DETAIL_PROC_INST on ACT_HI_DETAIL(PROC_INST_ID_); +create index ACT_IDX_HI_DETAIL_ACT_INST on ACT_HI_DETAIL(ACT_INST_ID_); +create index ACT_IDX_HI_DETAIL_CASE_INST on ACT_HI_DETAIL(CASE_INST_ID_); +create index ACT_IDX_HI_DETAIL_CASE_EXEC on ACT_HI_DETAIL(CASE_EXECUTION_ID_); +create index ACT_IDX_HI_DETAIL_TIME on ACT_HI_DETAIL(TIME_); +create index ACT_IDX_HI_DETAIL_NAME on ACT_HI_DETAIL(NAME_); +create index ACT_IDX_HI_DETAIL_TASK_ID on ACT_HI_DETAIL(TASK_ID_); +create index ACT_IDX_HI_DETAIL_TENANT_ID on ACT_HI_DETAIL(TENANT_ID_); +create index ACT_IDX_HI_DETAIL_PROC_DEF_KEY on ACT_HI_DETAIL(PROC_DEF_KEY_); +create index ACT_IDX_HI_DETAIL_BYTEAR on ACT_HI_DETAIL(BYTEARRAY_ID_); + +create index ACT_IDX_HI_IDENT_LNK_USER on ACT_HI_IDENTITYLINK(USER_ID_); +create index ACT_IDX_HI_IDENT_LNK_GROUP on ACT_HI_IDENTITYLINK(GROUP_ID_); +create index ACT_IDX_HI_IDENT_LNK_TENANT_ID on ACT_HI_IDENTITYLINK(TENANT_ID_); +create index ACT_IDX_HI_IDENT_LNK_PROC_DEF_KEY on ACT_HI_IDENTITYLINK(PROC_DEF_KEY_); +create index ACT_IDX_HI_IDENT_LINK_TASK on ACT_HI_IDENTITYLINK(TASK_ID_); + +create index ACT_IDX_HI_PROCVAR_PROC_INST on ACT_HI_VARINST(PROC_INST_ID_); +create index ACT_IDX_HI_PROCVAR_NAME_TYPE on ACT_HI_VARINST(NAME_, VAR_TYPE_); +create index ACT_IDX_HI_CASEVAR_CASE_INST on ACT_HI_VARINST(CASE_INST_ID_); +create index ACT_IDX_HI_VAR_INST_TENANT_ID on ACT_HI_VARINST(TENANT_ID_); +create index ACT_IDX_HI_VAR_INST_PROC_DEF_KEY on ACT_HI_VARINST(PROC_DEF_KEY_); +create index ACT_IDX_HI_VARINST_BYTEAR on ACT_HI_VARINST(BYTEARRAY_ID_); + +create index ACT_IDX_HI_INCIDENT_TENANT_ID on ACT_HI_INCIDENT(TENANT_ID_); +create index ACT_IDX_HI_INCIDENT_PROC_DEF_KEY on ACT_HI_INCIDENT(PROC_DEF_KEY_); +create index ACT_IDX_HI_INCIDENT_PROCINST on ACT_HI_INCIDENT(PROC_INST_ID_); + +create index ACT_IDX_HI_JOB_LOG_PROCINST on ACT_HI_JOB_LOG(PROCESS_INSTANCE_ID_); +create index ACT_IDX_HI_JOB_LOG_PROCDEF on ACT_HI_JOB_LOG(PROCESS_DEF_ID_); +create index ACT_IDX_HI_JOB_LOG_TENANT_ID on ACT_HI_JOB_LOG(TENANT_ID_); +create index ACT_IDX_HI_JOB_LOG_JOB_DEF_ID on ACT_HI_JOB_LOG(JOB_DEF_ID_); +create index ACT_IDX_HI_JOB_LOG_PROC_DEF_KEY on ACT_HI_JOB_LOG(PROCESS_DEF_KEY_); +create index ACT_IDX_HI_JOB_LOG_EX_STACK on ACT_HI_JOB_LOG(JOB_EXCEPTION_STACK_ID_); + +create index ACT_HI_EXT_TASK_LOG_PROCINST on ACT_HI_EXT_TASK_LOG(PROC_INST_ID_); +create index ACT_HI_EXT_TASK_LOG_PROCDEF on ACT_HI_EXT_TASK_LOG(PROC_DEF_ID_); +create index ACT_HI_EXT_TASK_LOG_PROC_DEF_KEY on ACT_HI_EXT_TASK_LOG(PROC_DEF_KEY_); +create index ACT_HI_EXT_TASK_LOG_TENANT_ID on ACT_HI_EXT_TASK_LOG(TENANT_ID_); +create index ACT_IDX_HI_EXTTASKLOG_ERRORDET on ACT_HI_EXT_TASK_LOG(ERROR_DETAILS_ID_); + +create index ACT_IDX_HI_OP_LOG_PROCINST on ACT_HI_OP_LOG(PROC_INST_ID_); +create index ACT_IDX_HI_OP_LOG_PROCDEF on ACT_HI_OP_LOG(PROC_DEF_ID_); + +create index ACT_IDX_HI_COMMENT_TASK on ACT_HI_COMMENT(TASK_ID_); +create index ACT_IDX_HI_COMMENT_PROCINST on ACT_HI_COMMENT(PROC_INST_ID_); + +create index ACT_IDX_HI_ATTACHMENT_CONTENT on ACT_HI_ATTACHMENT(CONTENT_ID_); +create index ACT_IDX_HI_ATTACHMENT_PROCINST on ACT_HI_ATTACHMENT(PROC_INST_ID_); +create index ACT_IDX_HI_ATTACHMENT_TASK on ACT_HI_ATTACHMENT(TASK_ID_); +create table ACT_HI_CASEINST ( + ID_ varchar(64) not null, + CASE_INST_ID_ varchar(64) not null, + BUSINESS_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64) not null, + CREATE_TIME_ datetime(3) not null, + CLOSE_TIME_ datetime(3), + DURATION_ bigint, + STATE_ integer, + CREATE_USER_ID_ varchar(255), + SUPER_CASE_INSTANCE_ID_ varchar(64), + SUPER_PROCESS_INSTANCE_ID_ varchar(64), + TENANT_ID_ varchar(64), + primary key (ID_), + unique (CASE_INST_ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_CASEACTINST ( + ID_ varchar(64) not null, + PARENT_ACT_INST_ID_ varchar(64), + CASE_DEF_ID_ varchar(64) not null, + CASE_INST_ID_ varchar(64) not null, + CASE_ACT_ID_ varchar(255) not null, + TASK_ID_ varchar(64), + CALL_PROC_INST_ID_ varchar(64), + CALL_CASE_INST_ID_ varchar(64), + CASE_ACT_NAME_ varchar(255), + CASE_ACT_TYPE_ varchar(255), + CREATE_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + DURATION_ bigint, + STATE_ integer, + REQUIRED_ boolean, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create index ACT_IDX_HI_CAS_I_CLOSE on ACT_HI_CASEINST(CLOSE_TIME_); +create index ACT_IDX_HI_CAS_I_BUSKEY on ACT_HI_CASEINST(BUSINESS_KEY_); +create index ACT_IDX_HI_CAS_I_TENANT_ID on ACT_HI_CASEINST(TENANT_ID_); +create index ACT_IDX_HI_CAS_A_I_CREATE on ACT_HI_CASEACTINST(CREATE_TIME_); +create index ACT_IDX_HI_CAS_A_I_END on ACT_HI_CASEACTINST(END_TIME_); +create index ACT_IDX_HI_CAS_A_I_COMP on ACT_HI_CASEACTINST(CASE_ACT_ID_, END_TIME_, ID_); +create index ACT_IDX_HI_CAS_A_I_CASEINST on ACT_HI_CASEACTINST(CASE_INST_ID_, CASE_ACT_ID_); +create index ACT_IDX_HI_CAS_A_I_TENANT_ID on ACT_HI_CASEACTINST(TENANT_ID_); +-- create history decision instance table -- +create table ACT_HI_DECINST ( + ID_ varchar(64) NOT NULL, + DEC_DEF_ID_ varchar(64) NOT NULL, + DEC_DEF_KEY_ varchar(255) NOT NULL, + DEC_DEF_NAME_ varchar(255), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + ACT_ID_ varchar(255), + EVAL_TIME_ datetime(3) not null, + COLLECT_VALUE_ double, + USER_ID_ varchar(255), + ROOT_DEC_INST_ID_ varchar(64), + DEC_REQ_ID_ varchar(64), + DEC_REQ_KEY_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create history decision input table -- +create table ACT_HI_DEC_IN ( + ID_ varchar(64) NOT NULL, + DEC_INST_ID_ varchar(64) NOT NULL, + CLAUSE_ID_ varchar(64), + CLAUSE_NAME_ varchar(255), + VAR_TYPE_ varchar(100), + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB, + TEXT2_ LONGBLOB, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create history decision output table -- +create table ACT_HI_DEC_OUT ( + ID_ varchar(64) NOT NULL, + DEC_INST_ID_ varchar(64) NOT NULL, + CLAUSE_ID_ varchar(64), + CLAUSE_NAME_ varchar(255), + RULE_ID_ varchar(64), + RULE_ORDER_ integer, + VAR_NAME_ varchar(255), + VAR_TYPE_ varchar(100), + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB, + TEXT2_ LONGBLOB, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + + +create index ACT_IDX_HI_DEC_INST_ID on ACT_HI_DECINST(DEC_DEF_ID_); +create index ACT_IDX_HI_DEC_INST_KEY on ACT_HI_DECINST(DEC_DEF_KEY_); +create index ACT_IDX_HI_DEC_INST_PI on ACT_HI_DECINST(PROC_INST_ID_); +create index ACT_IDX_HI_DEC_INST_CI on ACT_HI_DECINST(CASE_INST_ID_); +create index ACT_IDX_HI_DEC_INST_ACT on ACT_HI_DECINST(ACT_ID_); +create index ACT_IDX_HI_DEC_INST_ACT_INST on ACT_HI_DECINST(ACT_INST_ID_); +create index ACT_IDX_HI_DEC_INST_TIME on ACT_HI_DECINST(EVAL_TIME_); +create index ACT_IDX_HI_DEC_INST_TENANT_ID on ACT_HI_DECINST(TENANT_ID_); +create index ACT_IDX_HI_DEC_INST_ROOT_ID on ACT_HI_DECINST(ROOT_DEC_INST_ID_); +create index ACT_IDX_HI_DEC_INST_REQ_ID on ACT_HI_DECINST(DEC_REQ_ID_); +create index ACT_IDX_HI_DEC_INST_REQ_KEY on ACT_HI_DECINST(DEC_REQ_KEY_); + + +create index ACT_IDX_HI_DEC_IN_INST on ACT_HI_DEC_IN(DEC_INST_ID_); +create index ACT_IDX_HI_DEC_IN_CLAUSE on ACT_HI_DEC_IN(DEC_INST_ID_, CLAUSE_ID_); + +create index ACT_IDX_HI_DEC_OUT_INST on ACT_HI_DEC_OUT(DEC_INST_ID_); +create index ACT_IDX_HI_DEC_OUT_RULE on ACT_HI_DEC_OUT(RULE_ORDER_, CLAUSE_ID_); + +-- mariadb_identity_7.8.0-ee + +create table ACT_ID_GROUP ( + ID_ varchar(64), + REV_ integer, + NAME_ varchar(255), + TYPE_ varchar(255), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_MEMBERSHIP ( + USER_ID_ varchar(64), + GROUP_ID_ varchar(64), + primary key (USER_ID_, GROUP_ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_USER ( + ID_ varchar(64), + REV_ integer, + FIRST_ varchar(255), + LAST_ varchar(255), + EMAIL_ varchar(255), + PWD_ varchar(255), + SALT_ varchar(255), + PICTURE_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_INFO ( + ID_ varchar(64), + REV_ integer, + USER_ID_ varchar(64), + TYPE_ varchar(64), + KEY_ varchar(255), + VALUE_ varchar(255), + PASSWORD_ LONGBLOB, + PARENT_ID_ varchar(255), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_TENANT ( + ID_ varchar(64), + REV_ integer, + NAME_ varchar(255), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_TENANT_MEMBER ( + ID_ varchar(64) not null, + TENANT_ID_ varchar(64) not null, + USER_ID_ varchar(64), + GROUP_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +alter table ACT_ID_MEMBERSHIP + add constraint ACT_FK_MEMB_GROUP + foreign key (GROUP_ID_) + references ACT_ID_GROUP (ID_); + +alter table ACT_ID_MEMBERSHIP + add constraint ACT_FK_MEMB_USER + foreign key (USER_ID_) + references ACT_ID_USER (ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_UNIQ_TENANT_MEMB_USER + unique (TENANT_ID_, USER_ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_UNIQ_TENANT_MEMB_GROUP + unique (TENANT_ID_, GROUP_ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_FK_TENANT_MEMB + foreign key (TENANT_ID_) + references ACT_ID_TENANT (ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_FK_TENANT_MEMB_USER + foreign key (USER_ID_) + references ACT_ID_USER (ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_FK_TENANT_MEMB_GROUP + foreign key (GROUP_ID_) + references ACT_ID_GROUP (ID_); + +ALTER TABLE ACT_GE_BYTEARRAY + ADD TYPE_ integer; + +ALTER TABLE ACT_GE_BYTEARRAY + ADD CREATE_TIME_ datetime(3); + +ALTER TABLE ACT_RE_PROCDEF + ADD STARTABLE_ BOOLEAN NOT NULL DEFAULT TRUE;
\ No newline at end of file diff --git a/so-simulator/pom.xml b/so-simulator/pom.xml index a92664afb8..26a3da451e 100644 --- a/so-simulator/pom.xml +++ b/so-simulator/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>so</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>so-simulator</artifactId> @@ -74,11 +74,8 @@ <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> - <version>3.7.0</version> <configuration> <encoding>${project.build.sourceEncoding}</encoding> - <source>1.8</source> - <target>1.8</target> </configuration> </plugin> <plugin> @@ -105,6 +102,16 @@ </execution> </executions> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <executions> + <execution> + <id>original</id> + <phase>package</phase> + </execution> + </executions> + </plugin> </plugins> </build> diff --git a/so-simulator/src/main/docker/Dockerfile b/so-simulator/src/main/docker/Dockerfile index 8fa8dc75e9..a64ec39f8a 100644 --- a/so-simulator/src/main/docker/Dockerfile +++ b/so-simulator/src/main/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM docker.io/openjdk:8-jdk-alpine +FROM docker.io/openjdk:11-jre-slim #Create User so RUN addgroup -g 1000 so && adduser -S -u 1000 -G so so @@ -21,4 +21,4 @@ RUN chown -R so:so /app USER so -ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app/app.jar"]
\ No newline at end of file +ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app/app.jar"] diff --git a/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java b/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java index f790d804ca..954ebdd013 100644 --- a/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java +++ b/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java @@ -1,12 +1,18 @@ package org.onap.so.simulator.actions.aai; +import java.io.InputStream; +import java.util.List; import org.onap.aai.domain.yang.Vnfc; +import org.onap.aai.domain.yang.Vserver; +import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.aai.entities.Relationships; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.core.io.ClassPathResource; import com.consol.citrus.actions.AbstractTestAction; import com.consol.citrus.context.TestContext; @@ -56,6 +62,26 @@ public class ProcessVnfc extends AbstractTestAction { aaiResourceClient.connect(vnfcURI, vserverURI); aaiResourceClient.connect(vserverURI, pserverURI); aaiResourceClient.connect(vfModuleURI, vnfcURI); + } else if (context.getVariable("requestAction").equals("CreateVfModuleInstance") + && context.getVariable("serviceAction").equals("activate")) { + // For recreate after soft delete + AAIResourceUri vnfcURI = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, "zauk51bfrwl09oam001"); + AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, + context.getVariable("cloudOwner"), context.getVariable("cloudRegion"), + context.getVariable("tenant"), "d29f3151-592d-4011-9356-ad047794e236"); + + Relationships relationships = aaiResourceClient.get(vnfcURI).getRelationships().get(); + List<AAIResourceUri> uris = relationships.getRelatedUris(AAIObjectType.VSERVER); + if (uris.isEmpty() || uris.size() == 0) { + if (!aaiResourceClient.exists(vserverURI)) { + AAICommonObjectMapperProvider aaiMapper = new AAICommonObjectMapperProvider(); + InputStream vserverFile = + new ClassPathResource("openstack/gr_api/CreateVserver.json").getInputStream(); + Vserver vserver = aaiMapper.getMapper().readValue(vserverFile, Vserver.class); + aaiResourceClient.create(vserverURI, vserver); + } + aaiResourceClient.connect(vnfcURI, vserverURI); + } } } catch (Exception e) { logger.debug("Exception in ProcessVnfc.doExecute", e); diff --git a/so-simulator/src/main/resources/openstack/gr_api/CreateVserver.json b/so-simulator/src/main/resources/openstack/gr_api/CreateVserver.json new file mode 100644 index 0000000000..17bc9233d4 --- /dev/null +++ b/so-simulator/src/main/resources/openstack/gr_api/CreateVserver.json @@ -0,0 +1,87 @@ +{ + "vserver-id": "d29f3151-592d-4011-9356-ad047794e236", + "vserver-name": "ssc_server_1", + "vserver-name2": "ssc_server_1", + "vserver-selflink": "https://test.com:8774/v2/0422ffb57ba042c0800a29dc85ca70f8/servers/92272b67-d23f-42ca-87fa-7b06a9ec81f3", + "in-maint": false, + "is-closed-loop-disabled": false, + "l-interfaces": { + "l-interface": [ + { + "interface-name": "ssc_1_mgmt_port_0", + "selflink": "https://test.com:9696/v2.0/ports/07f5b14c-147a-4d14-8c94-a9e94dbc097b", + "interface-id": "e80bec21-4b4b-42b0-ae17-20e736b8a82b", + "macaddr": "02:07:f5:b1:4c:14", + "network-name": "GRP-27529-T-IST-05E-dyh3b_TIPFR_OAMP_NSD_TSBC0_net_1", + "is-port-mirrored": false, + "in-maint": false, + "is-ip-unnumbered": false, + "l3-interface-ipv4-address-list": [ + { + "l3-interface-ipv4-address": "192.61.12.203", + "l3-interface-ipv4-prefix-length": 28, + "is-floating": false, + "neutron-network-id": "cae2ade2-9f44-40fa-b124-18b101ff9aa0", + "neutron-subnet-id": "1f954922-6e9c-4a64-9d78-62e869ba8c77" + } + ], + "vlans" : { + "vlan": [ + { + "in-maint": false, + "is-ip-unnumbered": false, + "is-private": false, + "vlan-id-inner": 0, + "vlan-id-outer": 123, + "vlan-interface": "oamfw_oam_direct1_0_port141" + } + ] + } + }, + { + "interface-name": "ssc_1_int_ha_port_0", + "selflink": "https://test.com:9696/v2.0/ports/0594a2f2-7ea4-42eb-abc2-48ea49677fca", + "interface-id": "e80bec21-4b4b-42b0-ae17-20e736b8a82a", + "macaddr": "02:05:94:a2:f2:7e", + "network-name": "GRP-27529-T-IST-05E-dyh3b_TIPFR-UNTR-ROLE1-PARNT_net_1", + "is-port-mirrored": false, + "in-maint": false, + "is-ip-unnumbered": false, + "l-interfaces": { + "l-interface": [ + { + "interface-name": "tsbc0005v_tsbc0005vm002_subint_untrusted_role1_81", + "interface-id": "2bbfa345-33bb-495a-94b2-fb514ee1cffc", + "macaddr": "02:05:94:a2:f2:7e", + "network-name": "GRP-27529-T-IST-05E-dyh3b_TIPFR_UNTR_VSE_ROLE10_net_1", + "is-port-mirrored": false, + "in-maint": false, + "is-ip-unnumbered": false + } + ] + }, + "l3-interface-ipv4-address-list": [ + { + "l3-interface-ipv4-address": "172.26.0.36", + "l3-interface-ipv4-prefix-length": 27, + "is-floating": false, + "neutron-network-id": "49bd2c8c-808d-4783-a1c5-5d9ae0c6a9fa", + "neutron-subnet-id": "8d073a94-b1b9-493a-8fc1-cf92abcba466" + } + ], + "vlans" : { + "vlan": [ + { + "in-maint": false, + "is-ip-unnumbered": false, + "is-private": false, + "vlan-id-inner": 0, + "vlan-id-outer": 965, + "vlan-interface": "oamfw_oam_direct1_0_port141" + } + ] + } + } + ] + } +} diff --git a/so-simulator/src/main/resources/openstack/gr_api/GetNovaServer.json b/so-simulator/src/main/resources/openstack/gr_api/GetNovaServer.json index 622bf8e3ef..afc7b8e6db 100644 --- a/so-simulator/src/main/resources/openstack/gr_api/GetNovaServer.json +++ b/so-simulator/src/main/resources/openstack/gr_api/GetNovaServer.json @@ -66,7 +66,7 @@ "OS-SRV-USG:terminated_at": null, "key_name": null, "OS-EXT-SRV-ATTR:hypervisor_hostname": "test.com", - "name": "zauk51bfrwl09oam001", + "name": "ssc_server_1", "created": "2019-02-11T19:11:58Z", "tenant_id": "872f331350c54e59991a8de2cbffb40c", "os-extended-volumes:volumes_attached": [], diff --git a/version.properties b/version.properties index e377fcf8e3..4bdcfa1b54 100644 --- a/version.properties +++ b/version.properties @@ -4,7 +4,7 @@ major=1 minor=7 -patch=0 +patch=1 base_version=${major}.${minor}.${patch} |