diff options
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-enrichment-lib')
22 files changed, 558 insertions, 146 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-api/pom.xml.versionsBackup b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-api/pom.xml.versionsBackup new file mode 100644 index 0000000000..493e4256a3 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-api/pom.xml.versionsBackup @@ -0,0 +1,45 @@ +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://maven.apache.org/POM/4.0.0" + 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> + + <name>openecomp-sdc-enrichment-api</name> + <artifactId>openecomp-sdc-enrichment-api</artifactId> + + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-lib</artifactId> + <version>1.0-SNAPSHOT</version> + <relativePath>../..</relativePath> + </parent> + + <dependencies> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-facade-core</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-annotations</artifactId> + <version>1.5.3</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-datatypes-lib</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>${logback.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-versioning-api</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + </dependencies> + +</project>
\ No newline at end of file diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-api/src/main/java/org/openecomp/core/enrichment/types/ComponentMibInfo.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-api/src/main/java/org/openecomp/core/enrichment/types/ComponentMibInfo.java deleted file mode 100644 index 88dbedc136..0000000000 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-api/src/main/java/org/openecomp/core/enrichment/types/ComponentMibInfo.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * 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.openecomp.core.enrichment.types; - -public class ComponentMibInfo { - private MibInfo snmpTrap; - private MibInfo snmpPoll; - - - public MibInfo getSnmpTrap() { - return snmpTrap; - } - - public void setSnmpTrap(MibInfo snmpTrap) { - this.snmpTrap = snmpTrap; - } - - public MibInfo getSnmpPoll() { - return snmpPoll; - } - - public void setSnmpPoll(MibInfo snmpPoll) { - this.snmpPoll = snmpPoll; - } - - -} diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-api/src/main/java/org/openecomp/core/enrichment/types/ComponentMonitoringUploadInfo.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-api/src/main/java/org/openecomp/core/enrichment/types/ComponentMonitoringUploadInfo.java new file mode 100644 index 0000000000..a3a76a561b --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-api/src/main/java/org/openecomp/core/enrichment/types/ComponentMonitoringUploadInfo.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.openecomp.core.enrichment.types; + +import java.util.HashMap; +import java.util.Map; + +import static org.openecomp.core.enrichment.types.MonitoringUploadType.SNMP_POLL; +import static org.openecomp.core.enrichment.types.MonitoringUploadType.SNMP_TRAP; +import static org.openecomp.core.enrichment.types.MonitoringUploadType.VES_EVENTS; + +public class ComponentMonitoringUploadInfo { + + + private Map<MonitoringUploadType, MonitoringArtifactInfo> infoByType = new HashMap<>(); + //todo as part of ATTASDC-4503 + + + public MonitoringArtifactInfo getSnmpTrap() { + return infoByType.get(SNMP_TRAP); + } + + public void setSnmpTrap(MonitoringArtifactInfo snmpTrapInfo) { + infoByType.put(SNMP_TRAP, snmpTrapInfo); + } + + public MonitoringArtifactInfo getSnmpPoll() { + return infoByType.get(SNMP_POLL); + } + + public void setSnmpPoll(MonitoringArtifactInfo snmpPollInfo) { + infoByType.put(SNMP_POLL, snmpPollInfo); + } + + public MonitoringArtifactInfo getVesEvent() { + return infoByType.get(VES_EVENTS); + } + + public void setVesEvent(MonitoringArtifactInfo snmpPollInfo) { + infoByType.put(VES_EVENTS, snmpPollInfo); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-api/src/main/java/org/openecomp/core/enrichment/types/MibInfo.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-api/src/main/java/org/openecomp/core/enrichment/types/MonitoringArtifactInfo.java index f5d2fcb90d..27a0d83069 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-api/src/main/java/org/openecomp/core/enrichment/types/MibInfo.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-api/src/main/java/org/openecomp/core/enrichment/types/MonitoringArtifactInfo.java @@ -23,7 +23,7 @@ package org.openecomp.core.enrichment.types; import java.io.ByteArrayInputStream; import java.io.InputStream; -public class MibInfo { +public class MonitoringArtifactInfo { private String name; private byte[] content; diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-api/src/main/java/org/openecomp/core/enrichment/types/ArtifactType.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-api/src/main/java/org/openecomp/core/enrichment/types/MonitoringUploadType.java index 48805d7ca5..077480f95f 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-api/src/main/java/org/openecomp/core/enrichment/types/ArtifactType.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-api/src/main/java/org/openecomp/core/enrichment/types/MonitoringUploadType.java @@ -20,11 +20,10 @@ package org.openecomp.core.enrichment.types; -public enum ArtifactType { +public enum MonitoringUploadType { SNMP_POLL, - SNMP_TRAP; - - + SNMP_TRAP, + VES_EVENTS } diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/pom.xml b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/pom.xml index ab0cafb879..9fe0f49387 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/pom.xml @@ -20,6 +20,11 @@ <version>${logback.version}</version> </dependency> <dependency> + <groupId>org.openecomp.sdc.common</groupId> + <artifactId>openecomp-tosca-datatype</artifactId> + <version>${openecomp.sdc.common.version}</version> + </dependency> + <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <scope>test</scope> diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/pom.xml.versionsBackup b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/pom.xml.versionsBackup new file mode 100644 index 0000000000..d8f63f10e9 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/pom.xml.versionsBackup @@ -0,0 +1,94 @@ +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://maven.apache.org/POM/4.0.0" + 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> + + <name>openecomp-sdc-enrichment-core</name> + <artifactId>openecomp-sdc-enrichment-core</artifactId> + + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-lib</artifactId> + <version>1.0-SNAPSHOT</version> + <relativePath>../..</relativePath> + </parent> + + <dependencies> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>${logback.version}</version> + + </dependency> + <dependency> + <groupId>org.testng</groupId> + <artifactId>testng</artifactId> + <scope>test</scope> + <version>6.8.5</version> + <exclusions> + <exclusion> + <artifactId>snakeyaml</artifactId> + <groupId>org.yaml</groupId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>RELEASE</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-utilities-lib</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-enrichment-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-enrichment-impl</artifactId> + <version>${project.version}</version> + <!--scope>runtime</scope--> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-datatypes-lib</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-all</artifactId> + <scope>test</scope> + <version>1.10.19</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-model-impl</artifactId> + <version>1.0-SNAPSHOT</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-tosca-lib</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.19.1</version> + <configuration> + <useSystemClassLoader>false</useSystemClassLoader> + <redirectTestOutputToFile>true</redirectTestOutputToFile> + </configuration> + </plugin> + </plugins> + </build> +</project>
\ No newline at end of file diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/src/test/java/org/openecomp/sdc/enrichment/impl/EnrichmentManagerImplTest.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/src/test/java/org/openecomp/sdc/enrichment/impl/EnrichmentManagerImplTest.java index dfdbaef896..293e4dec2a 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/src/test/java/org/openecomp/sdc/enrichment/impl/EnrichmentManagerImplTest.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/src/test/java/org/openecomp/sdc/enrichment/impl/EnrichmentManagerImplTest.java @@ -29,7 +29,7 @@ import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; import org.openecomp.sdc.tosca.services.ToscaFileOutputService; import org.openecomp.sdc.tosca.services.impl.ToscaFileOutputServiceCsarImpl; -import org.openecomp.sdc.tosca.services.yamlutil.ToscaExtensionYamlUtil; +import org.openecomp.sdc.tosca.services.ToscaExtensionYamlUtil; import org.openecomp.sdc.versioning.dao.types.Version; import org.testng.Assert; import org.testng.annotations.Test; diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/pom.xml b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/pom.xml index b5014fd4b1..cfc824bc5e 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/pom.xml @@ -20,6 +20,12 @@ <version>${logback.version}</version> </dependency> <dependency> + <groupId>org.openecomp.sdc.common</groupId> + <artifactId>openecomp-tosca-datatype</artifactId> + <version>${openecomp.sdc.common.version}</version> + </dependency> + + <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <scope>test</scope> diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/pom.xml.versionsBackup b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/pom.xml.versionsBackup new file mode 100644 index 0000000000..65e84d88dc --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/pom.xml.versionsBackup @@ -0,0 +1,127 @@ +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://maven.apache.org/POM/4.0.0" + 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> + + <name>openecomp-sdc-enrichment-impl</name> + <artifactId>openecomp-sdc-enrichment-impl</artifactId> + + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-lib</artifactId> + <version>1.0-SNAPSHOT</version> + <relativePath>../..</relativePath> + </parent> + + <dependencies> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>${logback.version}</version> + + </dependency> + + <dependency> + <groupId>org.testng</groupId> + <artifactId>testng</artifactId> + <scope>test</scope> + <version>6.8.5</version> + <exclusions> + <exclusion> + <artifactId>snakeyaml</artifactId> + <groupId>org.yaml</groupId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>RELEASE</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-utilities-lib</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-enrichment-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-model-core</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-common-lib</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-software-product-core</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-all</artifactId> + <scope>test</scope> + <version>1.10.19</version> + </dependency> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-heat-lib</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-tosca-lib</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-translator-core</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-config-lib</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-software-product-api</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <scope>runtime</scope> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-software-product-core</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <scope>test</scope> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-model-impl</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.19.1</version> + <configuration> + <useSystemClassLoader>false</useSystemClassLoader> + <redirectTestOutputToFile>true</redirectTestOutputToFile> + </configuration> + </plugin> + </plugins> + </build> + +</project>
\ No newline at end of file diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricher.java index 3920cc28af..a5d1ac1ba2 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricher.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricher.java @@ -21,9 +21,9 @@ package org.openecomp.sdc.enrichment.impl.external.artifact; import org.openecomp.core.enrichment.types.ArtifactCategory; -import org.openecomp.core.enrichment.types.ArtifactType; -import org.openecomp.core.enrichment.types.ComponentMibInfo; -import org.openecomp.core.enrichment.types.MibInfo; +import org.openecomp.core.enrichment.types.ComponentMonitoringUploadInfo; +import org.openecomp.core.enrichment.types.MonitoringArtifactInfo; +import org.openecomp.core.enrichment.types.MonitoringUploadType; import org.openecomp.core.model.dao.EnrichedServiceModelDao; import org.openecomp.core.model.dao.EnrichedServiceModelDaoFactory; import org.openecomp.core.model.types.ServiceArtifact; @@ -35,12 +35,12 @@ import org.openecomp.sdc.datatypes.error.ErrorMessage; import org.openecomp.sdc.enrichment.EnrichmentInfo; import org.openecomp.sdc.enrichment.inter.ExternalArtifactEnricherInterface; import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; -import org.openecomp.sdc.vendorsoftwareproduct.dao.MibDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.MibDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.MibEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.MonitoringUploadDaoFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity; import org.openecomp.sdc.versioning.dao.types.Version; import java.io.File; @@ -56,7 +56,7 @@ public class MonitoringMibEnricher implements ExternalArtifactEnricherInterface private EnrichedServiceModelDao enrichedServiceModelDao; private ComponentDao componentDao; - private MibDao mibDao; + private ComponentArtifactDao componentArtifactDao; private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); /** @@ -86,65 +86,77 @@ public class MonitoringMibEnricher implements ExternalArtifactEnricherInterface mdcDataDebugMessage.debugEntryMessage(null, null); Map<String, List<ErrorMessage>> errors = new HashMap<>(); - ComponentMibInfo componentMibInfo = + ComponentMonitoringUploadInfo componentMonitoringUploadInfo = extractComponentMibInfo(componentEntry, vspId, version, errors); - enrichComponentMib(componentMibInfo, vspId, version, errors); + enrichComponentMib(componentMonitoringUploadInfo, vspId, version, errors); mdcDataDebugMessage.debugExitMessage(null, null); return errors; } - ComponentMibInfo extractComponentMibInfo(ComponentEntity componentEntity, String vspId, - Version version, - Map<String, List<ErrorMessage>> errors) { + private ComponentMonitoringUploadInfo extractComponentMibInfo(ComponentEntity componentEntity, + String vspId, + Version version, + Map<String, List<ErrorMessage>> errors) { mdcDataDebugMessage.debugEntryMessage(null, null); String componentId = componentEntity.getId(); - MibEntity entity = new MibEntity(); + ComponentMonitoringUploadEntity entity = new ComponentMonitoringUploadEntity(); entity.setVspId(vspId); entity.setVersion(version); entity.setComponentId(componentId); String componentName = componentEntity.getComponentCompositionData().getName(); - ComponentMibInfo componentMibInfo = new ComponentMibInfo(); - updComponentMibInfoByType(componentName, ArtifactType.SNMP_POLL, entity, componentMibInfo, - errors); - updComponentMibInfoByType(componentName, ArtifactType.SNMP_TRAP, entity, componentMibInfo, - errors); + ComponentMonitoringUploadInfo componentMonitoringUploadInfo = + new ComponentMonitoringUploadInfo(); + for (MonitoringUploadType monitoringUploadType : MonitoringUploadType.values()) { + updComponentMibInfoByType(componentName, monitoringUploadType, entity, + componentMonitoringUploadInfo, + errors); + } +// updComponentMibInfoByType(componentName, MonitoringUploadType.SNMP_POLL, entity, +// componentMonitoringUploadInfo, +// errors); +// updComponentMibInfoByType(componentName, MonitoringUploadType.SNMP_TRAP, entity, +// componentMonitoringUploadInfo, +// errors); mdcDataDebugMessage.debugExitMessage(null, null); - return componentMibInfo; + return componentMonitoringUploadInfo; } - void updComponentMibInfoByType(String componentName, ArtifactType type, - MibEntity mibEntity, - ComponentMibInfo componentMibInfo, - Map<String, List<ErrorMessage>> errors) { + private void updComponentMibInfoByType(String componentName, MonitoringUploadType type, + ComponentMonitoringUploadEntity componentMonitoringUploadEntity, + ComponentMonitoringUploadInfo componentMonitoringUploadInfo, + Map<String, List<ErrorMessage>> errors) { mdcDataDebugMessage.debugEntryMessage(null, null); String path; - mibEntity.setType(type); - Optional<MibEntity> artifact = - getMibDao().getByType(mibEntity); + componentMonitoringUploadEntity.setType(type); + Optional<ComponentMonitoringUploadEntity> artifact = + getComponentArtifactDao().getByType(componentMonitoringUploadEntity); if (!artifact.isPresent()) { return; } path = componentName + File.separator + ArtifactCategory.DEPLOYMENT.getDisplayName() + File.separator + type.name(); - MibInfo mibInfo = new MibInfo(); - mibInfo.setName(path); - mibInfo.setContent(artifact.get().getArtifact().array()); - switch (type) { + MonitoringArtifactInfo monitoringArtifactInfo = new MonitoringArtifactInfo(); + monitoringArtifactInfo.setName(path); + monitoringArtifactInfo.setContent(artifact.get().getArtifact().array()); + switch (type) { //todo as part of ATTASDC-4503 case SNMP_POLL: - componentMibInfo.setSnmpPoll(mibInfo); + componentMonitoringUploadInfo.setSnmpPoll(monitoringArtifactInfo); break; case SNMP_TRAP: - componentMibInfo.setSnmpTrap(mibInfo); + componentMonitoringUploadInfo.setSnmpTrap(monitoringArtifactInfo); + break; + case VES_EVENTS: + componentMonitoringUploadInfo.setVesEvent(monitoringArtifactInfo); break; default: break; @@ -153,8 +165,10 @@ public class MonitoringMibEnricher implements ExternalArtifactEnricherInterface mdcDataDebugMessage.debugExitMessage(null, null); } - void enrichComponentMib(ComponentMibInfo componentMibInfo, String vspId, Version version, - Map<String, List<ErrorMessage>> errors) { + private void enrichComponentMib(ComponentMonitoringUploadInfo componentMonitoringUploadInfo, + String vspId, + Version version, + Map<String, List<ErrorMessage>> errors) { mdcDataDebugMessage.debugEntryMessage(null, null); @@ -162,40 +176,50 @@ public class MonitoringMibEnricher implements ExternalArtifactEnricherInterface ServiceArtifact mibServiceArtifact = new ServiceArtifact(); mibServiceArtifact.setVspId(vspId); mibServiceArtifact.setVersion(version); - enrichMibFiles(mibServiceArtifact, componentMibInfo, errors); + enrichMibFiles(mibServiceArtifact, componentMonitoringUploadInfo, errors); mdcDataDebugMessage.debugExitMessage(null, null); } - void enrichMibFiles(ServiceArtifact mibServiceArtifact, ComponentMibInfo componentMibInfo, - Map<String, List<ErrorMessage>> errors) { + private void enrichMibFiles(ServiceArtifact monitoringArtifact, + ComponentMonitoringUploadInfo componentMonitoringUploadInfo, + Map<String, List<ErrorMessage>> errors) { mdcDataDebugMessage.debugEntryMessage(null, null); - if (componentMibInfo == null) { + if (componentMonitoringUploadInfo == null) { return; } - enrichMibByType(componentMibInfo.getSnmpTrap(), ArtifactType.SNMP_TRAP, mibServiceArtifact, + //todo fix as part of ATTASDC-4503 + enrichMibByType(componentMonitoringUploadInfo.getSnmpTrap(), MonitoringUploadType.SNMP_TRAP, + monitoringArtifact, + errors); + enrichMibByType(componentMonitoringUploadInfo.getSnmpPoll(), MonitoringUploadType.SNMP_POLL, + monitoringArtifact, errors); - enrichMibByType(componentMibInfo.getSnmpPoll(), ArtifactType.SNMP_POLL, mibServiceArtifact, + enrichMibByType(componentMonitoringUploadInfo.getVesEvent(), MonitoringUploadType.VES_EVENTS, + monitoringArtifact, errors); mdcDataDebugMessage.debugExitMessage(null, null); } - void enrichMibByType(MibInfo mibInfo, ArtifactType type, ServiceArtifact mibServiceArtifact, - Map<String, List<ErrorMessage>> errors) { + private void enrichMibByType(MonitoringArtifactInfo monitoringArtifactInfo, + MonitoringUploadType type, + ServiceArtifact mibServiceArtifact, + Map<String, List<ErrorMessage>> errors) { mdcDataDebugMessage.debugEntryMessage(null, null); - if (mibInfo == null) { + if (monitoringArtifactInfo == null) { return; } FileContentHandler mibs; try { - mibs = FileUtils.getFileContentMapFromZip(FileUtils.toByteArray(mibInfo.getContent())); + mibs = FileUtils + .getFileContentMapFromZip(FileUtils.toByteArray(monitoringArtifactInfo.getContent())); } catch (IOException ioException) { ErrorMessage.ErrorMessageUtil .addMessage(mibServiceArtifact.getName() + "." + type.name(), errors) @@ -205,7 +229,7 @@ public class MonitoringMibEnricher implements ExternalArtifactEnricherInterface Set<String> fileList = mibs.getFileList(); for (String fileName : fileList) { mibServiceArtifact.setContentData(FileUtils.toByteArray(mibs.getFileContent(fileName))); - mibServiceArtifact.setName(mibInfo.getName() + File.separator + fileName); + mibServiceArtifact.setName(monitoringArtifactInfo.getName() + File.separator + fileName); getEnrichedServiceModelDao().storeExternalArtifact(mibServiceArtifact); } @@ -226,11 +250,11 @@ public class MonitoringMibEnricher implements ExternalArtifactEnricherInterface return componentDao; } - private MibDao getMibDao() { - if (mibDao == null) { - mibDao = MibDaoFactory.getInstance().createInterface(); + private ComponentArtifactDao getComponentArtifactDao() { + if (componentArtifactDao == null) { + componentArtifactDao = MonitoringUploadDaoFactory.getInstance().createInterface(); } - return mibDao; + return componentArtifactDao; } } diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricher.java index 93c4e67fc9..32df165eb3 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricher.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricher.java @@ -1,17 +1,5 @@ package org.openecomp.sdc.enrichment.impl.tosca; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.HIGH_AVAIL_MODE; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MANDATORY; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MAX_INSTANCES; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MIN_INSTANCES; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_NAMING_CODE; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VM_TYPE_TAG; -import static org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType.NATIVE_NODE; -import static org.openecomp.sdc.tosca.datatypes.ToscaNodeType.VFC_ABSTRACT_SUBSTITUTE; -import static org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType.NATIVE_DEPENDS_ON; -import static org.openecomp.sdc.tosca.services.ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME; -import static org.openecomp.sdc.translator.services.heattotosca.Constants.ABSTRACT_NODE_TEMPLATE_ID_PREFIX; - import org.apache.commons.lang3.StringUtils; import org.openecomp.sdc.datatypes.error.ErrorMessage; import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; @@ -29,6 +17,20 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.HIGH_AVAIL_MODE; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MANDATORY; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MAX_INSTANCES; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MIN_INSTANCES; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_CODE; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_FUNCTION; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_NAMING_CODE; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VM_TYPE_TAG; +import static org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType.NATIVE_NODE; +import static org.openecomp.sdc.tosca.datatypes.ToscaNodeType.VFC_ABSTRACT_SUBSTITUTE; +import static org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType.NATIVE_DEPENDS_ON; +import static org.openecomp.sdc.tosca.services.ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME; +import static org.openecomp.sdc.translator.services.heattotosca.Constants.ABSTRACT_NODE_TEMPLATE_ID_PREFIX; + public class AbstractSubstituteToscaEnricher { private ToscaAnalyzerService toscaAnalyzerService ; private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); @@ -108,6 +110,11 @@ public class AbstractSubstituteToscaEnricher { setProperty(nodeTemplate, VFC_NAMING_CODE, getValueFromQuestionnaireDetails (componentProperties, componentDisplayName, VFC_NAMING_CODE)); + setProperty(nodeTemplate, VFC_CODE, getValueFromQuestionnaireDetails + (componentProperties, componentDisplayName, VFC_CODE)); + + setProperty(nodeTemplate, VFC_FUNCTION, getValueFromQuestionnaireDetails + (componentProperties, componentDisplayName, VFC_FUNCTION)); if(componentProperties.get(componentDisplayName).get(MIN_INSTANCES) != null) { nodeTemplate.getProperties().put(MIN_INSTANCES, diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java index 7457c36701..f49c53d79b 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java @@ -1,12 +1,8 @@ package org.openecomp.sdc.enrichment.impl.tosca; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.HIGH_AVAIL_MODE; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MANDATORY; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MAX_INSTANCES; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MIN_INSTANCES; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_NAMING_CODE; import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants; import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao; @@ -23,6 +19,14 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.HIGH_AVAIL_MODE; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MANDATORY; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MAX_INSTANCES; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MIN_INSTANCES; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_NAMING_CODE; + + + public class ComponentQuestionnaireData { ComponentDao componentDao = ComponentDaoFactory.getInstance().createInterface(); @@ -64,6 +68,15 @@ public class ComponentQuestionnaireData { String vfc_code = componentData != null ? componentData.getVfcCode() : null; questionnaireParams.put(VFC_NAMING_CODE, vfc_code); + String nfcCode = componentData.getNfcCode() != null ? componentData.getNfcCode() : null; + questionnaireParams.put(EnrichmentConstants.VFC_CODE, nfcCode); + + String vfcDescription = + componentData.getNfcFunction() != null ? componentData.getNfcFunction() : + null; + questionnaireParams.put(EnrichmentConstants.VFC_FUNCTION, vfcDescription); + + if (componentQuestionnaire.getHighAvailabilityAndLoadBalancing() != null ) { String mandatory = componentQuestionnaire.getHighAvailabilityAndLoadBalancing() .getIsComponentMandatory(); diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/util/EnrichmentConstants.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/util/EnrichmentConstants.java index e803d14b35..036d64014a 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/util/EnrichmentConstants.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/util/EnrichmentConstants.java @@ -8,5 +8,7 @@ public class EnrichmentConstants { public static final String MIN_INSTANCES = "min_instances"; public static final String MAX_INSTANCES = "max_instances"; public static final String VM_TYPE_TAG = "vm_type_tag"; + public static final String VFC_CODE = "nfc_code"; + public static final String VFC_FUNCTION = "nfc_function"; } diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricherTest.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricherTest.java index 7a16b6945d..38f7a1c56e 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricherTest.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricherTest.java @@ -26,16 +26,16 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.openecomp.core.enrichment.types.ArtifactCategory; -import org.openecomp.core.enrichment.types.ArtifactType; +import org.openecomp.core.enrichment.types.MonitoringUploadType; import org.openecomp.core.model.dao.EnrichedServiceModelDao; import org.openecomp.core.model.types.ServiceArtifact; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.sdc.enrichment.EnrichmentInfo; -import org.openecomp.sdc.vendorsoftwareproduct.dao.MibDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.MibEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity; import org.openecomp.sdc.versioning.dao.types.Version; import org.testng.Assert; import org.testng.annotations.BeforeMethod; @@ -60,7 +60,7 @@ import static org.mockito.Mockito.times; public class MonitoringMibEnricherTest { @Mock - private MibDao mibDaoMock; + private ComponentArtifactDao componentArtifactDaoMock; @Mock private EnrichedServiceModelDao enrichedServiceModelDaoMock; @Mock @@ -99,7 +99,7 @@ public class MonitoringMibEnricherTest { .assertEquals(expectedServiceArtifact.getValue().getName().startsWith(componentName), true); Assert.assertEquals(expectedServiceArtifact.getValue().getName(), componentName + File.separator + ArtifactCategory.DEPLOYMENT.getDisplayName() + - File.separator + ArtifactType.SNMP_POLL + File.separator + "mib1.yml"); + File.separator + MonitoringUploadType.VES_EVENTS + File.separator + "mib1.yml"); } @@ -125,20 +125,20 @@ public class MonitoringMibEnricherTest { setMockToEnrichComponent(vspId, componentId1, version); monitoringMibEnricher.enrich(enrichmentInfo); - Mockito.verify(enrichedServiceModelDaoMock, times(8)).storeExternalArtifact(anyObject()); + Mockito.verify(enrichedServiceModelDaoMock, times(12)).storeExternalArtifact(anyObject()); } private void setMockToEnrichComponent(String vspId, String componentId, Version version) { - MibEntity returnedArtifact = new MibEntity(); + ComponentMonitoringUploadEntity returnedArtifact = new ComponentMonitoringUploadEntity(); returnedArtifact.setVspId(vspId); returnedArtifact.setVersion(version); returnedArtifact.setComponentId(componentId); - returnedArtifact.setType(ArtifactType.SNMP_POLL); + returnedArtifact.setType(MonitoringUploadType.SNMP_POLL); returnedArtifact.setArtifactName("mib.zip"); returnedArtifact.setArtifact(getMibByteBuffer("/mock/enrichMib/MIB.zip")); - Mockito.when(mibDaoMock.getByType(anyObject())) + Mockito.when(componentArtifactDaoMock.getByType(anyObject())) .thenReturn(Optional.of(returnedArtifact)); Mockito.doNothing().when(enrichedServiceModelDaoMock).storeExternalArtifact(anyObject()); } diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricherTest.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricherTest.java index ae1b613f75..ca116a9ae3 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricherTest.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricherTest.java @@ -1,13 +1,6 @@ package org.openecomp.sdc.enrichment.impl.tosca; -import static org.mockito.Mockito.when; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.HIGH_AVAIL_MODE; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MANDATORY; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MAX_INSTANCES; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MIN_INSTANCES; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_NAMING_CODE; - import org.apache.commons.collections.map.HashedMap; import org.mockito.InjectMocks; import org.mockito.Mock; @@ -24,6 +17,15 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import static org.mockito.Mockito.when; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.HIGH_AVAIL_MODE; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MANDATORY; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MAX_INSTANCES; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MIN_INSTANCES; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_CODE; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_FUNCTION; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_NAMING_CODE; + public class AbstractSubstituteToscaEnricherTest extends BaseToscaEnrichmentTest { @Mock @@ -51,11 +53,13 @@ public class AbstractSubstituteToscaEnricherTest extends BaseToscaEnrichmentTest loadToscaServiceModel("/mock/enrichHA/in/", "/mock/toscaGlobalServiceTemplates/", "MainServiceTemplate.yaml"); - Map<String, Map<String, Object>> componentTypetoParams = new HashMap(); - Map<String, Object> innerProps = new HashedMap(); + Map<String, Map<String, Object>> componentTypetoParams = new HashMap<>(); + Map<String, Object> innerProps = new HashMap<>(); innerProps.put(MANDATORY, "YES"); innerProps.put(HIGH_AVAIL_MODE, "geo-activestandby"); innerProps.put(VFC_NAMING_CODE, "Code1"); + innerProps.put(VFC_CODE, "pd_server_code"); + innerProps.put(VFC_FUNCTION, "pd_server_description"); innerProps.put(MIN_INSTANCES, 1); innerProps.put(MAX_INSTANCES, 2); @@ -96,6 +100,8 @@ public class AbstractSubstituteToscaEnricherTest extends BaseToscaEnrichmentTest innerProps.put(MANDATORY, "NO"); innerProps.put(HIGH_AVAIL_MODE, ""); innerProps.put(VFC_NAMING_CODE, "pd_server_code1"); + innerProps.put(VFC_CODE, "pd_server_code"); + innerProps.put(VFC_FUNCTION, "pd_server_description"); innerProps.put(MIN_INSTANCES, null); innerProps.put(MAX_INSTANCES, null); diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/BaseToscaEnrichmentTest.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/BaseToscaEnrichmentTest.java index 366bd82eab..4196168b2c 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/BaseToscaEnrichmentTest.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/BaseToscaEnrichmentTest.java @@ -26,7 +26,7 @@ import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; import org.openecomp.sdc.tosca.services.ToscaFileOutputService; import org.openecomp.sdc.tosca.services.ToscaUtil; import org.openecomp.sdc.tosca.services.impl.ToscaFileOutputServiceCsarImpl; -import org.openecomp.sdc.tosca.services.yamlutil.ToscaExtensionYamlUtil; +import org.openecomp.sdc.tosca.services.ToscaExtensionYamlUtil; import java.io.*; import java.net.URL; diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireDataTest.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireDataTest.java index d281604227..d825504d81 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireDataTest.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireDataTest.java @@ -1,12 +1,5 @@ package org.openecomp.sdc.enrichment.impl.tosca; -import static org.mockito.Mockito.doReturn; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.HIGH_AVAIL_MODE; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MANDATORY; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MAX_INSTANCES; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MIN_INSTANCES; -import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_NAMING_CODE; - import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -14,7 +7,6 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; -import org.openecomp.sdc.versioning.VersioningManager; import org.openecomp.sdc.versioning.dao.types.Version; import org.testng.Assert; import org.testng.annotations.BeforeMethod; @@ -25,6 +17,15 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import static org.mockito.Mockito.doReturn; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.HIGH_AVAIL_MODE; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MANDATORY; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MAX_INSTANCES; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MIN_INSTANCES; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_CODE; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_FUNCTION; +import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_NAMING_CODE; + public class ComponentQuestionnaireDataTest { private static String VSP_ID = "vspId"; public static final Version VERSION01 = new Version(0, 1); @@ -47,8 +48,13 @@ public class ComponentQuestionnaireDataTest { @Test public void testGetData() { ComponentEntity componentEntity = new ComponentEntity(VSP_ID, VERSION01,"ID1" ); - componentEntity.setCompositionData("{\"name\": \"org.openecomp.resource.vfc.nodes.heat.be\"," + - "\"displayName\": \"be\", \"vfcCode\": \"be_1\"}"); + componentEntity.setCompositionData("{\n" + + " \"name\": \"org.openecomp.resource.vfc.nodes.heat.be\",\n" + + " \"displayName\": \"be\",\n" + + " \"vfcCode\": \"be_1\",\n" + + " \"nfcCode\": \"code\",\n" + + " \"nfcFunction\": \"desc\"\n" + + "}"); componentEntity.setQuestionnaireData ("{\"highAvailabilityAndLoadBalancing\":{\"isComponentMandatory\" : \"NO\"," + "\"highAvailabilityMode\":\"geo-activeactive\"},\"compute\":{\"numOfVMs\" " + @@ -64,6 +70,8 @@ public class ComponentQuestionnaireDataTest { final Map<String, Object> be = propertiesfromCompQuestionnaire.get("be"); Assert.assertEquals(be.get(VFC_NAMING_CODE) , "be_1"); + Assert.assertEquals(be.get(VFC_CODE), "code"); + Assert.assertEquals(be.get(VFC_FUNCTION), "desc"); Assert.assertEquals(be.get(MANDATORY) ,"NO"); Assert.assertEquals(be.get(HIGH_AVAIL_MODE) ,"geo-activeactive"); Assert.assertEquals(be.get(MIN_INSTANCES) ,null); diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/resources/logback.xml b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/resources/logback.xml new file mode 100644 index 0000000000..31672ca4d9 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/resources/logback.xml @@ -0,0 +1,13 @@ +<!-- only one line, shut up logback ! --> +<configuration> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <Pattern> + %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n + </Pattern> + </encoder> + </appender> + <root level="off"> + <appender-ref ref="STDOUT"/> + </root> +</configuration>
\ No newline at end of file diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/resources/mock/enrichHA/out/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/resources/mock/enrichHA/out/MainServiceTemplate.yaml index 0570cebdc2..18fb820678 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/resources/mock/enrichHA/out/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/resources/mock/enrichHA/out/MainServiceTemplate.yaml @@ -471,6 +471,8 @@ topology_template: vm_type_tag: pd_server high_availablity: geo-activestandby nfc_naming_code: Code1 + nfc_code: pd_server_code + nfc_function: pd_server_description min_instances: 1 max_instances: 2 groups: diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/resources/mock/enrichHANoServiceTemplateFilter/out/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/resources/mock/enrichHANoServiceTemplateFilter/out/MainServiceTemplate.yaml index 3d8cacd11e..9c23c1036c 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/resources/mock/enrichHANoServiceTemplateFilter/out/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/resources/mock/enrichHANoServiceTemplateFilter/out/MainServiceTemplate.yaml @@ -468,6 +468,8 @@ topology_template: service_template_filter: mandatory: false nfc_naming_code: pd_server_code1 + nfc_code: pd_server_code + nfc_function: pd_server_description groups: hot-mog-0108-bs1271_group: type: org.openecomp.groups.heat.HeatStack diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/pom.xml.versionsBackup b/openecomp-be/lib/openecomp-sdc-enrichment-lib/pom.xml.versionsBackup new file mode 100644 index 0000000000..b6e0173b77 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/pom.xml.versionsBackup @@ -0,0 +1,44 @@ +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://maven.apache.org/POM/4.0.0" + 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> + + <name>openecomp-sdc-enrichment-lib</name> + <artifactId>openecomp-sdc-enrichment-lib</artifactId> + + <packaging>pom</packaging> + <parent> + <artifactId>openecomp-sdc-lib</artifactId> + <groupId>org.openecomp.sdc</groupId> + <version>1.0-SNAPSHOT</version> + </parent> + + <modules> + <module>openecomp-sdc-enrichment-api</module> + <module>openecomp-sdc-enrichment-core</module> + <module>openecomp-sdc-enrichment-impl</module> + </modules> + + <dependencies> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-enrichment-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-enrichment-core</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-software-product-core</artifactId> + <version>${project.version}</version> + </dependency> + <!--dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-validation-impl</artifactId> + <version>${project.version}</version> + </dependency--> + </dependencies> +</project>
\ No newline at end of file |