diff options
author | Avi Ziv <avi.ziv@amdocs.com> | 2017-07-18 19:45:38 +0300 |
---|---|---|
committer | Avi Ziv <avi.ziv@amdocs.com> | 2017-07-18 19:45:38 +0300 |
commit | b8e2faf476202b6ffe61bc3a9a37df1304881d40 (patch) | |
tree | f78b8c0517d8e16c5ae610bf8b49f68ea8a312a1 /openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl | |
parent | 75aacbbe1acf78fa53378f07f0a8c7769449a17e (diff) |
[SDC] Onboarding 1710 rebase.
Change-Id: If3b6b81d221fde13908f1e8160db6f7d9433c535
Signed-off-by: Avi Ziv <avi.ziv@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl')
13 files changed, 305 insertions, 95 deletions
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 |