diff options
author | Michael Lando <ml636r@att.com> | 2018-07-29 16:13:45 +0300 |
---|---|---|
committer | Michael Lando <ml636r@att.com> | 2018-07-29 16:20:34 +0300 |
commit | 5b593496b8f1b8e8be8d7d2dbcc223332e65a49b (patch) | |
tree | 2f9dfc45191e723da69cf74be7829784e9741b94 /common-app-api/src | |
parent | 9200382f2ce7b4bb729aa287d0878004b2d2b4f9 (diff) |
re base code
Change-Id: I12a5ca14a6d8a87e9316b9ff362eb131105f98a5
Issue-ID: SDC-1566
Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'common-app-api/src')
139 files changed, 4505 insertions, 7824 deletions
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java index c4f221c875..b0c377c778 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java @@ -20,686 +20,725 @@ package org.openecomp.sdc.be.config; +import org.apache.commons.collections.map.CaseInsensitiveMap; import org.openecomp.sdc.common.api.BasicConfiguration; import java.util.Date; import java.util.List; import java.util.Map; import java.util.Set; -import static java.lang.String.format; +import static java.lang.String.format; import static java.util.Collections.emptyMap; + public class Configuration extends BasicConfiguration { - private List<String> identificationHeaderFields; - /** - * Requests from these Urls will not be logged by - * org.openecomp.sdc.be.filters.BeServletFilter.<br> - **/ - private List<String> unLoggedUrls; - - /** - * backend host - */ - private String beFqdn; - /** - * backend http port - */ - private Integer beHttpPort; - /** - * backend http secured port - */ - private Integer beSslPort; - /** - * be http context - */ - private String beContext; - /** - * backend protocol. http | https - */ - private String beProtocol = "http"; - - private Date released; - private String version = "1111"; - private String toscaConformanceLevel = "3.0"; - private String minToscaConformanceLevel = "3.0"; - private List<String> protocols; - private Map<String, String> users; - private Map<String, Object> neo4j; - private ElasticSearchConfig elasticSearch; - private String titanCfgFile; - private String titanMigrationKeySpaceCfgFile; - private Boolean titanInMemoryGraph; - private int startMigrationFrom; - private Long titanLockTimeout; - private Long titanReconnectIntervalInSeconds; - private List<String> healthStatusExclude; - private Long titanHealthCheckReadTimeout; - private Long esReconnectIntervalInSeconds; - private Long uebHealthCheckReconnectIntervalInSeconds; - private Long uebHealthCheckReadTimeout; - private List<Map<String, Map<String, String>>> defaultImports; - - private List<String> resourceTypes; - private List<String> excludeResourceCategory; - private List<String> excludeResourceType; - private Map<String, Set<String>> excludedPolicyTypesMapping; - - private Map<String, Set<String>> excludedGroupTypesMapping; - private Map<String, Object> deploymentResourceArtifacts; - private Map<String, Object> deploymentResourceInstanceArtifacts; - private Map<String, Object> toscaArtifacts; - private Map<String, Object> informationalResourceArtifacts; - private Map<String, Object> informationalServiceArtifacts; - private Map<String, ArtifactTypeConfig> resourceDeploymentArtifacts; - private Map<String, ArtifactTypeConfig> serviceDeploymentArtifacts; - private Map<String, ArtifactTypeConfig> resourceInstanceDeploymentArtifacts; - private Map<String, ArtifactTypeConfig> resourceInformationalArtifacts; - private Map<String, ArtifactTypeConfig> resourceInformationalDeployedArtifacts; - private Map<String, Object> serviceApiArtifacts; - private List<String> excludeServiceCategory; - private Map<String, Set<String>> requirementsToFulfillBeforeCert; - private Map<String, Set<String>> capabilitiesToConsumeBeforeCert; - - private List<String> artifactTypes; - private List<String> licenseTypes; - - private Integer additionalInformationMaxNumberOfKeys; - private Integer defaultHeatArtifactTimeoutMinutes; - - private BeMonitoringConfig systemMonitoring; - private CleanComponentsConfiguration cleanComponentsConfiguration; - - private String artifactsIndex; - - private String heatEnvArtifactHeader; - private String heatEnvArtifactFooter; - - private String toscaFilesDir; - private String heatTranslatorPath; - - private OnboardingConfig onboarding; - - private DcaeConfig dcae; - - private CassandrConfig cassandraConfig; - - private SwitchoverDetectorConfig switchoverDetector; - - private ApplicationL1CacheConfig applicationL1Cache; - - private ApplicationL2CacheConfig applicationL2Cache; - - private ToscaValidatorsConfig toscaValidators; - - private boolean disableAudit; - - private Map<String, VfModuleProperty> vfModuleProperties; - - private Map<String, String> genericAssetNodeTypes; - - private String appVersion; - private String artifactGeneratorConfig; - - public String getAutoHealingOwner() { - return autoHealingOwner; - } - - public void setAutoHealingOwner(String autoHealingOwner) { - this.autoHealingOwner = autoHealingOwner; - } - - private String autoHealingOwner; - - private Map<String, List<String>> resourcesForUpgrade; - private DmaapConsumerConfiguration dmaapConsumerConfiguration; - private boolean skipUpgradeFailedVfs; - private boolean skipUpgradeVSPs; - private DmeConfiguration dmeConfiguration; - - public DmaapConsumerConfiguration getDmaapConsumerConfiguration() { - return dmaapConsumerConfiguration; - } - - public void setDmaapConsumerConfiguration(DmaapConsumerConfiguration dmaapConsumerConfiguration) { - this.dmaapConsumerConfiguration = dmaapConsumerConfiguration; - } - - public DmeConfiguration getDmeConfiguration() { - return dmeConfiguration; - } - - public void setDmeConfiguration(DmeConfiguration dmeConfiguration) { - this.dmeConfiguration = dmeConfiguration; - } - public void setSkipUpgradeVSPs(boolean skipUpgradeVSPs) { this.skipUpgradeVSPs = skipUpgradeVSPs; } + private List<String> identificationHeaderFields; + /** + * Requests from these Urls will not be logged by + * org.openecomp.sdc.be.filters.BeServletFilter.<br> + **/ + private List<String> unLoggedUrls; + + /** + * backend host + */ + private String beFqdn; + /** + * backend http port + */ + private Integer beHttpPort; + /** + * backend http secured port + */ + private Integer beSslPort; + /** + * be http context + */ + private String beContext; + /** + * backend protocol. http | https + */ + private String beProtocol = "http"; + + private Date released; + private String version = "1111"; + private String toscaConformanceLevel = "3.0"; + private String minToscaConformanceLevel = "3.0"; + private List<String> protocols; + private Map<String, String> users; + private Map<String, Object> neo4j; + private ElasticSearchConfig elasticSearch; + private String titanCfgFile; + private String titanMigrationKeySpaceCfgFile; + private Boolean titanInMemoryGraph; + private int startMigrationFrom; + private Long titanLockTimeout; + private Long titanReconnectIntervalInSeconds; + private List<String> healthStatusExclude; + private Long titanHealthCheckReadTimeout; + private Long esReconnectIntervalInSeconds; + private Long uebHealthCheckReconnectIntervalInSeconds; + private Long uebHealthCheckReadTimeout; + private List<Map<String, Map<String, String>>> defaultImports; + + private List<String> resourceTypes; + private List<String> excludeResourceCategory; + private List<String> excludeResourceType; + private Map<String, Set<String>> excludedPolicyTypesMapping; + + private Map<String, Set<String>> excludedGroupTypesMapping; + private Map<String, Object> deploymentResourceArtifacts; + private Map<String, Object> deploymentResourceInstanceArtifacts; + private Map<String, Object> toscaArtifacts; + private Map<String, Object> informationalResourceArtifacts; + private Map<String, Object> informationalServiceArtifacts; + private Map<String, ArtifactTypeConfig> resourceDeploymentArtifacts; + private Map<String, ArtifactTypeConfig> serviceDeploymentArtifacts; + private Map<String, ArtifactTypeConfig> resourceInstanceDeploymentArtifacts; + private Map<String, ArtifactTypeConfig> resourceInformationalArtifacts; + private Map<String, ArtifactTypeConfig> resourceInformationalDeployedArtifacts; + private Map<String, Object> serviceApiArtifacts; + private List<String> excludeServiceCategory; + private Map<String, Set<String>> requirementsToFulfillBeforeCert; + private Map<String, Set<String>> capabilitiesToConsumeBeforeCert; + + private List<String> artifactTypes; + private List<String> licenseTypes; + + private Integer additionalInformationMaxNumberOfKeys; + private Integer defaultHeatArtifactTimeoutMinutes; + + private BeMonitoringConfig systemMonitoring; + private CleanComponentsConfiguration cleanComponentsConfiguration; + + private String artifactsIndex; + + private String heatEnvArtifactHeader; + private String heatEnvArtifactFooter; + + private String toscaFilesDir; + private String heatTranslatorPath; + + private OnboardingConfig onboarding; + + private DcaeConfig dcae; + + private CassandrConfig cassandraConfig; + + private SwitchoverDetectorConfig switchoverDetector; + + private ApplicationL1CacheConfig applicationL1Cache; + + private ApplicationL2CacheConfig applicationL2Cache; + + private ToscaValidatorsConfig toscaValidators; + + private boolean disableAudit; + + private Map<String, VfModuleProperty> vfModuleProperties; + + private Map<String, String> genericAssetNodeTypes; + + private String appVersion; + private String artifactGeneratorConfig; + + public String getAutoHealingOwner() { + return autoHealingOwner; + } + + public void setAutoHealingOwner(String autoHealingOwner) { + this.autoHealingOwner = autoHealingOwner; + } + + private String autoHealingOwner; + private boolean enableAutoHealing; + + private Map<String, List<String>> resourcesForUpgrade; + private DmaapConsumerConfiguration dmaapConsumerConfiguration; + private boolean skipUpgradeFailedVfs; + private boolean skipUpgradeVSPs; + private DmeConfiguration dmeConfiguration; + + private boolean supportAllottedResourcesAndProxy; + private Integer deleteLockTimeoutInSeconds; + private Integer maxDeleteComponents; + + public Integer getMaxDeleteComponents() { + return maxDeleteComponents; + } + + public void setMaxDeleteComponents(Integer maxDeleteComponents) { + this.maxDeleteComponents = maxDeleteComponents; + } + + public void setEnableAutoHealing(boolean enableAutoHealing) { + this.enableAutoHealing = enableAutoHealing; + } + + public boolean isEnableAutoHealing() { + return enableAutoHealing; + } + + public Integer getDeleteLockTimeoutInSeconds() { + return deleteLockTimeoutInSeconds; + } + + public void setDeleteLockTimeoutInSeconds(Integer deleteLockTimeoutInSeconds) { + this.deleteLockTimeoutInSeconds = deleteLockTimeoutInSeconds; + } + + public DmaapConsumerConfiguration getDmaapConsumerConfiguration() { + return dmaapConsumerConfiguration; + } + + public void setDmaapConsumerConfiguration(DmaapConsumerConfiguration dmaapConsumerConfiguration) { + this.dmaapConsumerConfiguration = dmaapConsumerConfiguration; + } + + public DmeConfiguration getDmeConfiguration() { + return dmeConfiguration; + } + + public void setDmeConfiguration(DmeConfiguration dmeConfiguration) { + this.dmeConfiguration = dmeConfiguration; + } + public void setSkipUpgradeVSPs(boolean skipUpgradeVSPs) { this.skipUpgradeVSPs = skipUpgradeVSPs; } + + public boolean getSkipUpgradeVSPsFlag() { return skipUpgradeVSPs; } + + public boolean getSkipUpgradeFailedVfs() { + return skipUpgradeFailedVfs; + } + + public boolean getSupportAllottedResourcesAndProxyFlag() { + return supportAllottedResourcesAndProxy; + } + + public void setSupportAllottedResourcesAndProxy(boolean supportAllottedResourcesAndProxy) { + this.supportAllottedResourcesAndProxy = supportAllottedResourcesAndProxy; + } + + public void setSkipUpgradeFailedVfs(boolean skipUpgradeFailedVfs) { + this.skipUpgradeFailedVfs = skipUpgradeFailedVfs; + } + + public String getAppVersion() { + return appVersion; + } - public boolean getSkipUpgradeVSPsFlag() { return skipUpgradeVSPs; } + public void setAppVersion(String appVersion) { + this.appVersion = appVersion; + } - public boolean getSkipUpgradeFailedVfs() { - return skipUpgradeFailedVfs; - } + public String getArtifactGeneratorConfig() { + return artifactGeneratorConfig; + } - public void setSkipUpgradeFailedVfs(boolean skipUpgradeFailedVfs) { - this.skipUpgradeFailedVfs = skipUpgradeFailedVfs; - } + public void setArtifactGeneratorConfig(String artifactGeneratorConfig) { + this.artifactGeneratorConfig = artifactGeneratorConfig; + } - public String getAppVersion() { - return appVersion; - } + private String workloadContext; - public void setAppVersion(String appVersion) { - this.appVersion = appVersion; - } + private EnvironmentContext environmentContext; - public String getArtifactGeneratorConfig() { - return artifactGeneratorConfig; - } + public Map<String, String> getGenericAssetNodeTypes() { + return genericAssetNodeTypes; + } - public void setArtifactGeneratorConfig(String artifactGeneratorConfig) { - this.artifactGeneratorConfig = artifactGeneratorConfig; - } + public void setGenericAssetNodeTypes(Map<String, String> genericAssetNodeTypes) { + this.genericAssetNodeTypes = genericAssetNodeTypes; + } - private String workloadContext; - - private EnvironmentContext environmentContext; + public SwitchoverDetectorConfig getSwitchoverDetector() { + return switchoverDetector; + } - public Map<String, String> getGenericAssetNodeTypes() { - return genericAssetNodeTypes; - } + public void setSwitchoverDetector(SwitchoverDetectorConfig switchoverDetector) { + this.switchoverDetector = switchoverDetector; + } - public void setGenericAssetNodeTypes(Map<String, String> genericAssetNodeTypes) { - this.genericAssetNodeTypes = genericAssetNodeTypes; - } + public ApplicationL1CacheConfig getApplicationL1Cache() { + return applicationL1Cache; + } - public SwitchoverDetectorConfig getSwitchoverDetector() { - return switchoverDetector; - } + public void setApplicationL1Cache(ApplicationL1CacheConfig applicationL1Cache) { + this.applicationL1Cache = applicationL1Cache; + } - public void setSwitchoverDetector(SwitchoverDetectorConfig switchoverDetector) { - this.switchoverDetector = switchoverDetector; - } + public ApplicationL2CacheConfig getApplicationL2Cache() { + return applicationL2Cache; + } - public ApplicationL1CacheConfig getApplicationL1Cache() { - return applicationL1Cache; - } + public void setApplicationL2Cache(ApplicationL2CacheConfig applicationL2Cache) { + this.applicationL2Cache = applicationL2Cache; + } - public void setApplicationL1Cache(ApplicationL1CacheConfig applicationL1Cache) { - this.applicationL1Cache = applicationL1Cache; - } + private EcompPortalConfig ecompPortal; - public ApplicationL2CacheConfig getApplicationL2Cache() { - return applicationL2Cache; - } + public CassandrConfig getCassandraConfig() { + return cassandraConfig; + } - public void setApplicationL2Cache(ApplicationL2CacheConfig applicationL2Cache) { - this.applicationL2Cache = applicationL2Cache; - } + public void setCassandraConfig(CassandrConfig cassandraKeySpace) { + this.cassandraConfig = cassandraKeySpace; + } - private EcompPortalConfig ecompPortal; + public List<String> getIdentificationHeaderFields() { + return identificationHeaderFields; + } - public CassandrConfig getCassandraConfig() { - return cassandraConfig; - } + public void setIdentificationHeaderFields(List<String> identificationHeaderFields) { + this.identificationHeaderFields = identificationHeaderFields; + } - public void setCassandraConfig(CassandrConfig cassandraKeySpace) { - this.cassandraConfig = cassandraKeySpace; - } + public Date getReleased() { + return released; + } - public List<String> getIdentificationHeaderFields() { - return identificationHeaderFields; - } + public String getVersion() { + return version; + } - public void setIdentificationHeaderFields(List<String> identificationHeaderFields) { - this.identificationHeaderFields = identificationHeaderFields; - } + public void setReleased(Date released) { + this.released = released; + } - public Date getReleased() { - return released; - } + public void setVersion(String version) { + this.version = version; + } - public String getVersion() { - return version; - } + public List<String> getProtocols() { + return protocols; + } - public void setReleased(Date released) { - this.released = released; - } + public void setProtocols(List<String> protocols) { + this.protocols = protocols; + } - public void setVersion(String version) { - this.version = version; - } + public Map<String, String> getUsers() { + return users; + } - public List<String> getProtocols() { - return protocols; - } + public void setUsers(Map<String, String> users) { + this.users = users; + } - public void setProtocols(List<String> protocols) { - this.protocols = protocols; - } + public String getBeFqdn() { + return beFqdn; + } - public Map<String, String> getUsers() { - return users; - } + public void setBeFqdn(String beHost) { + this.beFqdn = beHost; + } - public void setUsers(Map<String, String> users) { - this.users = users; - } + public Integer getBeHttpPort() { + return beHttpPort; + } - public String getBeFqdn() { - return beFqdn; - } + public void setBeHttpPort(Integer beHttpPort) { + this.beHttpPort = beHttpPort; + } - public void setBeFqdn(String beHost) { - this.beFqdn = beHost; - } + public Integer getBeSslPort() { + return beSslPort; + } - public Integer getBeHttpPort() { - return beHttpPort; - } + public void setBeSslPort(Integer beSslPort) { + this.beSslPort = beSslPort; + } - public void setBeHttpPort(Integer beHttpPort) { - this.beHttpPort = beHttpPort; - } + public String getBeContext() { + return beContext; + } - public Integer getBeSslPort() { - return beSslPort; - } + public void setBeContext(String beContext) { + this.beContext = beContext; + } - public void setBeSslPort(Integer beSslPort) { - this.beSslPort = beSslPort; - } + public String getBeProtocol() { + return beProtocol; + } - public String getBeContext() { - return beContext; - } + public void setBeProtocol(String beProtocol) { + this.beProtocol = beProtocol; + } - public void setBeContext(String beContext) { - this.beContext = beContext; - } + public Map<String, Object> getNeo4j() { + return neo4j; + } - public String getBeProtocol() { - return beProtocol; - } + public void setNeo4j(Map<String, Object> neo4j) { + this.neo4j = neo4j; + } - public void setBeProtocol(String beProtocol) { - this.beProtocol = beProtocol; - } + public ElasticSearchConfig getElasticSearch() { + return elasticSearch; + } - public Map<String, Object> getNeo4j() { - return neo4j; - } + public void setElasticSearch(ElasticSearchConfig elasticSearch) { + this.elasticSearch = elasticSearch; + } - public void setNeo4j(Map<String, Object> neo4j) { - this.neo4j = neo4j; - } + public String getTitanCfgFile() { + return titanCfgFile; + } - public ElasticSearchConfig getElasticSearch() { - return elasticSearch; - } + public void setTitanCfgFile(String titanCfgFile) { + this.titanCfgFile = titanCfgFile; + } - public void setElasticSearch(ElasticSearchConfig elasticSearch) { - this.elasticSearch = elasticSearch; - } + public String getTitanMigrationKeySpaceCfgFile() { + return titanMigrationKeySpaceCfgFile; + } - public String getTitanCfgFile() { - return titanCfgFile; - } + public void setTitanMigrationKeySpaceCfgFile(String titanMigrationKeySpaceCfgFile) { + this.titanMigrationKeySpaceCfgFile = titanMigrationKeySpaceCfgFile; + } - public void setTitanCfgFile(String titanCfgFile) { - this.titanCfgFile = titanCfgFile; - } + public Boolean getTitanInMemoryGraph() { + return titanInMemoryGraph; + } - public String getTitanMigrationKeySpaceCfgFile() { - return titanMigrationKeySpaceCfgFile; - } + public void setTitanInMemoryGraph(Boolean titanInMemoryGraph) { + this.titanInMemoryGraph = titanInMemoryGraph; + } - public void setTitanMigrationKeySpaceCfgFile(String titanMigrationKeySpaceCfgFile) { - this.titanMigrationKeySpaceCfgFile = titanMigrationKeySpaceCfgFile; - } + public int getStartMigrationFrom() { + return startMigrationFrom; + } - public Boolean getTitanInMemoryGraph() { - return titanInMemoryGraph; - } + public void setStartMigrationFrom(int startMigrationFrom) { + this.startMigrationFrom = startMigrationFrom; + } - public void setTitanInMemoryGraph(Boolean titanInMemoryGraph) { - this.titanInMemoryGraph = titanInMemoryGraph; - } + public Long getTitanLockTimeout() { + return titanLockTimeout; + } - public int getStartMigrationFrom() { - return startMigrationFrom; - } + public void setTitanLockTimeout(Long titanLockTimeout) { + this.titanLockTimeout = titanLockTimeout; + } - public void setStartMigrationFrom(int startMigrationFrom) { - this.startMigrationFrom = startMigrationFrom; - } + public Long getTitanHealthCheckReadTimeout() { + return titanHealthCheckReadTimeout; + } - public Long getTitanLockTimeout() { - return titanLockTimeout; - } + public Long getTitanHealthCheckReadTimeout(long defaultVal) { + return titanHealthCheckReadTimeout == null ? defaultVal : titanHealthCheckReadTimeout; + } - public void setTitanLockTimeout(Long titanLockTimeout) { - this.titanLockTimeout = titanLockTimeout; - } + public void setTitanHealthCheckReadTimeout(Long titanHealthCheckReadTimeout) { + this.titanHealthCheckReadTimeout = titanHealthCheckReadTimeout; + } - public Long getTitanHealthCheckReadTimeout() { - return titanHealthCheckReadTimeout; - } + public Long getTitanReconnectIntervalInSeconds() { + return titanReconnectIntervalInSeconds; + } - public Long getTitanHealthCheckReadTimeout(long defaultVal) { - return titanHealthCheckReadTimeout == null ? defaultVal : titanHealthCheckReadTimeout; - } + public Long getTitanReconnectIntervalInSeconds(long defaultVal) { + return titanReconnectIntervalInSeconds == null ? defaultVal : titanReconnectIntervalInSeconds; + } - public void setTitanHealthCheckReadTimeout(Long titanHealthCheckReadTimeout) { - this.titanHealthCheckReadTimeout = titanHealthCheckReadTimeout; - } + public void setTitanReconnectIntervalInSeconds(Long titanReconnectIntervalInSeconds) { + this.titanReconnectIntervalInSeconds = titanReconnectIntervalInSeconds; + } - public Long getTitanReconnectIntervalInSeconds() { - return titanReconnectIntervalInSeconds; - } + public Long getEsReconnectIntervalInSeconds() { + return esReconnectIntervalInSeconds; + } - public Long getTitanReconnectIntervalInSeconds(long defaultVal) { - return titanReconnectIntervalInSeconds == null ? defaultVal : titanReconnectIntervalInSeconds; - } + public Long getEsReconnectIntervalInSeconds(long defaultVal) { + return esReconnectIntervalInSeconds == null ? defaultVal : esReconnectIntervalInSeconds; + } - public void setTitanReconnectIntervalInSeconds(Long titanReconnectIntervalInSeconds) { - this.titanReconnectIntervalInSeconds = titanReconnectIntervalInSeconds; - } + public void setEsReconnectIntervalInSeconds(Long esReconnectIntervalInSeconds) { + this.esReconnectIntervalInSeconds = esReconnectIntervalInSeconds; + } - public Long getEsReconnectIntervalInSeconds() { - return esReconnectIntervalInSeconds; - } - - public Long getEsReconnectIntervalInSeconds(long defaultVal) { - return esReconnectIntervalInSeconds == null ? defaultVal : esReconnectIntervalInSeconds; - } - - public void setEsReconnectIntervalInSeconds(Long esReconnectIntervalInSeconds) { - this.esReconnectIntervalInSeconds = esReconnectIntervalInSeconds; - } - - public List<String> getArtifactTypes() { - return artifactTypes; - } - - public void setArtifactTypes(List<String> artifactTypes) { - this.artifactTypes = artifactTypes; - } - - public List<String> getExcludeResourceCategory() { - return excludeResourceCategory; - } - - public void setExcludeResourceCategory(List<String> excludeResourceCategory) { - this.excludeResourceCategory = excludeResourceCategory; - } - - public List<String> getExcludeResourceType() { - return excludeResourceType; - } - - public void setExcludeResourceType(List<String> excludeResourceType) { - this.excludeResourceType = excludeResourceType; - } - - public Map<String, Set<String>> getExcludedPolicyTypesMapping() { - return safeGetMap(excludedPolicyTypesMapping); - } - - public void setExcludedPolicyTypesMapping(Map<String, Set<String>> excludedPolicyTypesMapping) { - this.excludedPolicyTypesMapping = excludedPolicyTypesMapping; - } - - public Map<String, Set<String>> getExcludedGroupTypesMapping() { - return safeGetMap(excludedGroupTypesMapping); - } - - public void setExcludedGroupTypesMapping(Map<String, Set<String>> excludedGroupTypesMapping) { - this.excludedGroupTypesMapping = excludedGroupTypesMapping; - } - - public Map<String, Object> getToscaArtifacts() { - return toscaArtifacts; - } - - public void setToscaArtifacts(Map<String, Object> toscaArtifacts) { - this.toscaArtifacts = toscaArtifacts; - } - - public Map<String, Object> getInformationalResourceArtifacts() { - return informationalResourceArtifacts; - } - - public void setInformationalResourceArtifacts(Map<String, Object> informationalResourceArtifacts) { - this.informationalResourceArtifacts = informationalResourceArtifacts; - } - - public Map<String, Object> getInformationalServiceArtifacts() { - return informationalServiceArtifacts; - } - - public void setInformationalServiceArtifacts(Map<String, Object> informationalServiceArtifacts) { - this.informationalServiceArtifacts = informationalServiceArtifacts; - } - - public Map<String, Object> getServiceApiArtifacts() { - return serviceApiArtifacts; - } - - public void setServiceApiArtifacts(Map<String, Object> serviceApiArtifacts) { - this.serviceApiArtifacts = serviceApiArtifacts; - } + public List<String> getArtifactTypes() { + return artifactTypes; + } - public Map<String, ArtifactTypeConfig> getServiceDeploymentArtifacts() { - return serviceDeploymentArtifacts; - } + public void setArtifactTypes(List<String> artifactTypes) { + this.artifactTypes = artifactTypes; + } - public void setServiceDeploymentArtifacts(Map<String, ArtifactTypeConfig> serviceDeploymentArtifacts) { - this.serviceDeploymentArtifacts = serviceDeploymentArtifacts; - } + public List<String> getExcludeResourceCategory() { + return excludeResourceCategory; + } - public Map<String, ArtifactTypeConfig> getResourceDeploymentArtifacts() { - return resourceDeploymentArtifacts; - } + public void setExcludeResourceCategory(List<String> excludeResourceCategory) { + this.excludeResourceCategory = excludeResourceCategory; + } - public void setResourceDeploymentArtifacts(Map<String, ArtifactTypeConfig> resourceDeploymentArtifacts) { - this.resourceDeploymentArtifacts = resourceDeploymentArtifacts; - } + public List<String> getExcludeResourceType() { + return excludeResourceType; + } - public void setResourceInstanceDeploymentArtifacts( - Map<String, ArtifactTypeConfig> resourceInstanceDeploymentArtifacts) { - this.resourceInstanceDeploymentArtifacts = resourceInstanceDeploymentArtifacts; - } + public void setExcludeResourceType(List<String> excludeResourceType) { + this.excludeResourceType = excludeResourceType; + } - public Map<String, ArtifactTypeConfig> getResourceInstanceDeploymentArtifacts() { - return resourceInstanceDeploymentArtifacts; - } + public Map<String, Set<String>> getExcludedPolicyTypesMapping() { + return safeGetCapsInsensitiveMap(excludedPolicyTypesMapping); + } - public List<String> getExcludeServiceCategory() { - return excludeServiceCategory; - } + public void setExcludedPolicyTypesMapping(Map<String, Set<String>> excludedPolicyTypesMapping) { + this.excludedPolicyTypesMapping = excludedPolicyTypesMapping; + } - public void setExcludeServiceCategory(List<String> excludeServiceCategory) { - this.excludeServiceCategory = excludeServiceCategory; - } + public Map<String, Set<String>> getExcludedGroupTypesMapping() { + return safeGetCapsInsensitiveMap(excludedGroupTypesMapping); + } - public List<String> getLicenseTypes() { - return licenseTypes; - } + public void setExcludedGroupTypesMapping(Map<String, Set<String>> excludedGroupTypesMapping) { + this.excludedGroupTypesMapping = excludedGroupTypesMapping; + } - public void setLicenseTypes(List<String> licenseTypes) { - this.licenseTypes = licenseTypes; - } - - public Integer getAdditionalInformationMaxNumberOfKeys() { - return additionalInformationMaxNumberOfKeys; - } - - public void setAdditionalInformationMaxNumberOfKeys(Integer additionalInformationMaxNumberOfKeys) { - this.additionalInformationMaxNumberOfKeys = additionalInformationMaxNumberOfKeys; - } - - public BeMonitoringConfig getSystemMonitoring() { - return systemMonitoring; - } - - public void setSystemMonitoring(BeMonitoringConfig systemMonitoring) { - this.systemMonitoring = systemMonitoring; - } - - public Integer getDefaultHeatArtifactTimeoutMinutes() { - return defaultHeatArtifactTimeoutMinutes; - } - - public void setDefaultHeatArtifactTimeoutMinutes(Integer defaultHeatArtifactTimeoutMinutes) { - this.defaultHeatArtifactTimeoutMinutes = defaultHeatArtifactTimeoutMinutes; - } - - public Long getUebHealthCheckReconnectIntervalInSeconds() { - return uebHealthCheckReconnectIntervalInSeconds; - } - - public void setUebHealthCheckReconnectIntervalInSeconds(Long uebHealthCheckReconnectIntervalInSeconds) { - this.uebHealthCheckReconnectIntervalInSeconds = uebHealthCheckReconnectIntervalInSeconds; - } - - public Long getUebHealthCheckReadTimeout() { - return uebHealthCheckReadTimeout; - } - - public void setUebHealthCheckReadTimeout(Long uebHealthCheckReadTimeout) { - this.uebHealthCheckReadTimeout = uebHealthCheckReadTimeout; - } - - public String getWorkloadContext() { - return workloadContext; - } - - public void setWorkloadContext(String workloadContext) { - this.workloadContext = workloadContext; - } - - public EnvironmentContext getEnvironmentContext() { - return environmentContext; - } - - public void setEnvironmentContext(EnvironmentContext environmentContext) { - this.environmentContext = environmentContext; - } - - public static class ElasticSearchConfig { + public Map<String, Object> getToscaArtifacts() { + return toscaArtifacts; + } - List<IndicesTimeFrequencyEntry> indicesTimeFrequency; - - public List<IndicesTimeFrequencyEntry> getIndicesTimeFrequency() { - return indicesTimeFrequency; - } - - public void setIndicesTimeFrequency(List<IndicesTimeFrequencyEntry> indicesTimeFrequency) { - this.indicesTimeFrequency = indicesTimeFrequency; - } - - public static class IndicesTimeFrequencyEntry { + public void setToscaArtifacts(Map<String, Object> toscaArtifacts) { + this.toscaArtifacts = toscaArtifacts; + } - String indexPrefix; - String creationPeriod; + public Map<String, Object> getInformationalResourceArtifacts() { + return informationalResourceArtifacts; + } - public String getIndexPrefix() { - return indexPrefix; - } + public void setInformationalResourceArtifacts(Map<String, Object> informationalResourceArtifacts) { + this.informationalResourceArtifacts = informationalResourceArtifacts; + } - public void setIndexPrefix(String indexPrefix) { - this.indexPrefix = indexPrefix; - } + public Map<String, Object> getInformationalServiceArtifacts() { + return informationalServiceArtifacts; + } - public String getCreationPeriod() { - return creationPeriod; - } + public void setInformationalServiceArtifacts(Map<String, Object> informationalServiceArtifacts) { + this.informationalServiceArtifacts = informationalServiceArtifacts; + } - public void setCreationPeriod(String creationPeriod) { - this.creationPeriod = creationPeriod; - } - } - } + public Map<String, Object> getServiceApiArtifacts() { + return serviceApiArtifacts; + } - public static class CassandrConfig { + public void setServiceApiArtifacts(Map<String, Object> serviceApiArtifacts) { + this.serviceApiArtifacts = serviceApiArtifacts; + } - List<String> cassandraHosts; - String localDataCenter; - Long reconnectTimeout; - Integer socketReadTimeout; - Integer socketConnectTimeout; - List<KeyspaceConfig> keySpaces; - boolean authenticate; - String username; - String password; - boolean ssl; - String truststorePath; - String truststorePassword; + public Map<String, ArtifactTypeConfig> getServiceDeploymentArtifacts() { + return serviceDeploymentArtifacts; + } - public String getLocalDataCenter() { - return localDataCenter; - } + public void setServiceDeploymentArtifacts(Map<String, ArtifactTypeConfig> serviceDeploymentArtifacts) { + this.serviceDeploymentArtifacts = serviceDeploymentArtifacts; + } - public void setLocalDataCenter(String localDataCenter) { - this.localDataCenter = localDataCenter; - } + public Map<String, ArtifactTypeConfig> getResourceDeploymentArtifacts() { + return resourceDeploymentArtifacts; + } - public boolean isAuthenticate() { - return authenticate; - } + public void setResourceDeploymentArtifacts(Map<String, ArtifactTypeConfig> resourceDeploymentArtifacts) { + this.resourceDeploymentArtifacts = resourceDeploymentArtifacts; + } - public void setAuthenticate(boolean authenticate) { - this.authenticate = authenticate; - } + public void setResourceInstanceDeploymentArtifacts( + Map<String, ArtifactTypeConfig> resourceInstanceDeploymentArtifacts) { + this.resourceInstanceDeploymentArtifacts = resourceInstanceDeploymentArtifacts; + } - public String getUsername() { - return username; - } + public Map<String, ArtifactTypeConfig> getResourceInstanceDeploymentArtifacts() { + return resourceInstanceDeploymentArtifacts; + } - public void setUsername(String username) { - this.username = username; - } + public List<String> getExcludeServiceCategory() { + return excludeServiceCategory; + } - public String getPassword() { - return password; - } + public void setExcludeServiceCategory(List<String> excludeServiceCategory) { + this.excludeServiceCategory = excludeServiceCategory; + } - public void setPassword(String password) { - this.password = password; - } + public List<String> getLicenseTypes() { + return licenseTypes; + } - public boolean isSsl() { - return ssl; - } + public void setLicenseTypes(List<String> licenseTypes) { + this.licenseTypes = licenseTypes; + } - public void setSsl(boolean ssl) { - this.ssl = ssl; - } + public Integer getAdditionalInformationMaxNumberOfKeys() { + return additionalInformationMaxNumberOfKeys; + } + + public void setAdditionalInformationMaxNumberOfKeys(Integer additionalInformationMaxNumberOfKeys) { + this.additionalInformationMaxNumberOfKeys = additionalInformationMaxNumberOfKeys; + } + + public BeMonitoringConfig getSystemMonitoring() { + return systemMonitoring; + } + + public void setSystemMonitoring(BeMonitoringConfig systemMonitoring) { + this.systemMonitoring = systemMonitoring; + } + + public Integer getDefaultHeatArtifactTimeoutMinutes() { + return defaultHeatArtifactTimeoutMinutes; + } + + public void setDefaultHeatArtifactTimeoutMinutes(Integer defaultHeatArtifactTimeoutMinutes) { + this.defaultHeatArtifactTimeoutMinutes = defaultHeatArtifactTimeoutMinutes; + } + + public Long getUebHealthCheckReconnectIntervalInSeconds() { + return uebHealthCheckReconnectIntervalInSeconds; + } + + public void setUebHealthCheckReconnectIntervalInSeconds(Long uebHealthCheckReconnectIntervalInSeconds) { + this.uebHealthCheckReconnectIntervalInSeconds = uebHealthCheckReconnectIntervalInSeconds; + } + + public Long getUebHealthCheckReadTimeout() { + return uebHealthCheckReadTimeout; + } + + public void setUebHealthCheckReadTimeout(Long uebHealthCheckReadTimeout) { + this.uebHealthCheckReadTimeout = uebHealthCheckReadTimeout; + } + + public String getWorkloadContext() { + return workloadContext; + } + + public void setWorkloadContext(String workloadContext) { + this.workloadContext = workloadContext; + } + + public EnvironmentContext getEnvironmentContext() { + return environmentContext; + } + + public void setEnvironmentContext(EnvironmentContext environmentContext) { + this.environmentContext = environmentContext; + } + + public static class ElasticSearchConfig { - public String getTruststorePath() { - return truststorePath; - } + List<IndicesTimeFrequencyEntry> indicesTimeFrequency; + + public List<IndicesTimeFrequencyEntry> getIndicesTimeFrequency() { + return indicesTimeFrequency; + } + + public void setIndicesTimeFrequency(List<IndicesTimeFrequencyEntry> indicesTimeFrequency) { + this.indicesTimeFrequency = indicesTimeFrequency; + } + + public static class IndicesTimeFrequencyEntry { - public void setTruststorePath(String truststorePath) { - this.truststorePath = truststorePath; - } + String indexPrefix; + String creationPeriod; - public String getTruststorePassword() { - return truststorePassword; - } + public String getIndexPrefix() { + return indexPrefix; + } - public void setTruststorePassword(String truststorePassword) { - this.truststorePassword = truststorePassword; - } - - public Long getReconnectTimeout() { - return reconnectTimeout; - } - - public void setReconnectTimeout(Long reconnectTimeout) { - this.reconnectTimeout = reconnectTimeout; - } + public void setIndexPrefix(String indexPrefix) { + this.indexPrefix = indexPrefix; + } + + public String getCreationPeriod() { + return creationPeriod; + } + + public void setCreationPeriod(String creationPeriod) { + this.creationPeriod = creationPeriod; + } + } + } + + public static class CassandrConfig { + + List<String> cassandraHosts; + String localDataCenter; + Long reconnectTimeout; + Integer socketReadTimeout; + Integer socketConnectTimeout; + List<KeyspaceConfig> keySpaces; + boolean authenticate; + String username; + String password; + boolean ssl; + String truststorePath; + String truststorePassword; + + public String getLocalDataCenter() { + return localDataCenter; + } + + public void setLocalDataCenter(String localDataCenter) { + this.localDataCenter = localDataCenter; + } + + public boolean isAuthenticate() { + return authenticate; + } + + public void setAuthenticate(boolean authenticate) { + this.authenticate = authenticate; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public boolean isSsl() { + return ssl; + } + + public void setSsl(boolean ssl) { + this.ssl = ssl; + } + + public String getTruststorePath() { + return truststorePath; + } + + public void setTruststorePath(String truststorePath) { + this.truststorePath = truststorePath; + } + + public String getTruststorePassword() { + return truststorePassword; + } + + public void setTruststorePassword(String truststorePassword) { + this.truststorePassword = truststorePassword; + } + + public Long getReconnectTimeout() { + return reconnectTimeout; + } + + public void setReconnectTimeout(Long reconnectTimeout) { + this.reconnectTimeout = reconnectTimeout; + } public Integer getSocketReadTimeout() { return socketReadTimeout; } @@ -709,843 +748,843 @@ public class Configuration extends BasicConfiguration { public void setSocketConnectTimeout(Integer socketConnectTimeout) { this.socketConnectTimeout = socketConnectTimeout; } - public List<String> getCassandraHosts() { - return cassandraHosts; - } - - public void setCassandraHosts(List<String> cassandraHosts) { - this.cassandraHosts = cassandraHosts; - } - - public List<KeyspaceConfig> getKeySpaces() { - return keySpaces; - } - - public void setKeySpaces(List<KeyspaceConfig> cassandraConfig) { - this.keySpaces = cassandraConfig; - } - - public static class KeyspaceConfig { - - String name; - String replicationStrategy; - List<String> replicationInfo; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getReplicationStrategy() { - return replicationStrategy; - } - - public void setReplicationStrategy(String replicationStrategy) { - this.replicationStrategy = replicationStrategy; - } - - public List<String> getReplicationInfo() { - return replicationInfo; - } - - public void setReplicationInfo(List<String> replicationInfo) { - this.replicationInfo = replicationInfo; - } - } - } - - public static class SwitchoverDetectorConfig { - - String gBeFqdn; - String gFeFqdn; - String beVip; - String feVip; - int beResolveAttempts; - int feResolveAttempts; - Boolean enabled; - long interval; - String changePriorityUser; - String changePriorityPassword; - String publishNetworkUrl; - String publishNetworkBody; - Map<String, GroupInfo> groups; - - public String getgBeFqdn() { - return gBeFqdn; - } - - public void setgBeFqdn(String gBeFqdn) { - this.gBeFqdn = gBeFqdn; - } - - public String getgFeFqdn() { - return gFeFqdn; - } - - public void setgFeFqdn(String gFeFqdn) { - this.gFeFqdn = gFeFqdn; - } - - public String getBeVip() { - return beVip; - } - - public void setBeVip(String beVip) { - this.beVip = beVip; - } - - public String getFeVip() { - return feVip; - } + public List<String> getCassandraHosts() { + return cassandraHosts; + } + + public void setCassandraHosts(List<String> cassandraHosts) { + this.cassandraHosts = cassandraHosts; + } + + public List<KeyspaceConfig> getKeySpaces() { + return keySpaces; + } + + public void setKeySpaces(List<KeyspaceConfig> cassandraConfig) { + this.keySpaces = cassandraConfig; + } + + public static class KeyspaceConfig { + + String name; + String replicationStrategy; + List<String> replicationInfo; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getReplicationStrategy() { + return replicationStrategy; + } + + public void setReplicationStrategy(String replicationStrategy) { + this.replicationStrategy = replicationStrategy; + } + + public List<String> getReplicationInfo() { + return replicationInfo; + } + + public void setReplicationInfo(List<String> replicationInfo) { + this.replicationInfo = replicationInfo; + } + } + } + + public static class SwitchoverDetectorConfig { + + String gBeFqdn; + String gFeFqdn; + String beVip; + String feVip; + int beResolveAttempts; + int feResolveAttempts; + Boolean enabled; + long interval; + String changePriorityUser; + String changePriorityPassword; + String publishNetworkUrl; + String publishNetworkBody; + Map<String, GroupInfo> groups; + + public String getgBeFqdn() { + return gBeFqdn; + } + + public void setgBeFqdn(String gBeFqdn) { + this.gBeFqdn = gBeFqdn; + } + + public String getgFeFqdn() { + return gFeFqdn; + } + + public void setgFeFqdn(String gFeFqdn) { + this.gFeFqdn = gFeFqdn; + } + + public String getBeVip() { + return beVip; + } + + public void setBeVip(String beVip) { + this.beVip = beVip; + } + + public String getFeVip() { + return feVip; + } - public void setFeVip(String feVip) { - this.feVip = feVip; - } + public void setFeVip(String feVip) { + this.feVip = feVip; + } - public int getBeResolveAttempts() { - return beResolveAttempts; - } + public int getBeResolveAttempts() { + return beResolveAttempts; + } - public void setBeResolveAttempts(int beResolveAttempts) { - this.beResolveAttempts = beResolveAttempts; - } + public void setBeResolveAttempts(int beResolveAttempts) { + this.beResolveAttempts = beResolveAttempts; + } - public int getFeResolveAttempts() { - return feResolveAttempts; - } + public int getFeResolveAttempts() { + return feResolveAttempts; + } - public void setFeResolveAttempts(int feResolveAttempts) { - this.feResolveAttempts = feResolveAttempts; - } + public void setFeResolveAttempts(int feResolveAttempts) { + this.feResolveAttempts = feResolveAttempts; + } - public Boolean getEnabled() { - return enabled; - } + public Boolean getEnabled() { + return enabled; + } - public void setEnabled(Boolean enabled) { - this.enabled = enabled; - } - - public long getInterval() { - return interval; - } - - public void setInterval(long interval) { - this.interval = interval; - } - - public String getChangePriorityUser() { - return changePriorityUser; - } + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public long getInterval() { + return interval; + } + + public void setInterval(long interval) { + this.interval = interval; + } + + public String getChangePriorityUser() { + return changePriorityUser; + } - public void setChangePriorityUser(String changePriorityUser) { - this.changePriorityUser = changePriorityUser; - } + public void setChangePriorityUser(String changePriorityUser) { + this.changePriorityUser = changePriorityUser; + } - public String getChangePriorityPassword() { - return changePriorityPassword; - } + public String getChangePriorityPassword() { + return changePriorityPassword; + } - public void setChangePriorityPassword(String changePriorityPassword) { - this.changePriorityPassword = changePriorityPassword; - } + public void setChangePriorityPassword(String changePriorityPassword) { + this.changePriorityPassword = changePriorityPassword; + } - public String getPublishNetworkUrl() { - return publishNetworkUrl; - } + public String getPublishNetworkUrl() { + return publishNetworkUrl; + } - public void setPublishNetworkUrl(String publishNetworkUrl) { - this.publishNetworkUrl = publishNetworkUrl; - } + public void setPublishNetworkUrl(String publishNetworkUrl) { + this.publishNetworkUrl = publishNetworkUrl; + } - public String getPublishNetworkBody() { - return publishNetworkBody; - } + public String getPublishNetworkBody() { + return publishNetworkBody; + } - public void setPublishNetworkBody(String publishNetworkBody) { - this.publishNetworkBody = publishNetworkBody; - } + public void setPublishNetworkBody(String publishNetworkBody) { + this.publishNetworkBody = publishNetworkBody; + } - public Map<String, GroupInfo> getGroups() { - return groups; - } + public Map<String, GroupInfo> getGroups() { + return groups; + } - public void setGroups(Map<String, GroupInfo> groups) { - this.groups = groups; - } + public void setGroups(Map<String, GroupInfo> groups) { + this.groups = groups; + } - public static class GroupInfo { + public static class GroupInfo { - String changePriorityUrl; - String changePriorityBody; + String changePriorityUrl; + String changePriorityBody; - public String getChangePriorityUrl() { - return changePriorityUrl; - } + public String getChangePriorityUrl() { + return changePriorityUrl; + } - public void setChangePriorityUrl(String changePriorityUrl) { - this.changePriorityUrl = changePriorityUrl; - } + public void setChangePriorityUrl(String changePriorityUrl) { + this.changePriorityUrl = changePriorityUrl; + } - public String getChangePriorityBody() { - return changePriorityBody; - } + public String getChangePriorityBody() { + return changePriorityBody; + } - public void setChangePriorityBody(String changePriorityBody) { - this.changePriorityBody = changePriorityBody; - } - } + public void setChangePriorityBody(String changePriorityBody) { + this.changePriorityBody = changePriorityBody; + } + } - } + } - public static class BeMonitoringConfig { + public static class BeMonitoringConfig { - Boolean enabled; - Boolean isProxy; - Integer probeIntervalInSeconds; + Boolean enabled; + Boolean isProxy; + Integer probeIntervalInSeconds; - public Boolean getEnabled() { - return enabled; - } + public Boolean getEnabled() { + return enabled; + } - public void setEnabled(Boolean enabled) { - this.enabled = enabled; - } + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } - public Boolean getIsProxy() { - return isProxy; - } + public Boolean getIsProxy() { + return isProxy; + } - public void setIsProxy(Boolean isProxy) { - this.isProxy = isProxy; - } + public void setIsProxy(Boolean isProxy) { + this.isProxy = isProxy; + } - public Integer getProbeIntervalInSeconds() { - return probeIntervalInSeconds; - } + public Integer getProbeIntervalInSeconds() { + return probeIntervalInSeconds; + } - public Integer getProbeIntervalInSeconds(int defaultVal) { - return probeIntervalInSeconds == null ? defaultVal : probeIntervalInSeconds; - } + public Integer getProbeIntervalInSeconds(int defaultVal) { + return probeIntervalInSeconds == null ? defaultVal : probeIntervalInSeconds; + } - public void setProbeIntervalInSeconds(Integer probeIntervalInSeconds) { - this.probeIntervalInSeconds = probeIntervalInSeconds; - } - } + public void setProbeIntervalInSeconds(Integer probeIntervalInSeconds) { + this.probeIntervalInSeconds = probeIntervalInSeconds; + } + } - public static class ArtifactTypeConfig { + public static class ArtifactTypeConfig { - List<String> acceptedTypes; - List<String> validForResourceTypes; + List<String> acceptedTypes; + List<String> validForResourceTypes; - public List<String> getValidForResourceTypes() { - return validForResourceTypes; - } + public List<String> getValidForResourceTypes() { + return validForResourceTypes; + } - public void setValidForResourceTypes(List<String> validForResourceTypes) { - this.validForResourceTypes = validForResourceTypes; - } + public void setValidForResourceTypes(List<String> validForResourceTypes) { + this.validForResourceTypes = validForResourceTypes; + } - public List<String> getAcceptedTypes() { - return acceptedTypes; - } + public List<String> getAcceptedTypes() { + return acceptedTypes; + } - public void setAcceptedTypes(List<String> acceptedTypes) { - this.acceptedTypes = acceptedTypes; - } - } + public void setAcceptedTypes(List<String> acceptedTypes) { + this.acceptedTypes = acceptedTypes; + } + } - public static class OnboardingConfig { + public static class OnboardingConfig { - String protocol = "http"; - String host; - Integer port; - String downloadCsarUri; - String healthCheckUri; + String protocol = "http"; + String host; + Integer port; + String downloadCsarUri; + String healthCheckUri; - public String getProtocol() { - return protocol; - } + public String getProtocol() { + return protocol; + } - public void setProtocol(String protocol) { - this.protocol = protocol; - } + public void setProtocol(String protocol) { + this.protocol = protocol; + } - public String getHost() { - return host; - } + public String getHost() { + return host; + } - public void setHost(String host) { - this.host = host; - } + public void setHost(String host) { + this.host = host; + } - public Integer getPort() { - return port; - } + public Integer getPort() { + return port; + } - public void setPort(Integer port) { - this.port = port; - } + public void setPort(Integer port) { + this.port = port; + } - public String getDownloadCsarUri() { - return downloadCsarUri; - } + public String getDownloadCsarUri() { + return downloadCsarUri; + } - public void setDownloadCsarUri(String downloadCsarUri) { - this.downloadCsarUri = downloadCsarUri; - } + public void setDownloadCsarUri(String downloadCsarUri) { + this.downloadCsarUri = downloadCsarUri; + } - public String getHealthCheckUri() { - return healthCheckUri; - } + public String getHealthCheckUri() { + return healthCheckUri; + } - public void setHealthCheckUri(String healthCheckUri) { - this.healthCheckUri = healthCheckUri; - } + public void setHealthCheckUri(String healthCheckUri) { + this.healthCheckUri = healthCheckUri; + } - @Override - public String toString() { - return "OnboardingConfig [protocol=" + protocol + ", host=" + host + ", port=" + port + ", downloadCsarUri=" - + downloadCsarUri + "]"; - } + @Override + public String toString() { + return "OnboardingConfig [protocol=" + protocol + ", host=" + host + ", port=" + port + ", downloadCsarUri=" + + downloadCsarUri + "]"; + } - } + } - public DcaeConfig getDcae() { - return dcae; - } + public DcaeConfig getDcae() { + return dcae; + } - public void setDcae(DcaeConfig dcae) { - this.dcae = dcae; - } + public void setDcae(DcaeConfig dcae) { + this.dcae = dcae; + } - public static class DcaeConfig { + public static class DcaeConfig { - String protocol = "http"; - String host; - Integer port; - String healthCheckUri; + String protocol = "http"; + String host; + Integer port; + String healthCheckUri; - public String getProtocol() { - return protocol; - } + public String getProtocol() { + return protocol; + } - public void setProtocol(String protocol) { - this.protocol = protocol; - } + public void setProtocol(String protocol) { + this.protocol = protocol; + } - public String getHost() { - return host; - } + public String getHost() { + return host; + } - public void setHost(String host) { - this.host = host; - } + public void setHost(String host) { + this.host = host; + } - public Integer getPort() { - return port; - } + public Integer getPort() { + return port; + } - public void setPort(Integer port) { - this.port = port; - } + public void setPort(Integer port) { + this.port = port; + } - public String getHealthCheckUri() { - return healthCheckUri; - } + public String getHealthCheckUri() { + return healthCheckUri; + } - public void setHealthCheckUri(String healthCheckUri) { - this.healthCheckUri = healthCheckUri; - } - } + public void setHealthCheckUri(String healthCheckUri) { + this.healthCheckUri = healthCheckUri; + } + } - public static class EcompPortalConfig { + public static class EcompPortalConfig { - private String defaultFunctionalMenu; + private String defaultFunctionalMenu; - public String getDefaultFunctionalMenu() { - return defaultFunctionalMenu; - } + public String getDefaultFunctionalMenu() { + return defaultFunctionalMenu; + } - public void setDefaultFunctionalMenu(String defaultFunctionalMenu) { - this.defaultFunctionalMenu = defaultFunctionalMenu; - } + public void setDefaultFunctionalMenu(String defaultFunctionalMenu) { + this.defaultFunctionalMenu = defaultFunctionalMenu; + } - @Override - public String toString() { - return "EcompPortalConfig [defaultFunctionalMenu=" + defaultFunctionalMenu + "]"; - } + @Override + public String toString() { + return "EcompPortalConfig [defaultFunctionalMenu=" + defaultFunctionalMenu + "]"; + } - } + } - public static class ApplicationL1CacheConfig { + public static class ApplicationL1CacheConfig { - ApplicationL1CacheInfo datatypes; + ApplicationL1CacheInfo datatypes; - public ApplicationL1CacheInfo getDatatypes() { - return datatypes; - } + public ApplicationL1CacheInfo getDatatypes() { + return datatypes; + } - public void setDatatypes(ApplicationL1CacheInfo datatypes) { - this.datatypes = datatypes; - } + public void setDatatypes(ApplicationL1CacheInfo datatypes) { + this.datatypes = datatypes; + } - @Override - public String toString() { - return "ApplicationL1CacheConfig [datatypes=" + datatypes + "]"; - } + @Override + public String toString() { + return "ApplicationL1CacheConfig [datatypes=" + datatypes + "]"; + } - } + } - public static class ApplicationL2CacheConfig { + public static class ApplicationL2CacheConfig { - boolean enabled; - ApplicationL1CacheCatalogInfo catalogL1Cache; + boolean enabled; + ApplicationL1CacheCatalogInfo catalogL1Cache; - QueueInfo queue; + QueueInfo queue; - public boolean isEnabled() { - return enabled; - } + public boolean isEnabled() { + return enabled; + } - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } - public ApplicationL1CacheCatalogInfo getCatalogL1Cache() { - return catalogL1Cache; - } + public ApplicationL1CacheCatalogInfo getCatalogL1Cache() { + return catalogL1Cache; + } - public void setCatalogL1Cache(ApplicationL1CacheCatalogInfo catalogL1Cache) { - this.catalogL1Cache = catalogL1Cache; - } + public void setCatalogL1Cache(ApplicationL1CacheCatalogInfo catalogL1Cache) { + this.catalogL1Cache = catalogL1Cache; + } - public QueueInfo getQueue() { - return queue; - } + public QueueInfo getQueue() { + return queue; + } - public void setQueue(QueueInfo queue) { - this.queue = queue; - } + public void setQueue(QueueInfo queue) { + this.queue = queue; + } - @Override - public String toString() { - return "ApplicationL2CacheConfig [enabled=" + enabled + ", catalogL1Cache=" + catalogL1Cache + "]"; - } + @Override + public String toString() { + return "ApplicationL2CacheConfig [enabled=" + enabled + ", catalogL1Cache=" + catalogL1Cache + "]"; + } - } + } - public static class ToscaValidatorsConfig { + public static class ToscaValidatorsConfig { - private Integer stringMaxLength; + private Integer stringMaxLength; - public Integer getStringMaxLength() { - return stringMaxLength; - } + public Integer getStringMaxLength() { + return stringMaxLength; + } - public void setStringMaxLength(Integer stringMaxLength) { - this.stringMaxLength = stringMaxLength; - } + public void setStringMaxLength(Integer stringMaxLength) { + this.stringMaxLength = stringMaxLength; + } - @Override - public String toString() { - return "ToscaValidatorsConfig [stringMaxLength=" + stringMaxLength + "]"; - } + @Override + public String toString() { + return "ToscaValidatorsConfig [stringMaxLength=" + stringMaxLength + "]"; + } - } + } - public static class ApplicationL1CacheInfo { + public static class ApplicationL1CacheInfo { - Boolean enabled; - Integer firstRunDelay; - Integer pollIntervalInSec; + Boolean enabled; + Integer firstRunDelay; + Integer pollIntervalInSec; - public Boolean getEnabled() { - return enabled; - } + public Boolean getEnabled() { + return enabled; + } - public void setEnabled(Boolean enabled) { - this.enabled = enabled; - } + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } - public Integer getFirstRunDelay() { - return firstRunDelay; - } + public Integer getFirstRunDelay() { + return firstRunDelay; + } - public void setFirstRunDelay(Integer firstRunDelay) { - this.firstRunDelay = firstRunDelay; - } + public void setFirstRunDelay(Integer firstRunDelay) { + this.firstRunDelay = firstRunDelay; + } - public Integer getPollIntervalInSec() { - return pollIntervalInSec; - } + public Integer getPollIntervalInSec() { + return pollIntervalInSec; + } - public void setPollIntervalInSec(Integer pollIntervalInSec) { - this.pollIntervalInSec = pollIntervalInSec; - } + public void setPollIntervalInSec(Integer pollIntervalInSec) { + this.pollIntervalInSec = pollIntervalInSec; + } - @Override - public String toString() { - return "ApplicationL1CacheInfo [enabled=" + enabled + ", firstRunDelay=" + firstRunDelay - + ", pollIntervalInSec=" + pollIntervalInSec + "]"; - } - } + @Override + public String toString() { + return "ApplicationL1CacheInfo [enabled=" + enabled + ", firstRunDelay=" + firstRunDelay + + ", pollIntervalInSec=" + pollIntervalInSec + "]"; + } + } - public static class ApplicationL1CacheCatalogInfo { + public static class ApplicationL1CacheCatalogInfo { - Boolean enabled; - Integer resourcesSizeInCache; - Integer servicesSizeInCache; - Integer productsSizeInCache; + Boolean enabled; + Integer resourcesSizeInCache; + Integer servicesSizeInCache; + Integer productsSizeInCache; - public Boolean getEnabled() { - return enabled; - } + public Boolean getEnabled() { + return enabled; + } - public void setEnabled(Boolean enabled) { - this.enabled = enabled; - } + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } - public Integer getResourcesSizeInCache() { - return resourcesSizeInCache; - } + public Integer getResourcesSizeInCache() { + return resourcesSizeInCache; + } - public void setResourcesSizeInCache(Integer resourcesSizeInCache) { - this.resourcesSizeInCache = resourcesSizeInCache; - } + public void setResourcesSizeInCache(Integer resourcesSizeInCache) { + this.resourcesSizeInCache = resourcesSizeInCache; + } - public Integer getServicesSizeInCache() { - return servicesSizeInCache; - } - - public void setServicesSizeInCache(Integer servicesSizeInCache) { - this.servicesSizeInCache = servicesSizeInCache; - } - - public Integer getProductsSizeInCache() { - return productsSizeInCache; - } - - public void setProductsSizeInCache(Integer productsSizeInCache) { - this.productsSizeInCache = productsSizeInCache; - } - - @Override - public String toString() { - return "ApplicationL1CacheCatalogInfo [enabled=" + enabled + ", resourcesSizeInCache=" - + resourcesSizeInCache + ", servicesSizeInCache=" + servicesSizeInCache + ", productsSizeInCache=" - + productsSizeInCache + "]"; - } - - } - - public static class QueueInfo { - Integer numberOfCacheWorkers; - Integer waitOnShutDownInMinutes; - Integer syncIntervalInSecondes; - - public Integer getWaitOnShutDownInMinutes() { - return waitOnShutDownInMinutes; - } - - public void setWaitOnShutDownInMinutes(Integer waitOnShutDownInMinutes) { - this.waitOnShutDownInMinutes = waitOnShutDownInMinutes; - } - - public Integer getSyncIntervalInSecondes() { - return syncIntervalInSecondes; - } - - public void setSyncIntervalInSecondes(Integer syncIntervalInSecondes) { - this.syncIntervalInSecondes = syncIntervalInSecondes; - } - - public Integer getNumberOfCacheWorkers() { - return numberOfCacheWorkers; - } - - public void setNumberOfCacheWorkers(Integer numberOfCacheWorkers) { - this.numberOfCacheWorkers = numberOfCacheWorkers; - } - - @Override - public String toString() { - return "QueueInfo[" + "waitOnShutDownInMinutes=" + waitOnShutDownInMinutes + ", syncIntervalInSecondes=" - + syncIntervalInSecondes + ", numberOfCacheWorkers=" + this.numberOfCacheWorkers + ']'; - } - } - - public static class EnvironmentContext { - - String defaultValue; - List<String> validValues; - - public String getDefaultValue() { - return defaultValue; - } - - public void setDefaultValue(String defaultValue) { - this.defaultValue = defaultValue; - } - - public List<String> getValidValues() { - return validValues; - } - - public void setValidValues(List<String> validValues) { - this.validValues = validValues; - } - } - - - - public CleanComponentsConfiguration getCleanComponentsConfiguration() { - return cleanComponentsConfiguration; - } - - public void setCleanComponentsConfiguration(CleanComponentsConfiguration cleanComponentsConfiguration) { - this.cleanComponentsConfiguration = cleanComponentsConfiguration; - } - - @Override - public String toString() { - return new StringBuilder().append(format("backend host: %s%n", beFqdn)) - .append(format("backend http port: %s%n", beHttpPort)) - .append(format("backend ssl port: %s%n", beSslPort)).append(format("backend context: %s%n", beContext)) - .append(format("backend protocol: %s%n", beProtocol)).append(format("Version: %s%n", version)) - .append(format("Released: %s%n", released)).append(format("Supported protocols: %s%n", protocols)) - .append(format("Users: %s%n", users)).append(format("Neo4j: %s%n", neo4j)) - .append(format("ElasticSearch: %s%n", elasticSearch)) - .append(format("Titan Cfg File: %s%n", titanCfgFile)) - .append(format("Titan In memory: %s%n", titanInMemoryGraph)) - .append(format("Titan lock timeout: %s%n", titanLockTimeout)) - .append(format("Titan reconnect interval seconds: %s%n", titanReconnectIntervalInSeconds)) - .append(format("excludeResourceCategory: %s%n", excludeResourceCategory)) - .append(format("informationalResourceArtifacts: %s%n", informationalResourceArtifacts)) - .append(format("deploymentResourceArtifacts: %s%n", deploymentResourceArtifacts)) - .append(format("informationalServiceArtifacts: %s%n", informationalServiceArtifacts)) - .append(format("Supported artifacts types: %s%n", artifactTypes)) - .append(format("Supported license types: %s%n", licenseTypes)) - .append(format("Additional information Maximum number of preoperties: %s%n", - additionalInformationMaxNumberOfKeys)) - .append(format("Default Heat Artifact Timeout in Minutes: %s%n", defaultHeatArtifactTimeoutMinutes)) - .append(format("URLs For HTTP Requests that will not be automatically logged : %s%n", unLoggedUrls)) - .append(format("Service Api Artifacts: %s%n", serviceApiArtifacts)) - .append(format("heat env artifact header: %s%n", heatEnvArtifactHeader)) - .append(format("heat env artifact footer: %s%n", heatEnvArtifactFooter)) + public Integer getServicesSizeInCache() { + return servicesSizeInCache; + } + + public void setServicesSizeInCache(Integer servicesSizeInCache) { + this.servicesSizeInCache = servicesSizeInCache; + } + + public Integer getProductsSizeInCache() { + return productsSizeInCache; + } + + public void setProductsSizeInCache(Integer productsSizeInCache) { + this.productsSizeInCache = productsSizeInCache; + } + + @Override + public String toString() { + return "ApplicationL1CacheCatalogInfo [enabled=" + enabled + ", resourcesSizeInCache=" + + resourcesSizeInCache + ", servicesSizeInCache=" + servicesSizeInCache + ", productsSizeInCache=" + + productsSizeInCache + "]"; + } + + } + + public static class QueueInfo { + Integer numberOfCacheWorkers; + Integer waitOnShutDownInMinutes; + Integer syncIntervalInSecondes; + + public Integer getWaitOnShutDownInMinutes() { + return waitOnShutDownInMinutes; + } + + public void setWaitOnShutDownInMinutes(Integer waitOnShutDownInMinutes) { + this.waitOnShutDownInMinutes = waitOnShutDownInMinutes; + } + + public Integer getSyncIntervalInSecondes() { + return syncIntervalInSecondes; + } + + public void setSyncIntervalInSecondes(Integer syncIntervalInSecondes) { + this.syncIntervalInSecondes = syncIntervalInSecondes; + } + + public Integer getNumberOfCacheWorkers() { + return numberOfCacheWorkers; + } + + public void setNumberOfCacheWorkers(Integer numberOfCacheWorkers) { + this.numberOfCacheWorkers = numberOfCacheWorkers; + } + + @Override + public String toString() { + return "QueueInfo[" + "waitOnShutDownInMinutes=" + waitOnShutDownInMinutes + ", syncIntervalInSecondes=" + + syncIntervalInSecondes + ", numberOfCacheWorkers=" + this.numberOfCacheWorkers + ']'; + } + } + + public static class EnvironmentContext { + + String defaultValue; + List<String> validValues; + + public String getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + public List<String> getValidValues() { + return validValues; + } + + public void setValidValues(List<String> validValues) { + this.validValues = validValues; + } + } + + + + public CleanComponentsConfiguration getCleanComponentsConfiguration() { + return cleanComponentsConfiguration; + } + + public void setCleanComponentsConfiguration(CleanComponentsConfiguration cleanComponentsConfiguration) { + this.cleanComponentsConfiguration = cleanComponentsConfiguration; + } + + @Override + public String toString() { + return new StringBuilder().append(format("backend host: %s%n", beFqdn)) + .append(format("backend http port: %s%n", beHttpPort)) + .append(format("backend ssl port: %s%n", beSslPort)).append(format("backend context: %s%n", beContext)) + .append(format("backend protocol: %s%n", beProtocol)).append(format("Version: %s%n", version)) + .append(format("Released: %s%n", released)).append(format("Supported protocols: %s%n", protocols)) + .append(format("Users: %s%n", users)).append(format("Neo4j: %s%n", neo4j)) + .append(format("ElasticSearch: %s%n", elasticSearch)) + .append(format("Titan Cfg File: %s%n", titanCfgFile)) + .append(format("Titan In memory: %s%n", titanInMemoryGraph)) + .append(format("Titan lock timeout: %s%n", titanLockTimeout)) + .append(format("Titan reconnect interval seconds: %s%n", titanReconnectIntervalInSeconds)) + .append(format("excludeResourceCategory: %s%n", excludeResourceCategory)) + .append(format("informationalResourceArtifacts: %s%n", informationalResourceArtifacts)) + .append(format("deploymentResourceArtifacts: %s%n", deploymentResourceArtifacts)) + .append(format("informationalServiceArtifacts: %s%n", informationalServiceArtifacts)) + .append(format("Supported artifacts types: %s%n", artifactTypes)) + .append(format("Supported license types: %s%n", licenseTypes)) + .append(format("Additional information Maximum number of preoperties: %s%n", + additionalInformationMaxNumberOfKeys)) + .append(format("Default Heat Artifact Timeout in Minutes: %s%n", defaultHeatArtifactTimeoutMinutes)) + .append(format("URLs For HTTP Requests that will not be automatically logged : %s%n", unLoggedUrls)) + .append(format("Service Api Artifacts: %s%n", serviceApiArtifacts)) + .append(format("heat env artifact header: %s%n", heatEnvArtifactHeader)) + .append(format("heat env artifact footer: %s%n", heatEnvArtifactFooter)) .append(format("onboarding: %s%n", onboarding)) .append(format("tosca conformance level: %s%n", toscaConformanceLevel)) .toString(); - } + } + + public List<String> getUnLoggedUrls() { + return unLoggedUrls; + } - public List<String> getUnLoggedUrls() { - return unLoggedUrls; - } + public void setUnLoggedUrls(List<String> unLoggedUrls) { + this.unLoggedUrls = unLoggedUrls; + } - public void setUnLoggedUrls(List<String> unLoggedUrls) { - this.unLoggedUrls = unLoggedUrls; - } + public Map<String, Object> getDeploymentResourceArtifacts() { + return deploymentResourceArtifacts; + } - public Map<String, Object> getDeploymentResourceArtifacts() { - return deploymentResourceArtifacts; - } + public void setDeploymentResourceArtifacts(Map<String, Object> deploymentResourceArtifacts) { + this.deploymentResourceArtifacts = deploymentResourceArtifacts; + } - public void setDeploymentResourceArtifacts(Map<String, Object> deploymentResourceArtifacts) { - this.deploymentResourceArtifacts = deploymentResourceArtifacts; - } + public String getHeatEnvArtifactHeader() { + return heatEnvArtifactHeader; + } - public String getHeatEnvArtifactHeader() { - return heatEnvArtifactHeader; - } + public void setHeatEnvArtifactHeader(String heatEnvArtifactHeader) { + this.heatEnvArtifactHeader = heatEnvArtifactHeader; + } - public void setHeatEnvArtifactHeader(String heatEnvArtifactHeader) { - this.heatEnvArtifactHeader = heatEnvArtifactHeader; - } + public String getHeatEnvArtifactFooter() { + return heatEnvArtifactFooter; + } - public String getHeatEnvArtifactFooter() { - return heatEnvArtifactFooter; - } + public void setHeatEnvArtifactFooter(String heatEnvArtifactFooter) { + this.heatEnvArtifactFooter = heatEnvArtifactFooter; + } - public void setHeatEnvArtifactFooter(String heatEnvArtifactFooter) { - this.heatEnvArtifactFooter = heatEnvArtifactFooter; - } + public Map<String, Object> getDeploymentResourceInstanceArtifacts() { + return deploymentResourceInstanceArtifacts; + } - public Map<String, Object> getDeploymentResourceInstanceArtifacts() { - return deploymentResourceInstanceArtifacts; - } + public void setDeploymentResourceInstanceArtifacts(Map<String, Object> deploymentResourceInstanceArtifacts) { + this.deploymentResourceInstanceArtifacts = deploymentResourceInstanceArtifacts; + } - public void setDeploymentResourceInstanceArtifacts(Map<String, Object> deploymentResourceInstanceArtifacts) { - this.deploymentResourceInstanceArtifacts = deploymentResourceInstanceArtifacts; - } + public String getArtifactsIndex() { + return artifactsIndex; + } - public String getArtifactsIndex() { - return artifactsIndex; - } + public void setArtifactsIndex(String artifactsIndex) { + this.artifactsIndex = artifactsIndex; + } - public void setArtifactsIndex(String artifactsIndex) { - this.artifactsIndex = artifactsIndex; - } + public Map<String, ArtifactTypeConfig> getResourceInformationalDeployedArtifacts() { + return resourceInformationalDeployedArtifacts; + } - public Map<String, ArtifactTypeConfig> getResourceInformationalDeployedArtifacts() { - return resourceInformationalDeployedArtifacts; - } + public void setResourceInformationalDeployedArtifacts( + Map<String, ArtifactTypeConfig> resourceInformationalDeployedArtifacts) { + this.resourceInformationalDeployedArtifacts = resourceInformationalDeployedArtifacts; + } - public void setResourceInformationalDeployedArtifacts( - Map<String, ArtifactTypeConfig> resourceInformationalDeployedArtifacts) { - this.resourceInformationalDeployedArtifacts = resourceInformationalDeployedArtifacts; - } + public List<String> getResourceTypes() { + return resourceTypes; + } - public List<String> getResourceTypes() { - return resourceTypes; - } + public void setResourceTypes(List<String> resourceTypes) { + this.resourceTypes = resourceTypes; + } - public void setResourceTypes(List<String> resourceTypes) { - this.resourceTypes = resourceTypes; - } - - public String getToscaFilesDir() { - return toscaFilesDir; - } - - public void setToscaFilesDir(String toscaFilesDir) { - this.toscaFilesDir = toscaFilesDir; - } - - public String getHeatTranslatorPath() { - return heatTranslatorPath; - } - - public void setHeatTranslatorPath(String heatTranslatorPath) { - this.heatTranslatorPath = heatTranslatorPath; - } - - public Map<String, Set<String>> getRequirementsToFulfillBeforeCert() { - return requirementsToFulfillBeforeCert; - } - - public void setRequirementsToFulfillBeforeCert(Map<String, Set<String>> requirementsToFulfillBeforeCert) { - this.requirementsToFulfillBeforeCert = requirementsToFulfillBeforeCert; - } - - public Map<String, Set<String>> getCapabilitiesToConsumeBeforeCert() { - return capabilitiesToConsumeBeforeCert; - } - - public void setCapabilitiesToConsumeBeforeCert(Map<String, Set<String>> capabilitiesToConsumeBeforeCert) { - this.capabilitiesToConsumeBeforeCert = capabilitiesToConsumeBeforeCert; - } - - public OnboardingConfig getOnboarding() { - return onboarding; - } - - public void setOnboarding(OnboardingConfig onboarding) { - this.onboarding = onboarding; - } - - public EcompPortalConfig getEcompPortal() { - return ecompPortal; - } - - public void setEcompPortal(EcompPortalConfig ecompPortal) { - this.ecompPortal = ecompPortal; - } - - public ToscaValidatorsConfig getToscaValidators() { - return toscaValidators; - } - - public void setToscaValidators(ToscaValidatorsConfig toscaValidators) { - this.toscaValidators = toscaValidators; - } - - public boolean isDisableAudit() { - return disableAudit; - } - - public void setDisableAudit(boolean enableAudit) { - this.disableAudit = enableAudit; - } - - public Map<String, ArtifactTypeConfig> getResourceInformationalArtifacts() { - return resourceInformationalArtifacts; - } - - public void setResourceInformationalArtifacts(Map<String, ArtifactTypeConfig> resourceInformationalArtifacts) { - this.resourceInformationalArtifacts = resourceInformationalArtifacts; - } - - public Map<String, VfModuleProperty> getVfModuleProperties() { - return vfModuleProperties; - } - - public void setVfModuleProperties(Map<String, VfModuleProperty> vfModuleProperties) { - this.vfModuleProperties = vfModuleProperties; - } - - public String getToscaConformanceLevel() { - return toscaConformanceLevel; - } - - public void setToscaConformanceLevel(String toscaConformanceLevel) { - this.toscaConformanceLevel = toscaConformanceLevel; - } - - public String getMinToscaConformanceLevel() { - return minToscaConformanceLevel; - } - - public void setMinToscaConformanceLevel(String toscaConformanceLevel) { - this.minToscaConformanceLevel = toscaConformanceLevel; - } - - public static class VfModuleProperty { - private String forBaseModule; - private String forNonBaseModule; - public String getForBaseModule() { - return forBaseModule; - } - public void setForBaseModule(String forBaseModule) { - this.forBaseModule = forBaseModule; - } - public String getForNonBaseModule() { - return forNonBaseModule; - } - public void setForNonBaseModule(String forNonBaseModule) { - this.forNonBaseModule = forNonBaseModule; - } - } - - public List<Map<String, Map<String, String>>> getDefaultImports() { - return defaultImports; - } - - public void setDefaultImports(List<Map<String, Map<String, String>>> defaultImports) { - this.defaultImports = defaultImports; - } - - public Map<String, List<String>> getResourcesForUpgrade() { - return resourcesForUpgrade; - } - - public void setResourcesForUpgrade(Map<String, List<String>> resourcesForUpgrade) { - this.resourcesForUpgrade = resourcesForUpgrade; - } - - private <K,V> Map<K,V> safeGetMap(Map<K,V> map) { - return map == null ? emptyMap() : map; - } - - - public List<String> getHealthStatusExclude() { - return healthStatusExclude; - } - - public void setHealthStatusExclude(List<String> healthStatusExclude) { - this.healthStatusExclude = healthStatusExclude; - } + public String getToscaFilesDir() { + return toscaFilesDir; + } + + public void setToscaFilesDir(String toscaFilesDir) { + this.toscaFilesDir = toscaFilesDir; + } + + public String getHeatTranslatorPath() { + return heatTranslatorPath; + } + + public void setHeatTranslatorPath(String heatTranslatorPath) { + this.heatTranslatorPath = heatTranslatorPath; + } + + public Map<String, Set<String>> getRequirementsToFulfillBeforeCert() { + return requirementsToFulfillBeforeCert; + } + + public void setRequirementsToFulfillBeforeCert(Map<String, Set<String>> requirementsToFulfillBeforeCert) { + this.requirementsToFulfillBeforeCert = requirementsToFulfillBeforeCert; + } + + public Map<String, Set<String>> getCapabilitiesToConsumeBeforeCert() { + return capabilitiesToConsumeBeforeCert; + } + + public void setCapabilitiesToConsumeBeforeCert(Map<String, Set<String>> capabilitiesToConsumeBeforeCert) { + this.capabilitiesToConsumeBeforeCert = capabilitiesToConsumeBeforeCert; + } + + public OnboardingConfig getOnboarding() { + return onboarding; + } + + public void setOnboarding(OnboardingConfig onboarding) { + this.onboarding = onboarding; + } + + public EcompPortalConfig getEcompPortal() { + return ecompPortal; + } + + public void setEcompPortal(EcompPortalConfig ecompPortal) { + this.ecompPortal = ecompPortal; + } + + public ToscaValidatorsConfig getToscaValidators() { + return toscaValidators; + } + + public void setToscaValidators(ToscaValidatorsConfig toscaValidators) { + this.toscaValidators = toscaValidators; + } + + public boolean isDisableAudit() { + return disableAudit; + } + + public void setDisableAudit(boolean enableAudit) { + this.disableAudit = enableAudit; + } + + public Map<String, ArtifactTypeConfig> getResourceInformationalArtifacts() { + return resourceInformationalArtifacts; + } + + public void setResourceInformationalArtifacts(Map<String, ArtifactTypeConfig> resourceInformationalArtifacts) { + this.resourceInformationalArtifacts = resourceInformationalArtifacts; + } + + public Map<String, VfModuleProperty> getVfModuleProperties() { + return vfModuleProperties; + } + + public void setVfModuleProperties(Map<String, VfModuleProperty> vfModuleProperties) { + this.vfModuleProperties = vfModuleProperties; + } + + public String getToscaConformanceLevel() { + return toscaConformanceLevel; + } + + public void setToscaConformanceLevel(String toscaConformanceLevel) { + this.toscaConformanceLevel = toscaConformanceLevel; + } + + public String getMinToscaConformanceLevel() { + return minToscaConformanceLevel; + } + + public void setMinToscaConformanceLevel(String toscaConformanceLevel) { + this.minToscaConformanceLevel = toscaConformanceLevel; + } + + public static class VfModuleProperty { + private String forBaseModule; + private String forNonBaseModule; + public String getForBaseModule() { + return forBaseModule; + } + public void setForBaseModule(String forBaseModule) { + this.forBaseModule = forBaseModule; + } + public String getForNonBaseModule() { + return forNonBaseModule; + } + public void setForNonBaseModule(String forNonBaseModule) { + this.forNonBaseModule = forNonBaseModule; + } + } + + public List<Map<String, Map<String, String>>> getDefaultImports() { + return defaultImports; + } + + public void setDefaultImports(List<Map<String, Map<String, String>>> defaultImports) { + this.defaultImports = defaultImports; + } + + public Map<String, List<String>> getResourcesForUpgrade() { + return resourcesForUpgrade; + } + + public void setResourcesForUpgrade(Map<String, List<String>> resourcesForUpgrade) { + this.resourcesForUpgrade = resourcesForUpgrade; + } + + public static <K,V> Map<K,V> safeGetCapsInsensitiveMap(Map<K,V> map) { + return map == null ? emptyMap() : new CaseInsensitiveMap(map); + } + + + public List<String> getHealthStatusExclude() { + return healthStatusExclude; + } + + public void setHealthStatusExclude(List<String> healthStatusExclude) { + this.healthStatusExclude = healthStatusExclude; + } } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java index 0015729be0..360d2e6cb3 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java @@ -20,9 +20,6 @@ package org.openecomp.sdc.be.config; -import java.util.HashMap; -import java.util.Map; - import org.openecomp.sdc.common.api.BasicConfiguration; import org.openecomp.sdc.common.api.ConfigurationListener; import org.openecomp.sdc.common.api.ConfigurationSource; @@ -30,6 +27,9 @@ import org.openecomp.sdc.common.api.FileChangeCallback; import org.openecomp.sdc.common.config.EcompErrorConfiguration; import org.openecomp.sdc.common.config.IEcompConfigurationManager; +import java.util.HashMap; +import java.util.Map; + public class ConfigurationManager implements FileChangeCallback, IEcompConfigurationManager { ConfigurationSource configurationSource = null; @@ -42,7 +42,7 @@ public class ConfigurationManager implements FileChangeCallback, IEcompConfigura instance = this; } - Map<String, Object> configurations = new HashMap<String, Object>(); + Map<String, Object> configurations = new HashMap<>(); private void loadConfigurationFiles() { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/DistributionEngineConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/DistributionEngineConfiguration.java index eeeca5b9bb..6ac399c729 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/be/config/DistributionEngineConfiguration.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/DistributionEngineConfiguration.java @@ -20,15 +20,11 @@ package org.openecomp.sdc.be.config; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - import org.openecomp.sdc.common.api.BasicConfiguration; import org.openecomp.sdc.common.http.config.ExternalServiceConfig; +import java.util.*; + public class DistributionEngineConfiguration extends BasicConfiguration { private List<String> uebServers; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorConfiguration.java index 8250df6c04..52ea02cfab 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorConfiguration.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorConfiguration.java @@ -20,10 +20,10 @@ package org.openecomp.sdc.be.config; -import java.util.Map; - import org.openecomp.sdc.common.api.BasicConfiguration; +import java.util.Map; + public class ErrorConfiguration extends BasicConfiguration { private Map<String, ErrorInfo> errors; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorInfo.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorInfo.java index 85328caa22..ec9a61c81f 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorInfo.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorInfo.java @@ -20,8 +20,7 @@ package org.openecomp.sdc.be.config; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.openecomp.sdc.common.log.wrappers.Logger; public class ErrorInfo { @@ -33,7 +32,7 @@ public class ErrorInfo { private static final String SVC_PREFIX = "SVC"; private static final String POL_PREFIX = "POL"; - private static Logger log = LoggerFactory.getLogger(ErrorInfo.class.getName()); + private static Logger log = Logger.getLogger(ErrorInfo.class.getName()); public ErrorInfo() { this.errorInfoType = ErrorInfoType.OK; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/Neo4jErrorsConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/Neo4jErrorsConfiguration.java index 24a85dc627..02965242cf 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/be/config/Neo4jErrorsConfiguration.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/Neo4jErrorsConfiguration.java @@ -20,10 +20,10 @@ package org.openecomp.sdc.be.config; -import java.util.Map; - import org.openecomp.sdc.common.api.BasicConfiguration; +import java.util.Map; + public class Neo4jErrorsConfiguration extends BasicConfiguration { private Map<String, String> errors; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/monitoring/BeMonitoringService.java b/common-app-api/src/main/java/org/openecomp/sdc/be/monitoring/BeMonitoringService.java index f2438fcbfc..73358136b5 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/be/monitoring/BeMonitoringService.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/be/monitoring/BeMonitoringService.java @@ -20,13 +20,8 @@ package org.openecomp.sdc.be.monitoring; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.TimeUnit; - -import javax.servlet.ServletContext; - +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import org.apache.http.HttpEntity; import org.apache.http.HttpStatus; import org.apache.http.entity.ContentType; @@ -38,19 +33,21 @@ import org.openecomp.sdc.common.http.client.api.HttpRequest; import org.openecomp.sdc.common.http.client.api.HttpResponse; import org.openecomp.sdc.common.http.config.HttpClientConfig; import org.openecomp.sdc.common.http.config.Timeouts; +import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.common.monitoring.MonitoringEvent; import org.openecomp.sdc.common.monitoring.MonitoringMetricsFetcher; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; +import javax.servlet.ServletContext; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; public class BeMonitoringService { private static final String URL = "%s://%s:%s/sdc2/rest/monitoring"; - private static Logger monitoringLogger = LoggerFactory.getLogger("asdc.be.monitoring.service"); - private static Logger log = LoggerFactory.getLogger(BeMonitoringService.class.getName()); + private static Logger monitoringLogger = Logger.getLogger("asdc.be.monitoring.service"); + private static Logger log = Logger.getLogger(BeMonitoringService.class.getName()); private static Gson gson = new GsonBuilder().setPrettyPrinting().create(); private class MonitoringScheduledTask implements Runnable { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactTypeEnum.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactTypeEnum.java index 6beec9de54..408c36eeb6 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactTypeEnum.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactTypeEnum.java @@ -37,10 +37,10 @@ public enum ArtifactTypeEnum { DCAE_INVENTORY_POLICY("DCAE_INVENTORY_POLICY"), DCAE_INVENTORY_DOC("DCAE_INVENTORY_DOC"), DCAE_INVENTORY_BLUEPRINT("DCAE_INVENTORY_BLUEPRINT"), DCAE_INVENTORY_EVENT("DCAE_INVENTORY_EVENT"), // AAI Artifacts AAI_SERVICE_MODEL("AAI_SERVICE_MODEL"), AAI_VF_MODEL("AAI_VF_MODEL"), AAI_VF_MODULE_MODEL("AAI_VF_MODULE_MODEL"), AAI_VF_INSTANCE_MODEL("AAI_VF_INSTANCE_MODEL"), - // MIB Artifacts + // MIB artifacts SNMP_POLL ("SNMP_POLL"), SNMP_TRAP("SNMP_TRAP"), GUIDE("GUIDE"), - // PLAN Artifacts - PLAN("PLAN"); + PLAN("PLAN") + ; ArtifactTypeEnum(String type) { this.type = type; @@ -67,7 +67,7 @@ public enum ArtifactTypeEnum { } public static List<String> getAllTypes() { - List<String> types = new ArrayList<String>(); + List<String> types = new ArrayList<>(); for (ArtifactTypeEnum ate : ArtifactTypeEnum.values()) { types.add(ate.getType()); } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/Constants.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/Constants.java index 5d33e9918f..0a7a105f19 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/api/Constants.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/Constants.java @@ -136,7 +136,7 @@ public final class Constants { public static final String HC_COMPONENT_ES = "ES"; public static final String HC_COMPONENT_CASSANDRA = "CASSANDRA"; public static final String HC_COMPONENT_DISTRIBUTION_ENGINE = "DE"; - public static final String HC_COMPONENT_DMAAP_ENGINE = "DMAPP"; + public static final String HC_COMPONENT_DMAAP_ENGINE = "DMAAP"; //external HealthCheck components public static final String HC_COMPONENT_ON_BOARDING = "ON_BOARDING"; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckInfo.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckInfo.java index 7a22495643..c887c09149 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckInfo.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckInfo.java @@ -20,12 +20,12 @@ package org.openecomp.sdc.common.api; -import java.lang.reflect.Type; -import java.util.List; - import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; +import java.lang.reflect.Type; +import java.util.List; + public class HealthCheckInfo { private String healthCheckComponent; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/YamlSuffixEnum.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/YamlSuffixEnum.java index 4ac6290940..1310ab170f 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/api/YamlSuffixEnum.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/YamlSuffixEnum.java @@ -49,7 +49,7 @@ public enum YamlSuffixEnum { public static List<String> getSuffixes() { - List<String> arrayList = new ArrayList<String>(); + List<String> arrayList = new ArrayList<>(); for (YamlSuffixEnum yamlSuffixEnum : YamlSuffixEnum.values()) { arrayList.add(yamlSuffixEnum.getSuffix()); diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorConfiguration.java index 368104dea1..196dd0aa71 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorConfiguration.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorConfiguration.java @@ -20,13 +20,13 @@ package org.openecomp.sdc.common.config; +import org.openecomp.sdc.common.api.BasicConfiguration; + import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.regex.Pattern; -import org.openecomp.sdc.common.api.BasicConfiguration; - public class EcompErrorConfiguration extends BasicConfiguration { private Map<String, EcompErrorInfo> errors = new HashMap<>(); @@ -136,7 +136,7 @@ public class EcompErrorConfiguration extends BasicConfiguration { } /******************************* - * Enums + * enums */ public enum EcompErrorType { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorLogUtil.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorLogUtil.java index 950af691da..af53611104 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorLogUtil.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorLogUtil.java @@ -20,22 +20,21 @@ package org.openecomp.sdc.common.config; -import java.util.Formatter; -import java.util.IllegalFormatException; -import java.util.Locale; - +import fj.data.Either; import org.apache.commons.lang3.StringUtils; import org.openecomp.sdc.common.config.EcompErrorConfiguration.EcompErrorSeverity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode; +import org.openecomp.sdc.common.log.wrappers.Logger; import org.slf4j.MDC; -import fj.data.Either; +import java.util.Formatter; +import java.util.IllegalFormatException; +import java.util.Locale; public class EcompErrorLogUtil { private static String ECOMP_ERROR_TMPL = "ETYPE = \"%s\" ENAME = \"%s\" ECODE = \"%s\" ECONTEXT = \"%s\" EDESC = \"%s\""; - private static Logger log = LoggerFactory.getLogger(EcompErrorLogUtil.class.getName()); + private static Logger log = Logger.getLogger(EcompErrorLogUtil.class.getName()); private static final String FATAL_ERROR_PREFIX = "FATAL ERROR!! "; public static void logEcompError(EcompErrorName ecompErrorName, EcompErrorInfo ecompErrorInfo, @@ -62,24 +61,9 @@ public class EcompErrorLogUtil { // else it stays ERROR formatter.format(ECOMP_ERROR_TMPL, ecompErrorInfo.getType(), ecompErrorName.name(), ecompErrorInfo.getCode(), ecompErrorContext, description); - switch (severity) { - case INFO: - log.info(formatter.toString()); - break; - case WARN: - log.warn(formatter.toString()); - break; - case ERROR: - log.error(formatter.toString()); - break; - case FATAL: - // same as ERROR for now, might be additional logic later.. - log.error(formatter.toString()); - break; - default: - break; - } - } finally { + log.error(severity, EcompLoggerErrorCode.getByValue(ecompErrorInfo.getCode()), + ecompErrorContext, ecompErrorContext, description); + } finally { formatter.close(); MDC.remove("alarmSeverity"); } @@ -96,7 +80,7 @@ public class EcompErrorLogUtil { StringBuilder sb = new StringBuilder(); Formatter formatter = new Formatter(sb, Locale.US); try { - String description = ecompErrorEnum.getEcompErrorCode().getDescription(); + String description; Either<String, Boolean> setDescriptionParamsResult = setDescriptionParams(ecompErrorEnum, ecompDescriptionParams); @@ -104,13 +88,12 @@ public class EcompErrorLogUtil { description = setDescriptionParamsResult.left().value(); } else { EcompErrorEnum mismatchErrorEnum = EcompErrorEnum.EcompMismatchParam; - if (logMissingParams == true) { - logEcompError("logEcompError", mismatchErrorEnum, false, ecompErrorEnum.name().toString()); - return; + if (logMissingParams) { + logEcompError("logEcompError", mismatchErrorEnum, false, ecompErrorEnum.name()); } else { log.info("Failed to log the error code {}", mismatchErrorEnum); - return; } + return; } EcompClassification classification = ecompErrorEnum.getClassification(); @@ -132,23 +115,9 @@ public class EcompErrorLogUtil { // else it stays ERROR formatter.format(ECOMP_ERROR_TMPL, ecompErrorEnum.geteType(), ecompErrorEnum.name(), eCode, ecompErrorContext, description); - switch (severity) { - case INFO: - log.info(formatter.toString()); - break; - case WARN: - log.warn(formatter.toString()); - break; - case ERROR: - log.error(formatter.toString()); - break; - case FATAL: - // same as ERROR for now, might be additional logic later.. - log.error(formatter.toString()); - break; - default: - break; - } + + log.error(severity, EcompLoggerErrorCode.getByValue(ecompErrorEnum.getEcompErrorCode().name()), + ecompErrorContext, ecompErrorContext, description); } finally { formatter.close(); MDC.remove("alarmSeverity"); @@ -161,9 +130,8 @@ public class EcompErrorLogUtil { String ecompErrorCode = ecompErrorEnum.getEcompErrorCode().name(); String ecodeNumber = ecompErrorCode.substring(ecompErrorCode.indexOf("_") + 1); - String eCode = "ASDC" + ecodeNumber + classification.getClassification(); - return eCode; + return "ASDC" + ecodeNumber + classification.getClassification(); } private static Either<String, Boolean> setDescriptionParams(EcompErrorEnum ecompErrorEnum, diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java index 6b7afc439f..8ee8c6035d 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java @@ -20,6 +20,11 @@ package org.openecomp.sdc.common.config.generation; +import org.openecomp.sdc.common.config.EcompErrorEnum; +import org.openecomp.sdc.common.config.EcompErrorEnum.AlarmSeverity; +import org.openecomp.sdc.common.config.EcompErrorEnum.ErrorType; +import org.openecomp.sdc.common.config.EcompErrorLogUtil; + import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -31,11 +36,6 @@ import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.openecomp.sdc.common.config.EcompErrorEnum; -import org.openecomp.sdc.common.config.EcompErrorEnum.AlarmSeverity; -import org.openecomp.sdc.common.config.EcompErrorEnum.ErrorType; -import org.openecomp.sdc.common.config.EcompErrorLogUtil; - public class GenerateEcompErrorsCsv { private static Logger log = LoggerFactory.getLogger(GenerateEcompErrorsCsv.class); @@ -136,7 +136,7 @@ public class GenerateEcompErrorsCsv { boolean result = false; String dateFormatted = ""; - if (addTimeToFileName == true) { + if (addTimeToFileName) { DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); Date date = new Date(); diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKeysEnum.java b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKey.java index 0dd15073da..06b2452d82 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKeysEnum.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKey.java @@ -22,7 +22,7 @@ package org.openecomp.sdc.common.datastructure; import java.util.Date; -public enum AuditingFieldsKeysEnum { +public enum AuditingFieldsKey { // General AUDIT_TIMESTAMP(Date.class, "TIMESTAMP"), AUDIT_ACTION(String.class, "ACTION"), @@ -95,7 +95,7 @@ public enum AuditingFieldsKeysEnum { private Class<?> clazz; private String displayName; - AuditingFieldsKeysEnum(Class<?> clazz, String displayName) { + AuditingFieldsKey(Class<?> clazz, String displayName) { this.clazz = clazz; this.displayName = displayName; } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEvent.java b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEvent.java index 55b9f7f87f..d31f8227dc 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEvent.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEvent.java @@ -20,18 +20,12 @@ package org.openecomp.sdc.common.datastructure; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Formatter; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Locale; -import java.util.Map; -import java.util.TimeZone; - import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; +import java.text.SimpleDateFormat; +import java.util.*; + /** * Extending this class enforces the objects of implementing classes to have a * timestamp, so that like in logstash, we can derive the index name for those @@ -42,15 +36,16 @@ import org.codehaus.jettison.json.JSONObject; */ public class ESTimeBasedEvent { + protected SimpleDateFormat simpleDateFormat; protected static String dateFormatPattern = "yyyy-MM-dd HH:mm:ss.SSS z"; protected String timestamp; - protected Map<String, Object> fields = new HashMap<String, Object>(); + protected Map<String, Object> fields = new HashMap<>(); public ESTimeBasedEvent() { - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); + simpleDateFormat = new SimpleDateFormat(dateFormatPattern); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); this.timestamp = simpleDateFormat.format(new Date()); - fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), this.timestamp); + fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), this.timestamp); } @@ -64,7 +59,7 @@ public class ESTimeBasedEvent { while (keys.hasNext()) { String key = (String) keys.next(); event.fields.put(key, gsonObj.get(key)); - if (key.equals(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName())) { + if (key.equals(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName())) { event.timestamp = (String) gsonObj.get(key); } } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/FunctionalInterfaces.java b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/FunctionalInterfaces.java index 64266f5985..3f6fb4c298 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/FunctionalInterfaces.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/FunctionalInterfaces.java @@ -20,28 +20,21 @@ package org.openecomp.sdc.common.datastructure; +import fj.F; +import fj.data.Either; +import org.apache.commons.lang3.math.NumberUtils; +import org.openecomp.sdc.common.log.wrappers.Logger; + import java.io.Serializable; import java.util.Arrays; import java.util.List; import java.util.Optional; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; +import java.util.concurrent.*; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; -import org.apache.commons.lang3.math.NumberUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fj.F; -import fj.data.Either; - /** * Class For Functional interfaces And Functional Methods * @@ -51,7 +44,7 @@ import fj.data.Either; public class FunctionalInterfaces { private static final int DEFAULT_REDO_INTERVAL_TIME_MS = 50; private static final int DEFAULT_MAX_WAIT_TIME_MS = 10000; - private static final Logger LOGGER = LoggerFactory.getLogger(FunctionalInterfaces.class); + private static final Logger LOGGER = Logger.getLogger(FunctionalInterfaces.class.getName()); /** * This is an interface of a List that implements Serializable @@ -183,8 +176,7 @@ public class FunctionalInterfaces { */ public static <R, E extends Exception> R swallowException(SupplierThrows<R, E> methodToRun) { try { - final R result = methodToRun.get(); - return result; + return methodToRun.get(); } catch (Exception e) { throw new FunctionalAttException(e); } @@ -510,15 +502,14 @@ public class FunctionalInterfaces { } public static <T> F<T, Boolean> convertToFunction(Consumer<T> consumer) { - F<T, Boolean> func = t -> { - try { - consumer.accept(t); - return true; - } catch (Exception e) { - return false; - } - }; - return func; + return t -> { + try { + consumer.accept(t); + return true; + } catch (Exception e) { + return false; + } + }; } } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerAudit.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerAudit.java deleted file mode 100644 index e5f5fc99dd..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerAudit.java +++ /dev/null @@ -1,184 +0,0 @@ -package org.openecomp.sdc.common.ecomplog; - -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ALERT_SEVERITY; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_BEGIN_TIMESTAMP; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_CLASS_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ELAPSED_TIME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_END_TIMESTAMP; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_INSTANCE_UUID; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_KEY_REQUEST_ID; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD1; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD2; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD3; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD4; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_PARTNER_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_PROCESS_KEY; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_REMOTE_HOST; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_RESPONSE_CODE; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_RESPONSE_DESC; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVER_FQDN; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVER_IP_ADDRESS; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVICE_INSTANCE_ID; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVICE_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_STATUS_CODE; - -import org.openecomp.sdc.common.ecomplog.Enums.EcompLoggerErrorCode; -import org.openecomp.sdc.common.ecomplog.Enums.LogMarkers; -import org.openecomp.sdc.common.ecomplog.Enums.Severity; -import org.openecomp.sdc.common.ecomplog.Enums.StatusCode; -import org.openecomp.sdc.common.ecomplog.api.IEcompMdcWrapper; -import org.slf4j.MDC; -import org.slf4j.MarkerFactory; - -public class EcompLoggerAudit extends EcompLoggerBase{ - private static EcompLoggerAudit instanceLoggerAudit = EcompLoggerFactory.getLogger(EcompLoggerAudit.class); - - EcompLoggerAudit(IEcompMdcWrapper ecompMdcWrapper) { - super (ecompMdcWrapper, MarkerFactory.getMarker(LogMarkers.AUDIT_MARKER.text())); - } - - public static EcompLoggerAudit getInstance() { - return instanceLoggerAudit; - } - - @Override - public EcompLoggerAudit startTimer() { - return (EcompLoggerAudit) super.startTimer(); - } - - public EcompLoggerAudit stopTimer() { - ecompMdcWrapper.stopTimer(); - return this; - } - - // automatic parameter this is optional - public EcompLoggerAudit setAutoServerFQDN(String serverFQDN) { - ecompMdcWrapper.setAutoServerFQDN(serverFQDN); - return this; - } - - // automatic parameter this is optional - public EcompLoggerAudit setAutoServerIPAddress(String serverIPAddress) { - ecompMdcWrapper.setAutoServerIPAddress(serverIPAddress); - return this; - } - - public EcompLoggerAudit setInstanceUUID(String instanceUUID) { - ecompMdcWrapper.setInstanceUUID(instanceUUID); - return this; - } - - public EcompLoggerAudit setOptClassName(String className) { - MDC.put("ClassName", className); - return this; - } - - public EcompLoggerAudit setOptProcessKey(String processKey) { - ecompMdcWrapper.setProcessKey(processKey); - return this; - } - - public EcompLoggerAudit setOptAlertSeverity(Severity alertSeverity) { - ecompMdcWrapper.setAlertSeverity(alertSeverity); - return this; - } - - // ecomplog optional parameter - public EcompLoggerAudit setOptCustomField1(String customField1) { - ecompMdcWrapper.setOptCustomField1(customField1); - return this; - } - - // ecomplog optional parameter - public EcompLoggerAudit setOptCustomField2(String customField2) { - ecompMdcWrapper.setOptCustomField2(customField2); - return this; - } - - // ecomplog optional parameter - public EcompLoggerAudit setOptCustomField3(String customField3) { - ecompMdcWrapper.setOptCustomField3(customField3); - return this; - } - - public EcompLoggerAudit setOptCustomField4(String customField4) { - ecompMdcWrapper.setOptCustomField4(customField4); - return this; - } - - @Override - public EcompLoggerAudit setKeyRequestId(String keyRequestId) { - return (EcompLoggerAudit) super.setKeyRequestId(keyRequestId); - } - - public EcompLoggerAudit setRemoteHost(String remoteHost) { - ecompMdcWrapper.setRemoteHost(remoteHost); - return this; - } - - public EcompLoggerAudit setServiceName(String serviceName) { - ecompMdcWrapper.setServiceName(serviceName); - return this; - } - - public EcompLoggerAudit setStatusCode(String statusCode) { - // status code is either success (COMPLETE) or failure (ERROR) of the request. - String respStatus = Integer.parseInt(statusCode) / 100 == 2 ? StatusCode.COMPLETE.getStatusCodeEnum() : StatusCode.ERROR.getStatusCodeEnum(); - ecompMdcWrapper.setStatusCode(respStatus); - return this; - } - - public EcompLoggerAudit setPartnerName(String partnerName) { - ecompMdcWrapper.setPartnerName(partnerName); - return this; - } - - public EcompLoggerAudit setResponseCode(EcompLoggerErrorCode responseCode) { - ecompMdcWrapper.setResponseCode(responseCode.getErrorCode()); - return this; - } - - public EcompLoggerAudit setResponseDesc(String responseDesc) { - ecompMdcWrapper.setResponseDesc(responseDesc); - return this; - } - - public EcompLoggerAudit setOptServiceInstanceId(String serviceInstanceId) { - ecompMdcWrapper.setServiceInstanceId(serviceInstanceId); - return this; - } - - @Override - public EcompLoggerAudit clear() { - return (EcompLoggerAudit) super.clear(); - } - - @Override - public void initializeMandatoryFields() { - - ecompMdcWrapper.setMandatoryField(MDC_BEGIN_TIMESTAMP); - ecompMdcWrapper.setMandatoryField(MDC_END_TIMESTAMP); - ecompMdcWrapper.setMandatoryField(MDC_KEY_REQUEST_ID); - ecompMdcWrapper.setMandatoryField(MDC_SERVICE_NAME); - ecompMdcWrapper.setMandatoryField(MDC_PARTNER_NAME); - ecompMdcWrapper.setMandatoryField(MDC_STATUS_CODE); - ecompMdcWrapper.setMandatoryField(MDC_RESPONSE_CODE); - ecompMdcWrapper.setMandatoryField(MDC_SERVICE_INSTANCE_ID); - ecompMdcWrapper.setMandatoryField(MDC_RESPONSE_DESC); - ecompMdcWrapper.setMandatoryField(MDC_ELAPSED_TIME); - - //Theoretically Optional, but practically Mandatory - ecompMdcWrapper.setMandatoryField(MDC_SERVER_IP_ADDRESS); - ecompMdcWrapper.setMandatoryField(MDC_SERVER_FQDN); - - ecompMdcWrapper.setOptionalField(MDC_INSTANCE_UUID); - ecompMdcWrapper.setOptionalField(MDC_ALERT_SEVERITY); - ecompMdcWrapper.setOptionalField(MDC_REMOTE_HOST); - ecompMdcWrapper.setOptionalField(MDC_CLASS_NAME); - ecompMdcWrapper.setOptionalField(MDC_PROCESS_KEY); - ecompMdcWrapper.setOptionalField(MDC_OPT_FIELD1); - ecompMdcWrapper.setOptionalField(MDC_OPT_FIELD2); - ecompMdcWrapper.setOptionalField(MDC_OPT_FIELD3); - ecompMdcWrapper.setOptionalField(MDC_OPT_FIELD4); - } -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerBase.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerBase.java deleted file mode 100644 index 535e8a4204..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerBase.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.openecomp.sdc.common.ecomplog; - -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVER_FQDN; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVER_IP_ADDRESS; - -import org.openecomp.sdc.common.ecomplog.Enums.LogLevel; -import org.openecomp.sdc.common.ecomplog.api.IEcompLogger; -import org.openecomp.sdc.common.ecomplog.api.IEcompMdcWrapper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; -import org.slf4j.Marker; - - -/** - * Created by mm288v on 12/27/2017. - * This class holds the common behavior of all Loger-Typed classes. - * The Concrete loggers shoudl derive from this one. - */ -public abstract class EcompLoggerBase implements IEcompLogger{ - private static Logger myLogger = LoggerFactory.getLogger(IEcompLogger.class.getName()); - private Marker myMarker; - IEcompMdcWrapper ecompMdcWrapper; - - EcompLoggerBase(IEcompMdcWrapper ecompMdcWrapper, Marker marker) { - this.ecompMdcWrapper = ecompMdcWrapper; - initializeMandatoryFields(); - this.myMarker = marker; - } - - @Override - public void log(LogLevel errorLevel, String message) { - - ecompMdcWrapper.validateMandatoryFields(); - - if (this instanceof EcompLoggerAudit || this instanceof EcompLoggerMetric) { - MDC.put(MDC_SERVER_IP_ADDRESS, EcompMDCWrapper.getInstance().getHostAddress()); - MDC.put(MDC_SERVER_FQDN, EcompMDCWrapper.getInstance().getFqdn()); - } - - if (errorLevel.equals(LogLevel.ERROR)) { - myLogger.error(myMarker, message); - return; - } - - if (errorLevel.equals(LogLevel.WARN)) { - myLogger.warn(myMarker, message); - return; - } - - if (errorLevel.equals(LogLevel.INFO)) { - myLogger.info(myMarker, message); - return; - } - - if (errorLevel.equals(LogLevel.DEBUG)) { - myLogger.info(myMarker, message); - } - } - - @Override - public IEcompLogger clear() { - ecompMdcWrapper.clear(); - return this; - } - - @Override - public IEcompLogger startTimer() { - ecompMdcWrapper.startTimer(); - return this; - } - - @Override - public IEcompLogger setKeyRequestId(String keyRequestId) { - ecompMdcWrapper.setKeyRequestId(keyRequestId); - return this; - } - -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerDebug.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerDebug.java deleted file mode 100644 index aecb487e24..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerDebug.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.openecomp.sdc.common.ecomplog; - -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_BEGIN_TIMESTAMP; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_KEY_REQUEST_ID; - -import org.openecomp.sdc.common.ecomplog.Enums.LogLevel; -import org.openecomp.sdc.common.ecomplog.Enums.LogMarkers; -import org.openecomp.sdc.common.ecomplog.api.IEcompMdcWrapper; -import org.slf4j.MarkerFactory; - -public class EcompLoggerDebug extends EcompLoggerBase { - - private static EcompLoggerDebug instanceLoggerDebug = EcompLoggerFactory.getLogger(EcompLoggerDebug.class); - - protected final String endOfRecordDelimiter = "|^\\n"; - - EcompLoggerDebug(IEcompMdcWrapper ecompMdcWrapper) { - super(ecompMdcWrapper, MarkerFactory.getMarker(LogMarkers.DEBUG_MARKER.text())); - } - - public static EcompLoggerDebug getInstance() { - return instanceLoggerDebug; - } - - @Override - public void log(LogLevel errorLevel, String message) { - String formattedMessage = String.format("%s%s", message, endOfRecordDelimiter); - super.log(errorLevel, formattedMessage); - } - - @Override - public void initializeMandatoryFields() { - ecompMdcWrapper.setMandatoryField(MDC_BEGIN_TIMESTAMP); - ecompMdcWrapper.setMandatoryField(MDC_KEY_REQUEST_ID); - } - - @Override - public EcompLoggerDebug clear() { - return (EcompLoggerDebug) super.clear(); - } - - @Override - public EcompLoggerDebug startTimer() { - return (EcompLoggerDebug) super.startTimer(); - } - - @Override - public EcompLoggerDebug setKeyRequestId(String keyRequestId) { - return (EcompLoggerDebug) super.setKeyRequestId(keyRequestId); - } -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerError.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerError.java deleted file mode 100644 index 92a495fda7..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerError.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.openecomp.sdc.common.ecomplog; - -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_BEGIN_TIMESTAMP; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ERROR_CATEGORY; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ERROR_CODE; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ERROR_DESC; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_KEY_REQUEST_ID; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_PARTNER_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVICE_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_TARGET_ENTITY; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_TARGET_SERVICE_NAME; - -import org.openecomp.sdc.common.ecomplog.Enums.EcompLoggerErrorCode; -import org.openecomp.sdc.common.ecomplog.Enums.LogMarkers; -import org.openecomp.sdc.common.ecomplog.api.IEcompMdcWrapper; -import org.slf4j.MarkerFactory; - -public class EcompLoggerError extends EcompLoggerBase{ - private static EcompLoggerError instanceLoggerError = EcompLoggerFactory.getLogger(EcompLoggerError.class); - - EcompLoggerError(IEcompMdcWrapper ecompMdcWrapper) { - super(ecompMdcWrapper, MarkerFactory.getMarker(LogMarkers.ERROR_MARKER.text())); - } - - public static EcompLoggerError getInstance() { - return instanceLoggerError; - } - - @Override - public void initializeMandatoryFields() { - ecompMdcWrapper.setMandatoryField(MDC_BEGIN_TIMESTAMP); - ecompMdcWrapper.setMandatoryField(MDC_KEY_REQUEST_ID); - ecompMdcWrapper.setMandatoryField(MDC_SERVICE_NAME); - ecompMdcWrapper.setMandatoryField(MDC_PARTNER_NAME); - ecompMdcWrapper.setMandatoryField(MDC_ERROR_CATEGORY); - ecompMdcWrapper.setMandatoryField(MDC_ERROR_CODE); - ecompMdcWrapper.setMandatoryField(MDC_ERROR_DESC); - - ecompMdcWrapper.setOptionalField(MDC_TARGET_ENTITY); - ecompMdcWrapper.setOptionalField(MDC_TARGET_SERVICE_NAME); - } - - @Override - public EcompLoggerError startTimer() { - return (EcompLoggerError) super.startTimer(); - } - - @Override - public EcompLoggerError setKeyRequestId(String keyRequestId) { - return (EcompLoggerError) super.setKeyRequestId(keyRequestId); - } - - public EcompLoggerError setServiceName(String serviceName) { - ecompMdcWrapper.setServiceName(serviceName); - return this; - } - - public EcompLoggerError setTargetEntity(String targetEntity) { - ecompMdcWrapper.setTargetEntity(targetEntity); - return this; - } - - public EcompLoggerError setErrorCode(EcompLoggerErrorCode errorCode) { - ecompMdcWrapper.setErrorCode(errorCode.getErrorCode()); - return this; - } - - public EcompLoggerError setErrorDescription(String errorDescription) { - ecompMdcWrapper.setErrorDescription(errorDescription); - return this; - } - - public EcompLoggerError clear() { - return (EcompLoggerError) super.clear(); - } - -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerFactory.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerFactory.java deleted file mode 100644 index 2ea1280f48..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerFactory.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.openecomp.sdc.common.ecomplog; - -/** - * Created by dd4296 on 12/26/2017. - * this factory helps decouple the classes for Stopwatch and EcompMDCWrapper from - * the EcompLogger classes - */ -public class EcompLoggerFactory { - - private EcompLoggerFactory() { - } - - @SuppressWarnings("unchecked") - static public <T, V> V getLogger(Class<T> type) { - - if (type.getName().equals(EcompLoggerAudit.class.getName())) { - return (V) new EcompLoggerAudit(new EcompMDCWrapper(new Stopwatch())); - } - - if (type.getName().equals(EcompLoggerDebug.class.getName())) { - return (V) new EcompLoggerDebug(new EcompMDCWrapper(new Stopwatch())); - } - - if (type.getName().equals(EcompLoggerMetric.class.getName())) { - return (V) new EcompLoggerMetric(new EcompMDCWrapper(new Stopwatch())); - } - - if (type.getName().equals(EcompLoggerError.class.getName())) { - return (V) new EcompLoggerError(new EcompMDCWrapper(new Stopwatch())); - } - - return null; - } -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerMetric.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerMetric.java deleted file mode 100644 index 2405a0eadf..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerMetric.java +++ /dev/null @@ -1,207 +0,0 @@ -package org.openecomp.sdc.common.ecomplog; - -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ALERT_SEVERITY; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_BEGIN_TIMESTAMP; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_CLASS_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ELAPSED_TIME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_END_TIMESTAMP; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_INSTANCE_UUID; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_KEY_REQUEST_ID; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD1; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD2; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD3; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD4; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_PARTNER_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_PROCESS_KEY; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_REMOTE_HOST; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_RESPONSE_CODE; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_RESPONSE_DESC; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVER_FQDN; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVER_IP_ADDRESS; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVICE_INSTANCE_ID; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVICE_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_STATUS_CODE; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_TARGET_ENTITY; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_TARGET_SERVICE_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_TARGET_VIRTUAL_ENTITY; - -import org.openecomp.sdc.common.ecomplog.Enums.LogMarkers; -import org.openecomp.sdc.common.ecomplog.Enums.Severity; -import org.openecomp.sdc.common.ecomplog.api.IEcompMdcWrapper; -import org.slf4j.MarkerFactory; - - -public class EcompLoggerMetric extends EcompLoggerBase{ - private static EcompLoggerMetric instanceLoggerMetric = (EcompLoggerMetric) EcompLoggerFactory.getLogger(EcompLoggerMetric.class); - - EcompLoggerMetric(IEcompMdcWrapper ecompMdcWrapper) { - super(ecompMdcWrapper, MarkerFactory.getMarker(LogMarkers.METRIC_MARKER.text())); - } - - public static EcompLoggerMetric getInstance() { - return instanceLoggerMetric; - } - - @Override - public EcompLoggerMetric startTimer() { - return (EcompLoggerMetric) super.startTimer(); - } - - @Override - public EcompLoggerMetric setKeyRequestId(String keyRequestId) { - return (EcompLoggerMetric) super.setKeyRequestId(keyRequestId); - } - - public EcompLoggerMetric stopTimer() { - ecompMdcWrapper.stopTimer(); - return this; - } - - // automatic parameter this is optional - public EcompLoggerMetric setAutoServerFQDN(String serverFQDN) { - ecompMdcWrapper.setAutoServerFQDN(serverFQDN); - return this; - } - - // automatic parameter this is optional - public EcompLoggerMetric setAutoServerIPAddress(String serverIPAddress) { - ecompMdcWrapper.setAutoServerIPAddress(serverIPAddress); - return this; - } - - public EcompLoggerMetric setInstanceUUID(String instanceUUID) { - ecompMdcWrapper.setInstanceUUID(instanceUUID); - return this; - } - - // ecomplog optional parameter - public EcompLoggerMetric setOptProcessKey(String processKey) { - ecompMdcWrapper.setProcessKey(processKey); - return this; - } - - // ecomplog optional parameter - public EcompLoggerMetric setOptAlertSeverity(Severity alertSeverity) { - ecompMdcWrapper.setAlertSeverity(alertSeverity); - return this; - } - - // ecomplog optional parameter - public EcompLoggerMetric setOptCustomField1(String customField1) { - ecompMdcWrapper.setOptCustomField1(customField1); - return this; - } - - // ecomplog optional parameter - public EcompLoggerMetric setOptCustomField2(String customField2) { - ecompMdcWrapper.setOptCustomField2(customField2); - return this; - } - - // ecomplog optional parameter - public EcompLoggerMetric setOptCustomField3(String customField3) { - ecompMdcWrapper.setOptCustomField3(customField3); - return this; - } - - // ecomplog optional parameter - public EcompLoggerMetric setOptCustomField4(String customField4) { - ecompMdcWrapper.setOptCustomField4(customField4); - return this; - } - - public EcompLoggerMetric setRemoteHost(String remoteHost) { - ecompMdcWrapper.setRemoteHost(remoteHost); - return this; - } - - public EcompLoggerMetric setServiceName(String serviceName) { - ecompMdcWrapper.setServiceName(serviceName); - return this; - } - - public EcompLoggerMetric setStatusCode(String statusCode) { - ecompMdcWrapper.setStatusCode(statusCode); - return this; - } - - public EcompLoggerMetric setPartnerName(String partnerName) { - ecompMdcWrapper.setPartnerName(partnerName); - return this; - } - - public EcompLoggerMetric setResponseCode(int responseCode) { - ecompMdcWrapper.setResponseCode(responseCode); - return this; - } - - public EcompLoggerMetric setResponseDesc(String responseDesc) { - ecompMdcWrapper.setResponseDesc(responseDesc); - return this; - } - - public EcompLoggerMetric setOptServiceInstanceId(String serviceInstanceId) { - ecompMdcWrapper.setServiceInstanceId(serviceInstanceId); - return this; - } - - public EcompLoggerMetric setOptClassName(String className) { - ecompMdcWrapper.setClassName(className); - return this; - } - - public EcompLoggerMetric setTargetEntity(String targetEntity) { - ecompMdcWrapper.setTargetEntity(targetEntity); - return this; - } - - public EcompLoggerMetric setTargetServiceName(String targetServiceName) { - ecompMdcWrapper.setTargetServiceName(targetServiceName); - return this; - } - - public EcompLoggerMetric setTargetVirtualEntity(String targetVirtualEntity) { - ecompMdcWrapper.setTargetVirtualEntity(targetVirtualEntity); - return this; - } - - @Override - public EcompLoggerMetric clear () { - return (EcompLoggerMetric) super.clear(); - } - - - @Override - public void initializeMandatoryFields() { - - ecompMdcWrapper.setMandatoryField(MDC_BEGIN_TIMESTAMP); - ecompMdcWrapper.setMandatoryField(MDC_END_TIMESTAMP); - ecompMdcWrapper.setMandatoryField(MDC_KEY_REQUEST_ID); - ecompMdcWrapper.setMandatoryField(MDC_SERVICE_NAME); - ecompMdcWrapper.setMandatoryField(MDC_PARTNER_NAME); - ecompMdcWrapper.setMandatoryField(MDC_STATUS_CODE); - ecompMdcWrapper.setMandatoryField(MDC_RESPONSE_CODE); - ecompMdcWrapper.setMandatoryField(MDC_SERVICE_INSTANCE_ID); - ecompMdcWrapper.setMandatoryField(MDC_RESPONSE_DESC); - ecompMdcWrapper.setMandatoryField(MDC_ELAPSED_TIME); - ecompMdcWrapper.setMandatoryField(MDC_TARGET_ENTITY); - ecompMdcWrapper.setMandatoryField(MDC_TARGET_SERVICE_NAME); - ecompMdcWrapper.setMandatoryField(MDC_TARGET_VIRTUAL_ENTITY); - - //Theoretically Optional, but practically Mandatory - ecompMdcWrapper.setMandatoryField(MDC_SERVER_IP_ADDRESS); - ecompMdcWrapper.setMandatoryField(MDC_SERVER_FQDN); - - ecompMdcWrapper.setOptionalField(MDC_INSTANCE_UUID); - ecompMdcWrapper.setOptionalField(MDC_ALERT_SEVERITY); - ecompMdcWrapper.setOptionalField(MDC_REMOTE_HOST); - ecompMdcWrapper.setOptionalField(MDC_CLASS_NAME); - ecompMdcWrapper.setOptionalField(MDC_PROCESS_KEY); - ecompMdcWrapper.setOptionalField(MDC_OPT_FIELD1); - ecompMdcWrapper.setOptionalField(MDC_OPT_FIELD2); - ecompMdcWrapper.setOptionalField(MDC_OPT_FIELD3); - ecompMdcWrapper.setOptionalField(MDC_OPT_FIELD4); - - - } -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompMDCWrapper.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompMDCWrapper.java deleted file mode 100644 index 1d833ec6f9..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompMDCWrapper.java +++ /dev/null @@ -1,290 +0,0 @@ -package org.openecomp.sdc.common.ecomplog; - -import static java.lang.Integer.valueOf; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ALERT_SEVERITY; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_CLASS_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ERROR_CODE; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ERROR_DESC; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_INSTANCE_UUID; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_KEY_REQUEST_ID; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD1; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD2; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD3; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD4; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_PARTNER_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_PROCESS_KEY; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_REMOTE_HOST; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_RESPONSE_CODE; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_RESPONSE_DESC; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVER_FQDN; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVER_IP_ADDRESS; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVICE_INSTANCE_ID; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVICE_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_STATUS_CODE; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_TARGET_ENTITY; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_TARGET_SERVICE_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_TARGET_VIRTUAL_ENTITY; - -import java.net.InetAddress; -import java.util.ArrayList; - -import org.openecomp.sdc.common.ecomplog.Enums.Severity; -import org.openecomp.sdc.common.ecomplog.api.IEcompMdcWrapper; -import org.openecomp.sdc.common.ecomplog.api.IStopWatch; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; - -public class EcompMDCWrapper implements IEcompMdcWrapper { - - private static EcompMDCWrapper instanceMdcWrapper = new EcompMDCWrapper(new Stopwatch()); - - public static EcompMDCWrapper getInstance() { - return instanceMdcWrapper; - } - - private IStopWatch stopWatch; - protected static Logger log = LoggerFactory.getLogger(EcompMDCWrapper.class.getName()); - protected ArrayList<String> mandatoryFields = new ArrayList<>(); - protected ArrayList<String> optionalFields = new ArrayList<>(); - protected static String hostAddress; - protected static String fqdn; - - // in package classes can instantiate this class - // to use directly from outside the package usr the getInstance() Method - EcompMDCWrapper(IStopWatch stopwatch) { - this.stopWatch = stopwatch; - } - - static { - try { - hostAddress = InetAddress.getLocalHost().getHostAddress(); - fqdn = InetAddress.getByName(hostAddress).getCanonicalHostName(); - } catch (Exception ex) { - log.error("failed to get machine parameters", ex); - } - } - - @Override - public EcompMDCWrapper startTimer() { - stopWatch.start(); - return this; - } - - @Override - public EcompMDCWrapper stopTimer() { - try { - stopWatch.stop(); - } catch (Exception ex) { - log.error("StopWatch failed; probably start was not called before Stopwatch", ex); - } - return this; - } - - @Override - public EcompMDCWrapper setClassName(String className) { - MDC.put(MDC_CLASS_NAME, className); - return this; - } - - // automatic parameter this is optional - @Override - public EcompMDCWrapper setAutoServerFQDN(String serverFQDN) { - MDC.put(MDC_SERVER_FQDN, serverFQDN); - return this; - } - - // automatic parameter this is optional - @Override - public EcompMDCWrapper setAutoServerIPAddress(String serverIPAddress) { - MDC.put(MDC_SERVER_IP_ADDRESS, serverIPAddress); - return this; - } - - @Override - public EcompMDCWrapper setInstanceUUID(String instanceUUID) { - MDC.put(MDC_INSTANCE_UUID, instanceUUID); - return this; - } - - @Override - public EcompMDCWrapper setProcessKey(String processKey) { - MDC.put(MDC_PROCESS_KEY, processKey); - return this; - } - - @Override - public EcompMDCWrapper setAlertSeverity(Severity alertSeverity) { - MDC.put(MDC_ALERT_SEVERITY, String.valueOf(alertSeverity.getSeverityType())); - return this; - } - - @Override - public EcompMDCWrapper setOptCustomField1(String customField1) { - MDC.put(MDC_OPT_FIELD1, customField1); - return this; - } - - @Override - public EcompMDCWrapper setOptCustomField2(String customField2) { - MDC.put(MDC_OPT_FIELD2, customField2); - return this; - } - - @Override - public EcompMDCWrapper setOptCustomField3(String customField3) { - MDC.put(MDC_OPT_FIELD3, customField3); - return this; - } - - @Override - public EcompMDCWrapper setOptCustomField4(String customField4) { - MDC.put(MDC_OPT_FIELD4, customField4); - return this; - } - - @Override - public EcompMDCWrapper setKeyRequestId(String keyRequestId) { - MDC.put(MDC_KEY_REQUEST_ID, keyRequestId); // eg. servletRequest.getSession().getId() - return this; - } - - @Override - public EcompMDCWrapper setRemoteHost(String remoteHost) { - MDC.put(MDC_REMOTE_HOST, remoteHost); - return this; - } - - @Override - public EcompMDCWrapper setServiceName(String serviceName) { - MDC.put(MDC_SERVICE_NAME, serviceName); - return this; - } - - @Override - public EcompMDCWrapper setStatusCode(String statusCode) { - MDC.put(MDC_STATUS_CODE, statusCode); - return this; - } - - @Override - public EcompMDCWrapper setPartnerName(String partnerName) { - MDC.put(MDC_PARTNER_NAME, partnerName); - return this; - } - - @Override - public EcompMDCWrapper setResponseCode(int responseCode) { - MDC.put(MDC_RESPONSE_CODE, Integer.toString(responseCode)); - return this; - } - - @Override - public EcompMDCWrapper setResponseDesc(String responseDesc) { - MDC.put(MDC_RESPONSE_DESC, responseDesc); - return this; - } - - @Override - public EcompMDCWrapper setServiceInstanceId(String serviceInstanceId) { - MDC.put(MDC_SERVICE_INSTANCE_ID, serviceInstanceId); - return this; - } - - @Override - public EcompMDCWrapper setTargetEntity(String targetEntity) { - MDC.put(MDC_TARGET_ENTITY, targetEntity); - return this; - } - - @Override - public EcompMDCWrapper setTargetServiceName(String targetServiceName) { - MDC.put(MDC_TARGET_SERVICE_NAME, targetServiceName); - return this; - } - - @Override - public EcompMDCWrapper setTargetVirtualEntity(String targetVirtualEntity) { - MDC.put(MDC_TARGET_VIRTUAL_ENTITY, targetVirtualEntity); - return this; - } - - @Override - public EcompMDCWrapper setErrorCode(int errorCode) { - MDC.put(MDC_ERROR_CODE, valueOf(errorCode).toString()); - return this; - } - - @Override - public EcompMDCWrapper setErrorDescription(String errorDescription) { - MDC.put(MDC_ERROR_DESC, errorDescription); - return this; - } - - @Override - public void validateMandatoryFields() { - // this method only checks if the mandatory fields have been initialized - String filedNameThatHasNotBeenInitialized = checkMandatoryFieldsExistInMDC(); - - if (MDC.getCopyOfContextMap() == null || MDC.getCopyOfContextMap().isEmpty()) { - writeLogMDCEmptyError(); - return; - } - - if (!"".equalsIgnoreCase(filedNameThatHasNotBeenInitialized)) { - writeLogMissingFieldsError(filedNameThatHasNotBeenInitialized); - } - } - - protected void writeLogMissingFieldsError(String FiledNameThatHasNotBeenInitialized) { - log.error("mandatory parameters for EELF logging, missing fields: %s", FiledNameThatHasNotBeenInitialized); - } - - protected void writeLogMDCEmptyError() { - log.error("write to log when MDC is empty error"); - } - - @Override - public EcompMDCWrapper clear() { - mandatoryFields.forEach(MDC::remove); - optionalFields.forEach(MDC::remove); - return this; - } - - protected String checkMandatoryFieldsExistInMDC() { - // this method returns a String of uninitialised fields - StringBuilder missingFields = new StringBuilder(); - mandatoryFields.forEach(field -> { - if (isMDCParamEmpty(field)) { - missingFields.append(field).append(" "); - } - }); - return missingFields.toString(); - } - - @Override - public void setMandatoryField(String parameterName) { - mandatoryFields.add(parameterName); - } - - @Override - public void setOptionalField(String parameterName) { - optionalFields.add(parameterName); - } - - @Override - public boolean isMDCParamEmpty(String mdcKeyName) { - String val = MDC.get(mdcKeyName); - return (val == null || val.trim().length() == 0); - } - - @Override - public String getFqdn() { - return fqdn; - } - - @Override - public String getHostAddress() { - return hostAddress; - } -}
\ No newline at end of file diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Enums/EcompLoggerErrorCode.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Enums/EcompLoggerErrorCode.java deleted file mode 100644 index c6862656bb..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Enums/EcompLoggerErrorCode.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.openecomp.sdc.common.ecomplog.Enums; - -/** - * Created by dd4296 on 12/26/2017. - */ -public enum EcompLoggerErrorCode { - SUCCESS(0), - PERMISSION_ERROR(100), - AVAILABILITY_TIMEOUTS_ERROR(200), - DATA_ERROR(300), - SCHEMA_ERROR(400), - BUSINESS_PROCESS_ERROR(500), - UNKNOWN_ERROR(900); - - int errorCode; - - EcompLoggerErrorCode(int errorCode) { - this.errorCode = errorCode; - } - - public int getErrorCode() { - return errorCode; - } -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Stopwatch.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Stopwatch.java deleted file mode 100644 index 76262e7815..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Stopwatch.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.openecomp.sdc.common.ecomplog; - -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_BEGIN_TIMESTAMP; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ELAPSED_TIME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_END_TIMESTAMP; - -import java.time.Clock; -import java.time.Duration; -import java.time.LocalDateTime; - -import org.openecomp.sdc.common.ecomplog.api.IStopWatch; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; - -/** - * Created by dd4296 on 12/13/2017. - * this is local implementation of the stopwatch class from EELF standard with the same interface - * can be replaced if needed with EELF lib - */ -public class Stopwatch implements IStopWatch { - - private static Logger log = LoggerFactory.getLogger(Stopwatch.class.getName()); - - public Stopwatch() { - } - - public void start() { - if (MDC.get(MDC_BEGIN_TIMESTAMP) == null || MDC.get(MDC_BEGIN_TIMESTAMP).trim().length() == 0) - MDC.put(MDC_BEGIN_TIMESTAMP, generatedTimeNow()); - } - - public void stop() { - if (MDC.get(MDC_BEGIN_TIMESTAMP) == null) { - log.error("call to stop without calling start first, this is not compliant with EELF format"); - } - MDC.put(MDC_END_TIMESTAMP, generatedTimeNow()); - setElapsedTime(); - } - - private void setElapsedTime() { - - try { - - final LocalDateTime startTime = LocalDateTime.parse(MDC.get(MDC_BEGIN_TIMESTAMP)); - final LocalDateTime endTime = LocalDateTime.parse(MDC.get(MDC_END_TIMESTAMP)); - - final Duration timeDifference = Duration.between(startTime, endTime); - - MDC.put(MDC_ELAPSED_TIME, String.valueOf(timeDifference.toMillis())); - - } catch(Exception ex) { - log.error("failed to calculate elapsed time",ex); - } - } - - private String generatedTimeNow() { - return String.valueOf(LocalDateTime.now(Clock.systemUTC())); - } - -}
\ No newline at end of file diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/api/IEcompLogger.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/api/IEcompLogger.java deleted file mode 100644 index 569343eaf6..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/api/IEcompLogger.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.openecomp.sdc.common.ecomplog.api; - -import org.openecomp.sdc.common.ecomplog.Enums.LogLevel; - -/** - * Created by dd4296 on 12/24/2017. - */ -public interface IEcompLogger { - void log(LogLevel errorLevel, String message); - void initializeMandatoryFields(); - IEcompLogger clear(); - IEcompLogger startTimer(); - IEcompLogger setKeyRequestId(String keyRequestId); -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/api/IEcompMdcWrapper.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/api/IEcompMdcWrapper.java deleted file mode 100644 index 37d77fd6c5..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/api/IEcompMdcWrapper.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.openecomp.sdc.common.ecomplog.api; - -import org.openecomp.sdc.common.ecomplog.EcompMDCWrapper; -import org.openecomp.sdc.common.ecomplog.Enums.Severity; - -/** - * Created by dd4296 on 12/25/2017. - */ -public interface IEcompMdcWrapper { - EcompMDCWrapper startTimer(); - - EcompMDCWrapper stopTimer(); - - EcompMDCWrapper setClassName(String className); - - // automatic parameter this is optional - EcompMDCWrapper setAutoServerFQDN(String serverFQDN); - - // automatic parameter this is optional - EcompMDCWrapper setAutoServerIPAddress(String serverIPAddress); - - EcompMDCWrapper setInstanceUUID(String instanceUUID); - - EcompMDCWrapper setProcessKey(String processKey); - - EcompMDCWrapper setAlertSeverity(Severity alertSeverity); - - EcompMDCWrapper setOptCustomField1(String customField1); - - EcompMDCWrapper setOptCustomField2(String customField2); - - EcompMDCWrapper setOptCustomField3(String customField3); - - EcompMDCWrapper setOptCustomField4(String customField4); - - EcompMDCWrapper setKeyRequestId(String keyRequestId); - - EcompMDCWrapper setRemoteHost(String remoteHost); - - EcompMDCWrapper setServiceName(String serviceName); - - EcompMDCWrapper setStatusCode(String statusCode); - - EcompMDCWrapper setPartnerName(String partnerName); - - EcompMDCWrapper setResponseCode(int responseCode); - - EcompMDCWrapper setResponseDesc(String responseDesc); - - EcompMDCWrapper setServiceInstanceId(String serviceInstanceId); - - EcompMDCWrapper setTargetEntity(String targetEntity); - - EcompMDCWrapper setTargetServiceName(String targetServiceName); - - EcompMDCWrapper setTargetVirtualEntity(String targetVirtualEntity); - - EcompMDCWrapper setErrorCode(int errorCode); - - EcompMDCWrapper setErrorDescription(String errorDescription); - - EcompMDCWrapper clear(); - - void validateMandatoryFields(); - - void setMandatoryField(String mdcKeyRequestId); - - void setOptionalField(String mdcKeyRequestId); - - boolean isMDCParamEmpty(String mdcKeyName); - - String getFqdn(); - - String getHostAddress(); -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/api/IStopWatch.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/api/IStopWatch.java deleted file mode 100644 index 4f1649cef1..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/api/IStopWatch.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.openecomp.sdc.common.ecomplog.api; - -/** - * Created by dd4296 on 12/14/2017. - * - * stop watch interface compliant with ecomplog stop watch class - */ -public interface IStopWatch { - void start(); - void stop(); -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcAudit.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcAudit.java deleted file mode 100644 index 57499b340d..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcAudit.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.openecomp.sdc.common.ecomplogwrapper; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.container.ContainerRequestContext; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response; - -import org.openecomp.sdc.common.api.Constants; -import org.openecomp.sdc.common.ecomplog.EcompLoggerAudit; -import org.openecomp.sdc.common.ecomplog.Enums.LogLevel; -import org.openecomp.sdc.common.ecomplog.Enums.Severity; -import org.slf4j.MDC; - - -/** - * Created by dd4296 on 12/19/2017. - * - * audit log for asdc using the ecomplog library - * this is adapted for filter classes - */ -public class EcompLoggerSdcAudit extends EcompLoggerSdcUtilBase { - - private static String AUDIT_ON = "auditOn"; - private String className; - - public EcompLoggerSdcAudit(String className) { - this.className = className; - } - - public void startLog() { - EcompLoggerAudit - .getInstance() - .clear() - .startTimer(); - MDC.put(AUDIT_ON, "true"); - } - - public static boolean isFlowBeingTakenCare(){ - try - { - if (MDC.get(AUDIT_ON).equals("true")){ - return true; - } - return false; - } - catch (Exception E) - { - return false; - } - } - - public void log(HttpServletRequest sr, - ContainerRequestContext requestContext, - Response.StatusType statusInfo, - MultivaluedMap<String, Object> responseHeaders, - LogLevel errorLevel, - Severity securityLevel, - String message) { - - try { - EcompLoggerAudit.getInstance() - .stopTimer() - .setRemoteHost(sr.getRemoteAddr()) - .setServiceName(getServiceName(requestContext)) - .setResponseCode(convertHttpCodeToErrorCode(statusInfo.getStatusCode())) - .setStatusCode(Integer.toString(statusInfo.getStatusCode())) - .setResponseDesc(statusInfo.getReasonPhrase()) - .setKeyRequestId(getRequestIDfromHeaders(responseHeaders.get(Constants.X_ECOMP_REQUEST_ID_HEADER))) - - .setPartnerName(getPartnerName( - requestContext.getHeaderString("user-agent"), - requestContext.getHeaderString("USER_ID"), - getUrl(requestContext))) - - .setInstanceUUID(requestContext.getHeaderString(Constants.X_ECOMP_INSTANCE_ID_HEADER)) - - .setOptServiceInstanceId(requestContext.getHeaderString(Constants.X_ECOMP_SERVICE_ID_HEADER)) - .setOptClassName(className) - .setOptAlertSeverity(securityLevel) - .setOptCustomField1(requestContext.getMethod() + ": " + getUrl(requestContext)) - .setOptCustomField2(Integer.toString(statusInfo.getStatusCode())) - .log(errorLevel, message); - } - catch (Exception E) - { - log.warn("Faild to write to Audit Log. Original Message: {}", message); - } - finally { - MDC.put(AUDIT_ON,"false"); - } - } -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcDebug.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcDebug.java deleted file mode 100644 index 57e9e8c5a0..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcDebug.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.openecomp.sdc.common.ecomplogwrapper; - -import java.util.Arrays; - -import org.openecomp.sdc.common.ecomplog.EcompLoggerDebug; -import org.openecomp.sdc.common.ecomplog.Enums.LogLevel; - -public class EcompLoggerSdcDebug { - - public void log(LogLevel errorLevel, - String uuid, - String message, - Exception ex) { - - StringBuilder stackTrack = new StringBuilder(); - Arrays.asList(ex.getStackTrace()).forEach(item -> stackTrack.append(item.toString()).append("\n")); - - EcompLoggerDebug.getInstance() - .clear() - .startTimer() - .setKeyRequestId(uuid) - .log(errorLevel, String.format("%s %s", message, stackTrack.toString())); - } - - public void log(LogLevel errorLevel, - String uuid, - String message) { - - EcompLoggerDebug.getInstance() - .clear() - .startTimer() - .setKeyRequestId(uuid) - .log(errorLevel, message); - } -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcError.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcError.java deleted file mode 100644 index a2478c40eb..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcError.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.openecomp.sdc.common.ecomplogwrapper; - -import org.openecomp.sdc.common.ecomplog.EcompLoggerError; -import org.openecomp.sdc.common.ecomplog.Enums.EcompLoggerErrorCode; -import org.openecomp.sdc.common.ecomplog.Enums.LogLevel; - -public class EcompLoggerSdcError { - - public void log(LogLevel errorLevel, - EcompLoggerErrorCode errorCodeEnum, - String uuid, - String errorDescription, - String partnerName, - String targetEntity, - String message) { - - EcompLoggerError.getInstance() - .clear() - .startTimer() - .setErrorDescription(errorDescription) - .setErrorCode(errorCodeEnum) - .setKeyRequestId(uuid) - .setServiceName(partnerName) - .setTargetEntity(targetEntity) - .log(errorLevel, message); - } -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcMetric.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcMetric.java deleted file mode 100644 index 8603a77d08..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcMetric.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.openecomp.sdc.common.ecomplogwrapper; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.container.ContainerRequestContext; -import javax.ws.rs.core.Response; - -import org.openecomp.sdc.common.api.Constants; -import org.openecomp.sdc.common.ecomplog.EcompLoggerAudit; -import org.openecomp.sdc.common.ecomplog.EcompLoggerMetric; -import org.openecomp.sdc.common.ecomplog.Enums.LogLevel; -import org.openecomp.sdc.common.ecomplog.Enums.Severity; -import org.openecomp.sdc.common.util.ThreadLocalsHolder; - -/** - * Created by dd4296 on 12/20/2017. - * - * METRIC log for asdc using the ecomplog library - */ -public class EcompLoggerSdcMetric extends EcompLoggerSdcUtilBase { - - private String className; - - public EcompLoggerSdcMetric(String className) { - this.className = className; - } - - public void startLog() { - EcompLoggerAudit - .getInstance() - .clear() - .startTimer(); - } - - public void writeToLog(HttpServletRequest sr, - ContainerRequestContext requestContext, - Response.StatusType statusInfo, - LogLevel errorLevel, - Severity securityLevel, - String targetEntity, - String targetServiceName, - String targetVirtualEntity, - String message) { - - EcompLoggerMetric.getInstance() - .stopTimer() - .setRemoteHost(sr.getRemoteAddr()) - .setServiceName(getServiceName(requestContext)) - .setResponseCode(statusInfo.getStatusCode()) - .setStatusCode(Integer.toString(statusInfo.getStatusCode())) - .setResponseDesc(statusInfo.getReasonPhrase()) - .setKeyRequestId(ThreadLocalsHolder.getUuid()) - - .setPartnerName(getPartnerName( - requestContext.getHeaderString("user-agent"), - requestContext.getHeaderString("USER_ID"), - getUrl(requestContext))) - - .setInstanceUUID(requestContext.getHeaderString(Constants.X_ECOMP_INSTANCE_ID_HEADER)) - - .setOptServiceInstanceId(requestContext.getHeaderString(Constants.X_ECOMP_SERVICE_ID_HEADER)) - .setOptClassName(className) - .setOptAlertSeverity(securityLevel) - .setOptCustomField1(getUrl(requestContext) + "/" + requestContext.getMethod()) - - .setTargetEntity(targetEntity) - .setTargetServiceName(targetServiceName) - .setTargetVirtualEntity(targetVirtualEntity) - - .log(errorLevel, message); - } -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClient.java b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClient.java index 26518a6456..1240f9a8f9 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClient.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClient.java @@ -1,9 +1,5 @@ package org.openecomp.sdc.common.http.client.api; -import java.io.IOException; -import java.net.URI; -import java.util.Properties; - import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.HttpHeaders; @@ -13,13 +9,7 @@ import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.AuthCache; import org.apache.http.client.CredentialsProvider; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPatch; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import org.apache.http.client.methods.HttpRequestBase; +import org.apache.http.client.methods.*; import org.apache.http.client.protocol.HttpClientContext; import org.apache.http.impl.auth.BasicScheme; import org.apache.http.impl.client.BasicAuthCache; @@ -29,11 +19,14 @@ import org.openecomp.sdc.be.config.BeEcompErrorManager; import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.datastructure.FunctionalInterfaces.FunctionThrows; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.openecomp.sdc.common.log.wrappers.Logger; + +import java.io.IOException; +import java.net.URI; +import java.util.Properties; public class HttpClient { - private static final Logger logger = LoggerFactory.getLogger(HttpClient.class); + private static final Logger logger = Logger.getLogger(HttpClient.class.getName()); private final CloseableHttpClient client; private final HttpClientConfigImmutable configImmutable; @@ -82,7 +75,7 @@ public class HttpClient { private <T> HttpResponse<T> execute(HttpRequestBase request, Properties headers, FunctionThrows<CloseableHttpResponse, HttpResponse<T>, Exception> responseBuilder) throws HttpExecuteException { if(configImmutable.getHeaders() != null) { - configImmutable.getHeaders().forEach((k, v) -> request.addHeader(k, v)); + configImmutable.getHeaders().forEach(request::addHeader); } if (headers != null) { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClientConfigImmutable.java b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClientConfigImmutable.java index bfd3b473b4..1745650c91 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClientConfigImmutable.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClientConfigImmutable.java @@ -1,14 +1,14 @@ package org.openecomp.sdc.common.http.client.api; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - import org.openecomp.sdc.common.http.config.BasicAuthorization; import org.openecomp.sdc.common.http.config.ClientCertificate; import org.openecomp.sdc.common.http.config.HttpClientConfig; import org.openecomp.sdc.common.http.config.Timeouts; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + final class HttpClientConfigImmutable { private final Map<String, String> headers; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClientFactory.java b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClientFactory.java index c52880cb96..357eef3d0d 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClientFactory.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClientFactory.java @@ -8,12 +8,11 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.http.config.ClientCertificate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.openecomp.sdc.common.log.wrappers.Logger; public class HttpClientFactory { - private static final Logger LOGGER = LoggerFactory.getLogger(HttpClientFactory.class); + private static final Logger logger = Logger.getLogger(HttpClientFactory.class.getName()); private static final UserTokenHandler userTokenHandler = context -> null; private final HttpConnectionMngFactory connectionMngFactory; @@ -22,7 +21,7 @@ public class HttpClientFactory { } HttpClient createClient(String protocol, HttpClientConfigImmutable config) { - LOGGER.debug("Create {} client based on {}", protocol, config); + logger.debug("Create {} client based on {}", protocol, config); ClientCertificate clientCertificate = Constants.HTTPS.equals(protocol) ? config.getClientCertificate() : null; HttpClientConnectionManager connectionManager = connectionMngFactory.getOrCreate(clientCertificate); diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpConnectionMngFactory.java b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpConnectionMngFactory.java index 6a408c92cd..de50e8a0a7 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpConnectionMngFactory.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpConnectionMngFactory.java @@ -1,13 +1,5 @@ package org.openecomp.sdc.common.http.client.api; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.security.GeneralSecurityException; -import java.security.KeyStore; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - import org.apache.commons.lang3.StringUtils; import org.apache.http.config.Registry; import org.apache.http.config.RegistryBuilder; @@ -21,8 +13,15 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.ssl.SSLContextBuilder; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.http.config.ClientCertificate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.openecomp.sdc.common.log.wrappers.Logger; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.security.GeneralSecurityException; +import java.security.KeyStore; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; public class HttpConnectionMngFactory { @@ -33,7 +32,7 @@ public class HttpConnectionMngFactory { private static final String P12_KEYSTORE_TYPE = "pkcs12"; private static final String JKS_KEYSTORE_TYPE = "jks"; - private static final Logger logger = LoggerFactory.getLogger(HttpConnectionMngFactory.class); + private static final Logger logger = Logger.getLogger(HttpConnectionMngFactory.class.getName()); private static final int DEFAULT_CONNECTION_POOL_SIZE = 30; private static final int DEFAULT_MAX_CONNECTION_PER_ROUTE = 5; private static final int VALIDATE_CONNECTION_AFTER_INACTIVITY_MS = 10000; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpRequestHandler.java b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpRequestHandler.java index 5722fc9c4e..9619e11a14 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpRequestHandler.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpRequestHandler.java @@ -1,10 +1,6 @@ package org.openecomp.sdc.common.http.client.api; -import java.io.InputStream; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.ConcurrentHashMap; - +import com.google.common.annotations.VisibleForTesting; import org.apache.commons.io.IOUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; @@ -13,8 +9,13 @@ import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.datastructure.FunctionalInterfaces.FunctionThrows; import org.openecomp.sdc.common.http.config.HttpClientConfig; -public enum HttpRequestHandler { - HANDLER; +import java.io.InputStream; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.ConcurrentHashMap; + +public class HttpRequestHandler { + private static HttpRequestHandler handlerInstance = new HttpRequestHandler(); private static final String HTTPS_PREFIX = "https://"; private static final String HTTP_PREFIX = "http://"; @@ -46,13 +47,13 @@ public enum HttpRequestHandler { httpResponse.getStatusLine().getReasonPhrase()); }; - HttpRequestHandler() { + private HttpRequestHandler() { HttpConnectionMngFactory connectionMngFactory = new HttpConnectionMngFactory(); clientFactory = new HttpClientFactory(connectionMngFactory); } - static HttpRequestHandler get() { - return HANDLER; + public static HttpRequestHandler get() { + return handlerInstance; } public HttpResponse<String> get(String url, Properties headers, HttpClientConfig config) throws HttpExecuteException { @@ -100,7 +101,12 @@ public enum HttpRequestHandler { return clientFactory.createClient(protocol, config); } - private String getProtocol(String url) throws HttpExecuteException { + @VisibleForTesting + public static void setTestInstance(HttpRequestHandler handlerInstance) { + HttpRequestHandler.handlerInstance = handlerInstance; + } + + private String getProtocol(String url) throws HttpExecuteException { if (url.startsWith(HTTPS_PREFIX)) { return Constants.HTTPS; } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/RetryHandlers.java b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/RetryHandlers.java index 3e3b61f0f1..da5368d2a6 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/RetryHandlers.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/RetryHandlers.java @@ -1,21 +1,20 @@ package org.openecomp.sdc.common.http.client.api; import org.apache.http.protocol.HttpContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.openecomp.sdc.common.log.wrappers.Logger; import java.io.IOException; public class RetryHandlers { - private static final Logger LOGGER = LoggerFactory.getLogger(RetryHandlers.class); + private static final Logger logger = Logger.getLogger(RetryHandlers.class.getName()); private RetryHandlers(){} public static ComparableHttpRequestRetryHandler getDefault(int numOfRetries) { return (IOException exception, int executionCount, HttpContext context) -> { - LOGGER.debug("failed sending request with exception", exception); - LOGGER.debug("try request number: {}", executionCount); + logger.debug("failed sending request with exception", exception); + logger.debug("try request number: {}", executionCount); return executionCount <= numOfRetries; }; } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/BasicAuthorization.java b/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/BasicAuthorization.java index 4fb8fadce4..57750be0f1 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/BasicAuthorization.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/BasicAuthorization.java @@ -1,10 +1,9 @@ package org.openecomp.sdc.common.http.config; +import fj.data.Either; import org.apache.commons.lang3.StringUtils; import org.openecomp.sdc.security.SecurityUtil; -import fj.data.Either; - public class BasicAuthorization { private String userName; private String password; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/ClientCertificate.java b/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/ClientCertificate.java index 972a4178e0..11e0fa7b1b 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/ClientCertificate.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/ClientCertificate.java @@ -1,10 +1,9 @@ package org.openecomp.sdc.common.http.config; +import fj.data.Either; import org.apache.commons.lang3.StringUtils; import org.openecomp.sdc.security.SecurityUtil; -import fj.data.Either; - public class ClientCertificate { private String keyStore; private String keyStorePassword; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/HttpClientConfig.java b/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/HttpClientConfig.java index 69789957b4..c454ffcb0e 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/HttpClientConfig.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/HttpClientConfig.java @@ -1,9 +1,9 @@ package org.openecomp.sdc.common.http.config; -import java.util.Map; - import org.openecomp.sdc.common.http.client.api.ComparableHttpRequestRetryHandler; +import java.util.Map; + public class HttpClientConfig { private BasicAuthorization basicAuthorization; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ConfigFileChangeListener.java b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ConfigFileChangeListener.java index 9364dad476..3a7ccd774a 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ConfigFileChangeListener.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ConfigFileChangeListener.java @@ -20,24 +20,23 @@ package org.openecomp.sdc.common.impl; +import org.apache.commons.jci.listeners.FileChangeListener; +import org.openecomp.sdc.common.api.BasicConfiguration; +import org.openecomp.sdc.common.api.ConfigurationListener; +import org.openecomp.sdc.common.log.wrappers.Logger; +import org.openecomp.sdc.common.util.YamlToObjectConverter; + import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.commons.jci.listeners.FileChangeListener; -import org.openecomp.sdc.common.api.BasicConfiguration; -import org.openecomp.sdc.common.api.ConfigurationListener; -import org.openecomp.sdc.common.util.YamlToObjectConverter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - public class ConfigFileChangeListener extends FileChangeListener { - private static Logger log = LoggerFactory.getLogger(ConfigFileChangeListener.class.getName()); + private static Logger log = Logger.getLogger(ConfigFileChangeListener.class.getName()); - private Map<String, List<ConfigurationListener>> fileChangeToCallBack = new HashMap<String, List<ConfigurationListener>>(); + private Map<String, List<ConfigurationListener>> fileChangeToCallBack = new HashMap<>(); private Object lock = new Object(); @@ -116,7 +115,7 @@ public class ConfigFileChangeListener extends FileChangeListener { List<ConfigurationListener> callbacks = fileChangeToCallBack.get(id); if (callbacks == null) { - callbacks = new ArrayList<ConfigurationListener>(); + callbacks = new ArrayList<>(); fileChangeToCallBack.put(id, callbacks); } callbacks.add(configurationListener); diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ExternalConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ExternalConfiguration.java index b23dcb8812..79a78828e8 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ExternalConfiguration.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ExternalConfiguration.java @@ -20,11 +20,11 @@ package org.openecomp.sdc.common.impl; -import java.io.File; - import org.apache.commons.jci.monitor.FilesystemAlterationMonitor; import org.openecomp.sdc.common.api.ConfigurationSource; +import java.io.File; + /** * * Save the diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/MutableHttpServletRequest.java b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/MutableHttpServletRequest.java index c7ce7a8c32..3b88ff8978 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/MutableHttpServletRequest.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/MutableHttpServletRequest.java @@ -20,15 +20,9 @@ package org.openecomp.sdc.common.impl; -import java.util.Collections; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; +import java.util.*; public final class MutableHttpServletRequest extends HttpServletRequestWrapper { // holds custom header and value mapping @@ -36,7 +30,7 @@ public final class MutableHttpServletRequest extends HttpServletRequestWrapper { public MutableHttpServletRequest(HttpServletRequest request) { super(request); - this.customHeaders = new HashMap<String, String>(); + this.customHeaders = new HashMap<>(); } public void putHeader(String name, String value) { @@ -56,7 +50,7 @@ public final class MutableHttpServletRequest extends HttpServletRequestWrapper { public Enumeration<String> getHeaderNames() { // create a set of the custom header names - Set<String> set = new HashSet<String>(customHeaders.keySet()); + Set<String> set = new HashSet<>(customHeaders.keySet()); // now add the headers from the wrapped request object @SuppressWarnings("unchecked") diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/jsongraph/util/CommonUtility.java b/common-app-api/src/main/java/org/openecomp/sdc/common/jsongraph/util/CommonUtility.java index dfcf5b58c0..a4fc1b520e 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/jsongraph/util/CommonUtility.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/jsongraph/util/CommonUtility.java @@ -20,7 +20,7 @@ package org.openecomp.sdc.common.jsongraph.util; -import org.slf4j.Logger; +import org.openecomp.sdc.common.log.wrappers.Logger; /** * Provides common utility: functionality, common fields and enumerations diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/kpi/api/ASDCKpiApi.java b/common-app-api/src/main/java/org/openecomp/sdc/common/kpi/api/ASDCKpiApi.java index 5644ef5c41..65cf7161d4 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/kpi/api/ASDCKpiApi.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/kpi/api/ASDCKpiApi.java @@ -20,12 +20,11 @@ package org.openecomp.sdc.common.kpi.api; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.openecomp.sdc.common.log.wrappers.Logger; public class ASDCKpiApi { - private static Logger log = LoggerFactory.getLogger(ASDCKpiApi.class.getName()); + private static Logger log = Logger.getLogger(ASDCKpiApi.class.getName()); /* Number of activated resource imports. */ public static void countImportResourcesKPI() { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java b/common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java index 75449529d6..f5325a73e1 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java @@ -20,6 +20,15 @@ package org.openecomp.sdc.common.listener; +import org.openecomp.sdc.common.api.ConfigurationSource; +import org.openecomp.sdc.common.api.Constants; +import org.openecomp.sdc.common.impl.ExternalConfiguration; +import org.openecomp.sdc.common.impl.FSConfigurationSource; +import org.openecomp.sdc.common.log.wrappers.Logger; + +import javax.servlet.ServletContext; +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -28,20 +37,9 @@ import java.util.Map; import java.util.jar.Attributes; import java.util.jar.Manifest; -import javax.servlet.ServletContext; -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; - -import org.openecomp.sdc.common.api.ConfigurationSource; -import org.openecomp.sdc.common.api.Constants; -import org.openecomp.sdc.common.impl.ExternalConfiguration; -import org.openecomp.sdc.common.impl.FSConfigurationSource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - public class AppContextListener implements ServletContextListener { - private static Logger log = LoggerFactory.getLogger(AppContextListener.class.getName()); + private static Logger log = Logger.getLogger(AppContextListener.class.getName()); public void contextInitialized(ServletContextEvent context) { @@ -91,7 +89,7 @@ public class AppContextListener implements ServletContextListener { public static Map<String, String> getManifestInfo(ServletContext application) { - Map<String, String> result = new HashMap<String, String>(); + Map<String, String> result = new HashMap<>(); InputStream inputStream = null; try { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/api/IEcompLogConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/api/ILogConfiguration.java index 6521ea78e1..d5acb34319 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/api/IEcompLogConfiguration.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/api/ILogConfiguration.java @@ -1,17 +1,6 @@ -package org.openecomp.sdc.common.ecomplog.api; +package org.openecomp.sdc.common.log.api; -public interface IEcompLogConfiguration { - String PROPERTY_LOGGING_FILE_NAME = "com.att.ecomplog.logging.file"; - String PROPERTY_LOGGING_FILE_PATH = "com.att.ecomplog.logging.path"; - String GENERAL_LOGGER_NAME = "com.att.ecomplog"; - String METRICS_LOGGER_NAME = "com.att.ecomplog.metrics"; - String PERF_LOGGER_NAME = "com.att.ecomplog.perf"; - String POLICY_LOGGER_NAME = "com.att.ecomplog.policy"; - String SECURITY_LOGGER_NAME = "com.att.ecomplog.security"; - String SERVER_LOGGER_NAME = "com.att.ecomplog.server"; - String AUDIT_LOGGER_NAME = "com.att.ecomplog.audit"; - String ERROR_LOGGER_NAME = "com.att.ecomplog.error"; - String DEBUG_LOGGER_NAME = "com.att.ecomplog.debug"; +public interface ILogConfiguration { String MDC_KEY_REQUEST_ID = "RequestId"; String MDC_SERVICE_INSTANCE_ID = "ServiceInstanceId"; String MDC_SERVICE_NAME = "ServiceName"; @@ -19,8 +8,10 @@ public interface IEcompLogConfiguration { String MDC_SERVER_IP_ADDRESS = "ServerIPAddress"; String MDC_SERVER_FQDN = "ServerFQDN"; String MDC_REMOTE_HOST = "RemoteHost"; + String MDC_AUDIT_MESSAGE = "AuditMessage"; String MDC_ALERT_SEVERITY = "AlertSeverity"; - String MDC_BEGIN_TIMESTAMP = "BeginTimestamp"; + String MDC_AUDIT_BEGIN_TIMESTAMP = "AuditBeginTimestamp"; + String MDC_METRIC_BEGIN_TIMESTAMP = "MetricBeginTimestamp"; String MDC_END_TIMESTAMP = "EndTimestamp"; String MDC_PARTNER_NAME = "PartnerName"; String MDC_STATUS_CODE = "StatusCode"; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/api/ILogFieldsHandler.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/api/ILogFieldsHandler.java new file mode 100644 index 0000000000..1c46a41af2 --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/api/ILogFieldsHandler.java @@ -0,0 +1,111 @@ +package org.openecomp.sdc.common.log.api; + +import org.openecomp.sdc.common.log.enums.Severity; + +/** + * Created by dd4296 on 12/25/2017. + */ +public interface ILogFieldsHandler { + void startAuditTimer(); + + void startMetricTimer(); + + void stopAuditTimer(); + + void stopMetricTimer(); + + void setClassName(String className); + + void setServerFQDN(String serverFQDN); + + void setServerIPAddress(String serverIPAddress); + + // intended for setting this parameter in a given thread + void setServerFQDNInternally(); + + // intended for setting this parameter in a given thread + void setServerIPAddressInternally(); + + void setInstanceUUID(String instanceUUID); + + void setProcessKey(String processKey); + + void setAlertSeverity(Severity alertSeverity); + + void setOptCustomField1(String customField1); + + void setOptCustomField2(String customField2); + + void setOptCustomField3(String customField3); + + void setOptCustomField4(String customField4); + + void setKeyRequestId(String keyRequestId); + + void setRemoteHost(String remoteHost); + + void setServiceName(String serviceName); + + void setStatusCode(String statusCode); + + void setPartnerName(String partnerName); + + void setResponseCode(int responseCode); + + void setResponseDesc(String responseDesc); + + void setServiceInstanceId(String serviceInstanceId); + + void setTargetEntity(String targetEntity); + + void setTargetServiceName(String targetServiceName); + + void setTargetVirtualEntity(String targetVirtualEntity); + + void setErrorCode(int errorCode); + + void setErrorCategory(String errorCategory); + + String getErrorCode(); + + String getServiceName(); + + String getErrorCategory(); + + void clear(); + + boolean isMDCParamEmpty(String mdcKeyName); + + String getFqdn(); + + String getHostAddress(); + + String getKeyRequestId(); + + void removeStatusCode(); + + void removePartnerName(); + + void removeResponseCode(); + + void removeResponseDesc(); + + void removeServiceInstanceId(); + + void removeTargetEntity(); + + void removeTargetServiceName(); + + void removeTargetVirtualEntity(); + + void removeErrorCode(); + + void removeErrorCategory(); + + void removeErrorDescription(); + + void setAuditMessage(String message); + + String getAuditMessage(); + +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/api/ILogger.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/api/ILogger.java new file mode 100644 index 0000000000..887be9189e --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/api/ILogger.java @@ -0,0 +1,18 @@ +package org.openecomp.sdc.common.log.api; + +import org.openecomp.sdc.common.log.enums.LogLevel; + +import java.util.List; + +/** + * Created by dd4296 on 12/24/2017. + */ +public interface ILogger { + void log(LogLevel logLevel, String message); + void log(LogLevel logLevel, String message, Object...params); + void log(LogLevel logLevel, String message, Throwable throwable); + List<String> getMandatoryFields(); + ILogger clear(); + ILogger startTimer(); + ILogger setKeyRequestId(String keyRequestId); +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandler.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandler.java new file mode 100644 index 0000000000..3e4d7d4c89 --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandler.java @@ -0,0 +1,322 @@ +package org.openecomp.sdc.common.log.elements; + +import org.apache.commons.lang3.StringUtils; +import org.openecomp.sdc.common.log.api.ILogConfiguration; +import org.openecomp.sdc.common.log.api.ILogFieldsHandler; +import org.openecomp.sdc.common.log.enums.Severity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; + +import java.net.InetAddress; +import java.time.Duration; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; + +import static java.lang.Integer.valueOf; + +public class LogFieldsMdcHandler implements ILogFieldsHandler { + + private static LogFieldsMdcHandler instanceMdcWrapper = new LogFieldsMdcHandler(); + + public static LogFieldsMdcHandler getInstance() { + return instanceMdcWrapper; + } + + private final static String dateFormatPattern = "yyyy-MM-dd HH:mm:ss.SSSz"; + private final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(dateFormatPattern); + protected static Logger log = LoggerFactory.getLogger(LogFieldsMdcHandler.class.getName()); + protected static String hostAddress; + protected static String fqdn; + + static { + try { + hostAddress = InetAddress.getLocalHost().getHostAddress(); + fqdn = InetAddress.getByName(hostAddress).getCanonicalHostName(); + } catch (Exception ex) { + log.error("failed to get machine parameters", ex); + } + } + + @Override + public void startAuditTimer() { + if (StringUtils.isEmpty(MDC.get(ILogConfiguration.MDC_AUDIT_BEGIN_TIMESTAMP))) { + MDC.put(ILogConfiguration.MDC_AUDIT_BEGIN_TIMESTAMP, generatedTimeNow()); + } + } + + @Override + public void startMetricTimer() { + if (StringUtils.isEmpty(MDC.get(ILogConfiguration.MDC_METRIC_BEGIN_TIMESTAMP))) { + MDC.put(ILogConfiguration.MDC_METRIC_BEGIN_TIMESTAMP, generatedTimeNow()); + } + } + + @Override + public void stopAuditTimer() { + //set start time if it is not set yet + startAuditTimer(); + MDC.put(ILogConfiguration.MDC_END_TIMESTAMP, generatedTimeNow()); + setElapsedTime(MDC.get(ILogConfiguration.MDC_AUDIT_BEGIN_TIMESTAMP)); + } + + @Override + public void stopMetricTimer() { + //set start time if it is not set yet + startMetricTimer(); + MDC.put(ILogConfiguration.MDC_END_TIMESTAMP, generatedTimeNow()); + setElapsedTime(MDC.get(ILogConfiguration.MDC_METRIC_BEGIN_TIMESTAMP)); + } + + @Override + public void setClassName(String className) { + MDC.put(ILogConfiguration.MDC_CLASS_NAME, className); + } + + @Override + public void setServerFQDN(String serverFQDN) { + MDC.put(ILogConfiguration.MDC_SERVER_FQDN, serverFQDN); + } + + @Override + public void setServerIPAddress(String serverIPAddress) { + MDC.put(ILogConfiguration.MDC_SERVER_IP_ADDRESS, serverIPAddress); + } + + @Override + public void setServerFQDNInternally() { + setServerFQDN(fqdn); + } + + @Override + public void setServerIPAddressInternally() { + setServerIPAddress(hostAddress); + } + + @Override + public void setInstanceUUID(String instanceUUID) { + MDC.put(ILogConfiguration.MDC_INSTANCE_UUID, instanceUUID); + } + + @Override + public void setProcessKey(String processKey) { + MDC.put(ILogConfiguration.MDC_PROCESS_KEY, processKey); + } + + @Override + public void setAlertSeverity(Severity alertSeverity) { + MDC.put(ILogConfiguration.MDC_ALERT_SEVERITY, String.valueOf(alertSeverity.getSeverityType())); + } + + @Override + public void setOptCustomField1(String customField1) { + MDC.put(ILogConfiguration.MDC_OPT_FIELD1, customField1); + } + + @Override + public void setOptCustomField2(String customField2) { + MDC.put(ILogConfiguration.MDC_OPT_FIELD2, customField2); + } + + @Override + public void setOptCustomField3(String customField3) { + MDC.put(ILogConfiguration.MDC_OPT_FIELD3, customField3); + } + + @Override + public void setOptCustomField4(String customField4) { + MDC.put(ILogConfiguration.MDC_OPT_FIELD4, customField4); + } + + @Override + public void setKeyRequestId(String keyRequestId) { + MDC.put(ILogConfiguration.MDC_KEY_REQUEST_ID, keyRequestId); // eg. servletRequest.getSession().getId() + } + + @Override + public void setRemoteHost(String remoteHost) { + MDC.put(ILogConfiguration.MDC_REMOTE_HOST, remoteHost); + } + + @Override + public void setServiceName(String serviceName) { + MDC.put(ILogConfiguration.MDC_SERVICE_NAME, serviceName); + } + + @Override + public void setStatusCode(String statusCode) { + MDC.put(ILogConfiguration.MDC_STATUS_CODE, statusCode); + } + + @Override + public void setPartnerName(String partnerName) { + MDC.put(ILogConfiguration.MDC_PARTNER_NAME, partnerName); + } + + @Override + public void setResponseCode(int responseCode) { + MDC.put(ILogConfiguration.MDC_RESPONSE_CODE, Integer.toString(responseCode)); + } + + @Override + public void setResponseDesc(String responseDesc) { + MDC.put(ILogConfiguration.MDC_RESPONSE_DESC, responseDesc); + } + + @Override + public void setServiceInstanceId(String serviceInstanceId) { + MDC.put(ILogConfiguration.MDC_SERVICE_INSTANCE_ID, serviceInstanceId); + } + + @Override + public void setTargetEntity(String targetEntity) { + MDC.put(ILogConfiguration.MDC_TARGET_ENTITY, targetEntity); + } + + @Override + public void setTargetServiceName(String targetServiceName) { + MDC.put(ILogConfiguration.MDC_TARGET_SERVICE_NAME, targetServiceName); + } + + @Override + public void setTargetVirtualEntity(String targetVirtualEntity) { + MDC.put(ILogConfiguration.MDC_TARGET_VIRTUAL_ENTITY, targetVirtualEntity); + } + + @Override + public void setErrorCode(int errorCode) { + MDC.put(ILogConfiguration.MDC_ERROR_CODE, valueOf(errorCode).toString()); + } + + @Override + public void setErrorCategory(String errorCategory) { + MDC.put(ILogConfiguration.MDC_ERROR_CATEGORY, errorCategory); + } + + @Override + public String getErrorCode() { + return MDC.get(ILogConfiguration.MDC_ERROR_CODE); + } + + @Override + public String getServiceName() { + return MDC.get(ILogConfiguration.MDC_SERVICE_NAME); + } + + @Override + public String getErrorCategory() { + return MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY); + } + + @Override + public void clear() { + MDC.clear(); + } + + @Override + public boolean isMDCParamEmpty(String mdcKeyName) { + return StringUtils.isEmpty(MDC.get(mdcKeyName)); + } + + @Override + public String getFqdn() { + return fqdn; + } + + @Override + public String getHostAddress() { + return hostAddress; + } + + @Override + public String getKeyRequestId() { + return MDC.get(ILogConfiguration.MDC_KEY_REQUEST_ID); + } + + @Override + public void removeStatusCode() { + MDC.remove(ILogConfiguration.MDC_STATUS_CODE); + } + + @Override + public void removePartnerName(){ + MDC.remove(ILogConfiguration.MDC_PARTNER_NAME); + } + + @Override + public void removeResponseCode(){ + MDC.remove(ILogConfiguration.MDC_RESPONSE_CODE); + } + + @Override + public void removeResponseDesc(){ + MDC.remove(ILogConfiguration.MDC_RESPONSE_DESC); + } + + @Override + public void removeServiceInstanceId(){ + MDC.remove(ILogConfiguration.MDC_SERVICE_INSTANCE_ID); + } + + @Override + public void removeTargetEntity(){ + MDC.remove(ILogConfiguration.MDC_TARGET_ENTITY); + } + + @Override + public void removeTargetServiceName(){ + MDC.remove(ILogConfiguration.MDC_TARGET_SERVICE_NAME); + } + + @Override + public void removeTargetVirtualEntity(){ + MDC.remove(ILogConfiguration.MDC_TARGET_VIRTUAL_ENTITY); + } + + @Override + public void removeErrorCode(){ + MDC.remove(ILogConfiguration.MDC_ERROR_CODE); + } + + @Override + public void removeErrorCategory(){ + MDC.remove(ILogConfiguration.MDC_ERROR_CATEGORY); + } + + @Override + public void removeErrorDescription(){ + MDC.remove(ILogConfiguration.MDC_ERROR_DESC); + } + + @Override + public void setAuditMessage(String message) { + MDC.put(ILogConfiguration.MDC_AUDIT_MESSAGE, message); + } + + @Override + public String getAuditMessage() { + return MDC.get(ILogConfiguration.MDC_AUDIT_MESSAGE); + } + + private void setElapsedTime(String beginTimestamp) { + try { + final LocalDateTime startTime = LocalDateTime.parse(beginTimestamp, dateTimeFormatter); + final LocalDateTime endTime = LocalDateTime.parse(MDC.get(ILogConfiguration.MDC_END_TIMESTAMP), dateTimeFormatter); + final Duration timeDifference = Duration.between(startTime, endTime); + + MDC.put(ILogConfiguration.MDC_ELAPSED_TIME, String.valueOf(timeDifference.toMillis())); + + } catch(Exception ex) { + log.error("failed to calculate elapsed time",ex); + } + } + + private String generatedTimeNow() { + return dateTimeFormatter + .withZone(ZoneOffset.UTC) + .format(Instant.now()); + } + +}
\ No newline at end of file diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerAudit.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerAudit.java new file mode 100644 index 0000000000..61ae477caf --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerAudit.java @@ -0,0 +1,166 @@ +package org.openecomp.sdc.common.log.elements; + + +import org.openecomp.sdc.common.log.api.ILogConfiguration; +import org.openecomp.sdc.common.log.api.ILogFieldsHandler; +import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode; +import org.openecomp.sdc.common.log.enums.LogMarkers; +import org.openecomp.sdc.common.log.enums.Severity; +import org.openecomp.sdc.common.log.enums.StatusCode; +import org.slf4j.Logger; +import org.slf4j.MDC; +import org.slf4j.MarkerFactory; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public class LoggerAudit extends LoggerBase { + private static ArrayList<String> mandatoryFields = new ArrayList<>(Arrays.asList( + ILogConfiguration.MDC_AUDIT_BEGIN_TIMESTAMP, + ILogConfiguration.MDC_END_TIMESTAMP, + ILogConfiguration.MDC_KEY_REQUEST_ID, + ILogConfiguration.MDC_SERVICE_NAME, + ILogConfiguration.MDC_PARTNER_NAME, + ILogConfiguration.MDC_STATUS_CODE, + ILogConfiguration.MDC_RESPONSE_CODE, + ILogConfiguration.MDC_SERVICE_INSTANCE_ID, + ILogConfiguration.MDC_RESPONSE_DESC, + ILogConfiguration.MDC_ELAPSED_TIME, + ILogConfiguration.MDC_SERVER_IP_ADDRESS, + ILogConfiguration.MDC_SERVER_FQDN)); + + private static ArrayList<String> optionalFields = new ArrayList<>(Arrays.asList( + ILogConfiguration.MDC_INSTANCE_UUID, + ILogConfiguration.MDC_ALERT_SEVERITY, + ILogConfiguration.MDC_REMOTE_HOST, + ILogConfiguration.MDC_CLASS_NAME, + ILogConfiguration.MDC_PROCESS_KEY, + ILogConfiguration.MDC_OPT_FIELD1, + ILogConfiguration.MDC_OPT_FIELD2, + ILogConfiguration.MDC_OPT_FIELD3, + ILogConfiguration.MDC_OPT_FIELD4)); + + LoggerAudit(ILogFieldsHandler ecompMdcWrapper, Logger logger) { + super (ecompMdcWrapper, MarkerFactory.getMarker(LogMarkers.AUDIT_MARKER.text()), logger); + //put the remote host and FQDN values from another thread if they are set + ecompMdcWrapper.setServerIPAddressInternally(); + ecompMdcWrapper.setServerFQDNInternally(); + } + + @Override + public LoggerAudit startTimer() { + ecompLogFieldsHandler.startAuditTimer(); + return this; + } + + public LoggerAudit stopTimer() { + ecompLogFieldsHandler.stopAuditTimer(); + return this; + } + + public LoggerAudit setInstanceUUID(String instanceUUID) { + ecompLogFieldsHandler.setInstanceUUID(instanceUUID); + return this; + } + + public LoggerAudit setOptClassName(String className) { + MDC.put("ClassName", className); + return this; + } + + public LoggerAudit setOptProcessKey(String processKey) { + ecompLogFieldsHandler.setProcessKey(processKey); + return this; + } + + public LoggerAudit setOptAlertSeverity(Severity alertSeverity) { + ecompLogFieldsHandler.setAlertSeverity(alertSeverity); + return this; + } + + // log optional parameter + public LoggerAudit setOptCustomField1(String customField1) { + ecompLogFieldsHandler.setOptCustomField1(customField1); + return this; + } + + // log optional parameter + public LoggerAudit setOptCustomField2(String customField2) { + ecompLogFieldsHandler.setOptCustomField2(customField2); + return this; + } + + // log optional parameter + public LoggerAudit setOptCustomField3(String customField3) { + ecompLogFieldsHandler.setOptCustomField3(customField3); + return this; + } + + public LoggerAudit setOptCustomField4(String customField4) { + ecompLogFieldsHandler.setOptCustomField4(customField4); + return this; + } + + @Override + public LoggerAudit setKeyRequestId(String keyRequestId) { + return (LoggerAudit) super.setKeyRequestId(keyRequestId); + } + + public LoggerAudit setRemoteHost(String remoteHost) { + ecompLogFieldsHandler.setRemoteHost(remoteHost); + return this; + } + + public LoggerAudit setServiceName(String serviceName) { + ecompLogFieldsHandler.setServiceName(serviceName); + return this; + } + + public LoggerAudit setStatusCode(String statusCode) { + // status code is either success (COMPLETE) or failure (ERROR) of the request. + String respStatus = Integer.parseInt(statusCode) / 100 == 2 ? StatusCode.COMPLETE.getStatusCodeEnum() : StatusCode.ERROR.getStatusCodeEnum(); + ecompLogFieldsHandler.setStatusCode(respStatus); + return this; + } + + public LoggerAudit setPartnerName(String partnerName) { + ecompLogFieldsHandler.setPartnerName(partnerName); + return this; + } + + public LoggerAudit setResponseCode(EcompLoggerErrorCode responseCode) { + ecompLogFieldsHandler.setResponseCode(responseCode.getErrorCode()); + return this; + } + + public LoggerAudit setResponseDesc(String responseDesc) { + ecompLogFieldsHandler.setResponseDesc(responseDesc); + return this; + } + + public LoggerAudit setOptServiceInstanceId(String serviceInstanceId) { + ecompLogFieldsHandler.setServiceInstanceId(serviceInstanceId); + return this; + } + + public String getAuditMessage() { + return ecompLogFieldsHandler.getAuditMessage(); + } + + + @Override + public List<String> getMandatoryFields() { + return Collections.unmodifiableList(mandatoryFields); + } + + @Override + public LoggerAudit clear() { + super.clear(); + ecompLogFieldsHandler.setServerFQDNInternally(); + ecompLogFieldsHandler.setServerIPAddressInternally(); + return this; + } + +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerBase.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerBase.java new file mode 100644 index 0000000000..c449f6fdaf --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerBase.java @@ -0,0 +1,145 @@ +package org.openecomp.sdc.common.log.elements; + +import com.google.common.annotations.VisibleForTesting; +import org.apache.commons.lang3.StringUtils; +import org.openecomp.sdc.common.log.api.ILogFieldsHandler; +import org.openecomp.sdc.common.log.api.ILogger; +import org.openecomp.sdc.common.log.enums.LogLevel; +import org.openecomp.sdc.common.log.enums.LogMarkers; +import org.openecomp.sdc.common.util.ThreadLocalsHolder; +import org.slf4j.Logger; +import org.slf4j.Marker; +import org.slf4j.MarkerFactory; + +import java.util.Arrays; +import java.util.List; + + +/** + * Created by mm288v on 12/27/2017. + * This class holds the common behavior of all Loger-Typed classes. + * The Concrete loggers shoudl derive from this one. + */ +public abstract class LoggerBase implements ILogger { + private final Logger myLogger; + private final Marker myMarker; + protected final ILogFieldsHandler ecompLogFieldsHandler; + private final static String missingLogFieldsMsg = "mandatory parameters for ECOMP logging, missing fields: %s, original message: %s"; + + LoggerBase(ILogFieldsHandler ecompLogFieldsHandler, Marker marker, Logger logger) { + this.ecompLogFieldsHandler = ecompLogFieldsHandler; + this.myMarker = marker; + this.myLogger = logger; + setKeyRequestIdIfNotSetYet(); + } + + protected void setKeyRequestIdIfNotSetYet() { + if (StringUtils.isEmpty(ecompLogFieldsHandler.getKeyRequestId())) { + setKeyRequestId(ThreadLocalsHolder.getUuid()); + } + } + private void validateMandatoryFields(String originMsg) { + // this method only checks if the mandatory fields have been initialized + String filedNameThatHasNotBeenInitialized = checkMandatoryFieldsExistInMDC(); + + if (myLogger.isDebugEnabled() && !"".equalsIgnoreCase(filedNameThatHasNotBeenInitialized)) { + myLogger.debug(MarkerFactory.getMarker(LogMarkers.DEBUG_MARKER.text()), + String.format(missingLogFieldsMsg, filedNameThatHasNotBeenInitialized, originMsg)); + } + } + + @VisibleForTesting + String checkMandatoryFieldsExistInMDC() { + // this method returns a String of uninitialised fields + StringBuilder missingFields = new StringBuilder(); + getMandatoryFields().forEach(field -> { + if (ecompLogFieldsHandler.isMDCParamEmpty(field)) { + missingFields.append(field).append(" "); + } + }); + return missingFields.toString(); + } + + public abstract List<String> getMandatoryFields(); + + protected String convertExceptionStackToString(Exception ex) { + StringBuilder stackTrack = new StringBuilder(); + Arrays.asList(ex.getStackTrace()).forEach(item -> stackTrack.append(item.toString()).append("\n")); + return stackTrack.toString(); + } + + @Override + public void log(LogLevel logLevel, String message) { + log(logLevel, message, (Object) null); + } + + @Override + public void log(LogLevel logLevel, String message, Object...params) { + validateMandatoryFields(message); + + switch(logLevel) { + case ERROR: + case FATAL: //TODO check how to log "FATAL" word + myLogger.error(myMarker, message, params); + break; + case WARN: + myLogger.warn(myMarker, message, params); + break; + case INFO: + myLogger.info(myMarker, message, params); + break; + case DEBUG: + myLogger.debug(myMarker, message, params); + break; + case TRACE: + myLogger.trace(myMarker, message, params); + break; + default: + break; + } + } + + @Override + public void log(LogLevel logLevel, String message, Throwable throwable) { + validateMandatoryFields(message); + + switch(logLevel) { + case ERROR: + case FATAL: //TODO check how to log "FATAL" word + myLogger.error(myMarker, createErrorMessage(message, throwable)); + break; + case WARN: + myLogger.warn(myMarker, createErrorMessage(message, throwable)); + break; + case INFO: + myLogger.info(myMarker, createErrorMessage(message, throwable)); + break; + case DEBUG: + myLogger.debug(myMarker, message, throwable); + break; + case TRACE: + myLogger.trace(myMarker, message, throwable); + break; + default: + break; + } + } + + protected String createErrorMessage(String message, Throwable throwable) { + return String.format("%s: %s", message, throwable.getLocalizedMessage()); + } + + + @Override + public ILogger clear() { + ecompLogFieldsHandler.clear(); + return this; + } + + @Override + public ILogger setKeyRequestId(String keyRequestId) { + ecompLogFieldsHandler.setKeyRequestId(keyRequestId); + return this; + } + +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerDebug.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerDebug.java new file mode 100644 index 0000000000..6ac1267ed6 --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerDebug.java @@ -0,0 +1,55 @@ +package org.openecomp.sdc.common.log.elements; + +import org.openecomp.sdc.common.log.api.ILogConfiguration; +import org.openecomp.sdc.common.log.api.ILogFieldsHandler; +import org.openecomp.sdc.common.log.enums.LogLevel; +import org.openecomp.sdc.common.log.enums.LogMarkers; +import org.slf4j.Logger; +import org.slf4j.MarkerFactory; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class LoggerDebug extends LoggerBase { + + private static ArrayList<String> mandatoryFields = new ArrayList<>(Arrays.asList(ILogConfiguration.MDC_KEY_REQUEST_ID)); + + LoggerDebug(ILogFieldsHandler ecompMdcWrapper, Logger logger) { + super(ecompMdcWrapper, MarkerFactory.getMarker(LogMarkers.DEBUG_MARKER.text()), logger); + } + + @Override + public LoggerDebug clear() { + //nothing to clean up + return this; + } + + @Override + public void log(LogLevel logLevel, String message, Object...params){ + setKeyRequestIdIfNotSetYet(); + super.log(logLevel, message, params); + } + + @Override + public void log(LogLevel logLevel, String message, Throwable throwable){ + setKeyRequestIdIfNotSetYet(); + super.log(logLevel, message, throwable); + } + + @Override + public void log(LogLevel logLevel, String message){ + setKeyRequestIdIfNotSetYet(); + super.log(logLevel, message); + } + + @Override + public LoggerDebug startTimer() { + return this; + } + + @Override + public List<String> getMandatoryFields() { + return mandatoryFields; + } +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerError.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerError.java new file mode 100644 index 0000000000..97878ec7a1 --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerError.java @@ -0,0 +1,130 @@ +package org.openecomp.sdc.common.log.elements; + +import org.apache.commons.lang3.StringUtils; +import org.openecomp.sdc.common.config.EcompErrorConfiguration; +import org.openecomp.sdc.common.log.api.ILogConfiguration; +import org.openecomp.sdc.common.log.api.ILogFieldsHandler; +import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode; +import org.openecomp.sdc.common.log.enums.LogLevel; +import org.openecomp.sdc.common.log.enums.LogMarkers; +import org.slf4j.Logger; +import org.slf4j.MarkerFactory; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public class LoggerError extends LoggerBase { + private static ArrayList<String> mandatoryFields = new ArrayList<>(Arrays.asList( + ILogConfiguration.MDC_KEY_REQUEST_ID, + ILogConfiguration.MDC_SERVICE_NAME, + ILogConfiguration.MDC_ERROR_CATEGORY, + ILogConfiguration.MDC_ERROR_CODE)); + + public static final String defaultServiceName = "SDC catalog"; + + LoggerError(ILogFieldsHandler ecompMdcWrapper, Logger logger) { + super(ecompMdcWrapper, MarkerFactory.getMarker(LogMarkers.ERROR_MARKER.text()), logger); + } + + @Override + public List<String> getMandatoryFields() { + return Collections.unmodifiableList(mandatoryFields); + } + + @Override + public LoggerError setKeyRequestId(String keyRequestId) { + return (LoggerError) super.setKeyRequestId(keyRequestId); + } + + @Override + public LoggerError startTimer() { + return this; + } + + @Override + public LoggerError clear() { + ecompLogFieldsHandler.removeErrorCategory(); + ecompLogFieldsHandler.removeErrorDescription(); + ecompLogFieldsHandler.removeErrorCode(); + return this; + } + + public void log(LogLevel logLevel, + EcompLoggerErrorCode errorCodeEnum, + String serviceName, + String targetEntity, + String message, Object...params) { + fillFieldsBeforeLogging(logLevel, errorCodeEnum, serviceName, targetEntity); + super.log(logLevel, message, params); + } + + private void fillFieldsBeforeLogging(LogLevel logLevel, EcompLoggerErrorCode errorCodeEnum, String serviceName, String targetEntity) { + clear(); + ecompLogFieldsHandler.setErrorCode(errorCodeEnum.getErrorCode()); + ecompLogFieldsHandler.setErrorCategory(logLevel.name()); + if (!StringUtils.isEmpty(targetEntity)) { + //avoid overriding this parameter in MDC + ecompLogFieldsHandler.setTargetEntity(targetEntity); + } + if (StringUtils.isEmpty(ecompLogFieldsHandler.getServiceName())) { + ecompLogFieldsHandler.setServiceName(serviceName); + } + setKeyRequestIdIfNotSetYet(); + } + + public void log(EcompErrorConfiguration.EcompErrorSeverity errorSeverity, + EcompLoggerErrorCode errorCodeEnum, + String serviceName, + String targetEntity, + String message, Object... params) { + log(convertFromSeverityErrorLevel(errorSeverity), errorCodeEnum, serviceName, targetEntity, message, params); + } + + public void log(LogLevel logLevel, + EcompLoggerErrorCode errorCodeEnum, + String serviceName, + String message, Object...params) { + log(logLevel, errorCodeEnum, serviceName, null, message, params); + } + + public void log(LogLevel logLevel, + EcompLoggerErrorCode errorCodeEnum, + String serviceName, + String message) { + log(logLevel, errorCodeEnum, serviceName, message); + } + + @Override + public void log(LogLevel logLevel, String message, Object...params) { + log(logLevel, EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, defaultServiceName, null, message, params); + } + + public void log(LogLevel logLevel, String message, Throwable throwable) { + log(logLevel, createErrorMessage(message, throwable)); + } + + public void log(LogLevel logLevel, String message) { + log(logLevel, EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, defaultServiceName, null, message); + } + + public void logInfo(LogLevel logLevel, String message, Object... params) { + log(logLevel, EcompLoggerErrorCode.SUCCESS, defaultServiceName, null, message, params); + } + + private LogLevel convertFromSeverityErrorLevel(EcompErrorConfiguration.EcompErrorSeverity severityLevel) { + switch(severityLevel) { + case INFO: + return LogLevel.INFO; + case FATAL: + return LogLevel.FATAL; + case ERROR: + return LogLevel.ERROR; + case WARN: + return LogLevel.WARN; + } + return LogLevel.ERROR; + } + +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerFactory.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerFactory.java new file mode 100644 index 0000000000..de02c067c8 --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerFactory.java @@ -0,0 +1,58 @@ +package org.openecomp.sdc.common.log.elements; + +import org.slf4j.Logger; + +/** + * Created by dd4296 on 12/26/2017. + * this factory helps decouple the classes for Stopwatch and LogFieldsMdcHandler from + * the EcompLogger classes + */ +public class LoggerFactory { + + private LoggerFactory() { + } + + @SuppressWarnings("unchecked") + public static <T, V> V getLogger(Class<T> type, Logger logger) { + + if (type.getName().equals(LoggerAudit.class.getName())) { + return (V) new LoggerAudit(new LogFieldsMdcHandler(), logger); + } + + if (type.getName().equals(LoggerDebug.class.getName())) { + return (V) new LoggerDebug(new LogFieldsMdcHandler(), logger); + } + + if (type.getName().equals(LoggerMetric.class.getName())) { + return (V) new LoggerMetric(new LogFieldsMdcHandler(), logger); + } + + if (type.getName().equals(LoggerError.class.getName())) { + return (V) new LoggerError(new LogFieldsMdcHandler(), logger); + } + + return null; + } + + @SuppressWarnings("unchecked") + public static <T, V> V getMdcLogger(Class<T> type, Logger logger) { + + if (type.getName().equals(LoggerAudit.class.getName())) { + return (V) new LoggerAudit(LogFieldsMdcHandler.getInstance(), logger); + } + + if (type.getName().equals(LoggerDebug.class.getName())) { + return (V) new LoggerDebug(LogFieldsMdcHandler.getInstance(), logger); + } + + if (type.getName().equals(LoggerMetric.class.getName())) { + return (V) new LoggerMetric(LogFieldsMdcHandler.getInstance(), logger); + } + + if (type.getName().equals(LoggerError.class.getName())) { + return (V) new LoggerError(LogFieldsMdcHandler.getInstance(), logger); + } + + return null; + } +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerMetric.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerMetric.java new file mode 100644 index 0000000000..3be3c48946 --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerMetric.java @@ -0,0 +1,211 @@ +package org.openecomp.sdc.common.log.elements; + +import org.openecomp.sdc.common.log.api.ILogFieldsHandler; +import org.openecomp.sdc.common.log.enums.LogLevel; +import org.openecomp.sdc.common.log.enums.LogMarkers; +import org.openecomp.sdc.common.log.enums.Severity; +import org.slf4j.Logger; +import org.slf4j.MarkerFactory; + +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static org.openecomp.sdc.common.log.api.ILogConfiguration.*; + + +public class LoggerMetric extends LoggerBase { + private static ArrayList<String> mandatoryFields = new ArrayList<>(Arrays.asList( + MDC_METRIC_BEGIN_TIMESTAMP, + MDC_END_TIMESTAMP, + MDC_KEY_REQUEST_ID, + MDC_SERVICE_NAME, + MDC_PARTNER_NAME, + MDC_STATUS_CODE, + MDC_RESPONSE_CODE, + MDC_SERVICE_INSTANCE_ID, + MDC_RESPONSE_DESC, + MDC_ELAPSED_TIME, + MDC_TARGET_ENTITY, + MDC_TARGET_SERVICE_NAME, + MDC_TARGET_VIRTUAL_ENTITY, + MDC_SERVER_IP_ADDRESS, + MDC_SERVER_FQDN)); + + private static ArrayList<String> optionalFields = new ArrayList<>(Arrays.asList( + MDC_INSTANCE_UUID, + MDC_ALERT_SEVERITY, + MDC_REMOTE_HOST, + MDC_CLASS_NAME, + MDC_PROCESS_KEY, + MDC_OPT_FIELD1, + MDC_OPT_FIELD2, + MDC_OPT_FIELD3, + MDC_OPT_FIELD4)); + + LoggerMetric(ILogFieldsHandler ecompMdcWrapper, Logger logger) { + super(ecompMdcWrapper, MarkerFactory.getMarker(LogMarkers.METRIC_MARKER.text()), logger); + //put the remote host and FQDN values from another thread if they are set + ecompMdcWrapper.setServerIPAddressInternally(); + ecompMdcWrapper.setServerFQDNInternally(); + } + + public void log(Response.StatusType statusInfo, + String className, + LogLevel logLevel, + Severity securityLevel, + String message) { + log(statusInfo,className, logLevel, securityLevel, message); + } + + @Override + public void log(LogLevel logLevel, String message) { + setKeyRequestIdIfNotSetYet(); + log(logLevel, message, (Object) null); + } + + @Override + public LoggerMetric startTimer() { + clear(); + ecompLogFieldsHandler.startMetricTimer(); + return this; + } + + public LoggerMetric stopTimer() { + ecompLogFieldsHandler.stopMetricTimer(); + return this; + } + + @Override + public LoggerMetric setKeyRequestId(String keyRequestId) { + return (LoggerMetric) super.setKeyRequestId(keyRequestId); + } + + @Override + public List<String> getMandatoryFields() { + return mandatoryFields; + } + + @Override + public LoggerMetric clear() { + ecompLogFieldsHandler.removeTargetEntity(); + ecompLogFieldsHandler.removeTargetServiceName(); + ecompLogFieldsHandler.removeResponseCode(); + ecompLogFieldsHandler.removeResponseDesc(); + ecompLogFieldsHandler.removeStatusCode(); + return this; + } + + // automatic parameter this is optional + public LoggerMetric setAutoServerFQDN(String serverFQDN) { + ecompLogFieldsHandler.setServerFQDN(serverFQDN); + return this; + } + + // automatic parameter this is optional + public LoggerMetric setAutoServerIPAddress(String serverIPAddress) { + ecompLogFieldsHandler.setServerIPAddress(serverIPAddress); + return this; + } + + public LoggerMetric setInstanceUUID(String instanceUUID) { + ecompLogFieldsHandler.setInstanceUUID(instanceUUID); + return this; + } + + // log optional parameter + public LoggerMetric setOptProcessKey(String processKey) { + ecompLogFieldsHandler.setProcessKey(processKey); + return this; + } + + // log optional parameter + public LoggerMetric setOptAlertSeverity(Severity alertSeverity) { + ecompLogFieldsHandler.setAlertSeverity(alertSeverity); + return this; + } + + // log optional parameter + public LoggerMetric setOptCustomField1(String customField1) { + ecompLogFieldsHandler.setOptCustomField1(customField1); + return this; + } + + // log optional parameter + public LoggerMetric setOptCustomField2(String customField2) { + ecompLogFieldsHandler.setOptCustomField2(customField2); + return this; + } + + // log optional parameter + public LoggerMetric setOptCustomField3(String customField3) { + ecompLogFieldsHandler.setOptCustomField3(customField3); + return this; + } + + // log optional parameter + public LoggerMetric setOptCustomField4(String customField4) { + ecompLogFieldsHandler.setOptCustomField4(customField4); + return this; + } + + public LoggerMetric setRemoteHost(String remoteHost) { + ecompLogFieldsHandler.setRemoteHost(remoteHost); + return this; + } + + public LoggerMetric setServiceName(String serviceName) { + ecompLogFieldsHandler.setServiceName(serviceName); + return this; + } + + public LoggerMetric setStatusCode(String statusCode) { + ecompLogFieldsHandler.setStatusCode(statusCode); + return this; + } + + public LoggerMetric setPartnerName(String partnerName) { + ecompLogFieldsHandler.setPartnerName(partnerName); + return this; + } + + public LoggerMetric setResponseCode(int responseCode) { + ecompLogFieldsHandler.setResponseCode(responseCode); + return this; + } + + public LoggerMetric setResponseDesc(String responseDesc) { + ecompLogFieldsHandler.setResponseDesc(responseDesc); + return this; + } + + public LoggerMetric setOptServiceInstanceId(String serviceInstanceId) { + ecompLogFieldsHandler.setServiceInstanceId(serviceInstanceId); + return this; + } + + public LoggerMetric setOptClassName(String className) { + ecompLogFieldsHandler.setClassName(className); + return this; + } + + public LoggerMetric setTargetEntity(String targetEntity) { + ecompLogFieldsHandler.setTargetEntity(targetEntity); + return this; + } + + public LoggerMetric setTargetServiceName(String targetServiceName) { + ecompLogFieldsHandler.setTargetServiceName(targetServiceName); + return this; + } + + public LoggerMetric setTargetVirtualEntity(String targetVirtualEntity) { + ecompLogFieldsHandler.setTargetVirtualEntity(targetVirtualEntity); + return this; + } + + + + +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/enums/EcompLoggerErrorCode.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/enums/EcompLoggerErrorCode.java new file mode 100644 index 0000000000..6f7fc1a876 --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/enums/EcompLoggerErrorCode.java @@ -0,0 +1,47 @@ +package org.openecomp.sdc.common.log.enums; + +import java.util.Arrays; +import java.util.Optional; + +/** + * Created by dd4296 on 12/26/2017. + */ +public enum EcompLoggerErrorCode { + SUCCESS(0), + PERMISSION_ERROR(100), + AVAILABILITY_TIMEOUTS_ERROR(200), + DATA_ERROR(300), + SCHEMA_ERROR(400), + BUSINESS_PROCESS_ERROR(500), + UNKNOWN_ERROR(900); + + private int errorCode; + + EcompLoggerErrorCode(int errorCode) { + this.errorCode = errorCode; + } + + public int getErrorCode() { + return errorCode; + } + + public static EcompLoggerErrorCode getByValue(String ecompErrorCode) { + String errorPrefix = parseCode(ecompErrorCode); + Optional<EcompLoggerErrorCode> optionalCode = Arrays.stream(values()).filter(v->isCode(v, errorPrefix)).findFirst(); + return optionalCode.orElse(UNKNOWN_ERROR); + } + + private static boolean isCode(EcompLoggerErrorCode ecompLoggerErrorCode, String errorPrefix) { + return String.valueOf(ecompLoggerErrorCode.getErrorCode()).contains(errorPrefix); + } + + private static String parseCode(String errorCode) { + try { + return errorCode.substring("E_".length(), 3); + } catch (StringIndexOutOfBoundsException ex) { + return UNKNOWN_ERROR.name(); + } + } + + +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Enums/LogLevel.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/enums/LogLevel.java index 2fc7d7f26f..d044f6eaea 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Enums/LogLevel.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/enums/LogLevel.java @@ -1,4 +1,4 @@ -package org.openecomp.sdc.common.ecomplog.Enums; +package org.openecomp.sdc.common.log.enums; /** * Created by dd4296 on 12/14/2017. @@ -7,6 +7,7 @@ public enum LogLevel { INFO, WARN, DEBUG, + TRACE, ERROR, FATAL } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Enums/LogMarkers.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/enums/LogMarkers.java index b26e8c105d..5623294b3d 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Enums/LogMarkers.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/enums/LogMarkers.java @@ -1,4 +1,4 @@ -package org.openecomp.sdc.common.ecomplog.Enums; +package org.openecomp.sdc.common.log.enums; /** * Created by mm288v on 12/27/2017. diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Enums/Severity.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/enums/Severity.java index f842927af2..56f35a707b 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Enums/Severity.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/enums/Severity.java @@ -1,4 +1,4 @@ -package org.openecomp.sdc.common.ecomplog.Enums; +package org.openecomp.sdc.common.log.enums; /** * Created by dd4296 on 12/14/2017. diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Enums/StatusCode.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/enums/StatusCode.java index 2fdd96f11b..f61bd67964 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Enums/StatusCode.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/enums/StatusCode.java @@ -1,4 +1,4 @@ -package org.openecomp.sdc.common.ecomplog.Enums; +package org.openecomp.sdc.common.log.enums; public enum StatusCode { ERROR("ERROR"), diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/wrappers/Logger.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/wrappers/Logger.java new file mode 100644 index 0000000000..c9fccba303 --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/wrappers/Logger.java @@ -0,0 +1,526 @@ +package org.openecomp.sdc.common.log.wrappers; + +import com.google.common.annotations.VisibleForTesting; +import org.openecomp.sdc.common.config.EcompErrorConfiguration; +import org.openecomp.sdc.common.log.elements.LoggerDebug; +import org.openecomp.sdc.common.log.elements.LoggerError; +import org.openecomp.sdc.common.log.elements.LoggerFactory; +import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode; +import org.openecomp.sdc.common.log.enums.LogLevel; +import org.slf4j.Marker; + + +/** + * This class wraps {@link org.slf4j.Logger} object and provides mandatory information required by Ecomp logging rules. + * Note: All deprecated methods are supported to be compatible to the legacy code + * and have not be used by the new code + */ +public class Logger implements org.slf4j.Logger { + private final LoggerDebug debug; + private final LoggerError error; + private final org.slf4j.Logger logger; + + @VisibleForTesting + private Logger(org.slf4j.Logger logger) { + this.logger = logger; + this.debug = LoggerFactory.getMdcLogger(LoggerDebug.class, logger); + this.error = LoggerFactory.getMdcLogger(LoggerError.class, logger); + } + + private Logger(String className) { + this(org.slf4j.LoggerFactory.getLogger(className)); + } + + public static Logger getLogger(String className) { + return new Logger(className); + } + + public static Logger getLogger(Class<?> clazz) { + return new Logger(clazz.getName()); + } + + + public boolean isDebugEnabled() { + return logger.isDebugEnabled(); + } + + @Override + public String getName() { + return logger.getName(); + } + + public boolean isTraceEnabled() { + return logger.isTraceEnabled(); + } + + public boolean isErrorEnabled() { return logger.isErrorEnabled(); } + + public boolean isWarnEnabled() { return logger.isWarnEnabled(); } + + @Override + @Deprecated /** Please use method {@link #warn(EcompLoggerErrorCode, String, String)} **/ + public void warn(String msg) { + if (isWarnEnabled()) { + error.log(LogLevel.WARN, msg); + } + } + + @Override + @Deprecated /** Please use method {@link #warn(EcompLoggerErrorCode, String, String)} **/ + public void warn(String msg, Object o) { + + if (isWarnEnabled()) { + error.log(LogLevel.WARN, msg, o); + } + } + + public boolean isInfoEnabled() { return logger.isInfoEnabled(); } + + @Override + public void info(String msg) { + if (isInfoEnabled()) { + error.logInfo(LogLevel.INFO, msg); + } + } + + @Override + public void info(String msg, Object o) { + if (isInfoEnabled()) { + error.logInfo(LogLevel.INFO, msg, o); + } + } + + @Override + public void info(String msg, Object o, Object o1) { + if (isInfoEnabled()) { + error.logInfo(LogLevel.INFO, msg, o, o1); + } + } + + public void debug(String msg, Object... params) { + if (isDebugEnabled()) { + debug.log(LogLevel.DEBUG, msg, params); + } + } + + @Override + public void debug(String msg, Throwable throwable) { + if (isDebugEnabled()) { + debug.log(LogLevel.DEBUG, msg, throwable); + } + } + + @Override + public boolean isDebugEnabled(Marker marker) { + return false; + } + + @Override + public void debug(Marker marker, String msg) { + if (isDebugEnabled()) { + debug.log(LogLevel.DEBUG, msg); + } + } + + @Override + public void debug(Marker marker, String msg, Object o) { + if (isDebugEnabled()) { + debug.log(LogLevel.DEBUG, msg, o); + } + } + + @Override + public void debug(Marker marker, String msg, Object o, Object o1) { + if (isDebugEnabled()) { + debug.log(LogLevel.DEBUG, msg, o, o1); + } + } + + @Override + public void debug(Marker marker, String msg, Object... objects) { + if (isDebugEnabled()) { + debug.log(LogLevel.DEBUG, msg, objects); + } + } + + @Override + public void debug(Marker marker, String msg, Throwable throwable) { + if (isDebugEnabled()) { + debug.log(LogLevel.DEBUG, msg, throwable); + } + } + + public void debug(String message) { + if (isDebugEnabled()) { + debug.log(LogLevel.DEBUG, message); + } + } + + @Override + public void debug(String msg, Object o) { + if (isDebugEnabled()) { + debug.log(LogLevel.DEBUG, msg, o); + } + } + + @Override + public void debug(String msg, Object o, Object o1) { + if (isDebugEnabled()) { + debug.log(LogLevel.DEBUG, msg, o, o1); + } + } + + public void trace(String message, Object... params) { + if (isTraceEnabled()) { + debug.log(LogLevel.TRACE, message, params); + } + } + + @Override + public void trace(String msg, Throwable throwable) { + if (isTraceEnabled()) { + debug.log(LogLevel.TRACE, msg, throwable); + } + } + + @Override + public boolean isTraceEnabled(Marker marker) { + return false; + } + + @Override + public void trace(Marker marker, String msg) { + if (isTraceEnabled()) { + debug.log(LogLevel.TRACE, msg); + } + } + + @Override + public void trace(Marker marker, String msg, Object o) { + if (isTraceEnabled()) { + debug.log(LogLevel.TRACE, msg, o); + } + } + + @Override + public void trace(Marker marker, String msg, Object o, Object o1) { + if (isTraceEnabled()) { + debug.log(LogLevel.TRACE, msg, o, o1); + } + } + + @Override + public void trace(Marker marker, String msg, Object... objects) { + if (isTraceEnabled()) { + debug.log(LogLevel.TRACE, msg, objects); + } + } + + @Override + public void trace(Marker marker, String msg, Throwable throwable) { + if (isTraceEnabled()) { + debug.log(LogLevel.TRACE, msg, throwable); + } + } + + public void trace(String msg) { + if (isTraceEnabled()) { + debug.log(LogLevel.TRACE, msg); + } + } + + @Override + public void trace(String msg, Object o) { + if (isTraceEnabled()) { + debug.log(LogLevel.TRACE, msg, o); + } + } + + @Override + public void trace(String msg, Object o, Object o1) { + if (isTraceEnabled()) { + debug.log(LogLevel.TRACE, msg, o, o1); + } + } + + public void info(String msg, Object... params) { + if (isInfoEnabled()) { + error.logInfo(LogLevel.INFO, msg, params); + } + } + + @Override + public void info(String msg, Throwable throwable) { + if (isInfoEnabled()) { + error.logInfo(LogLevel.INFO, msg, throwable); + } + } + + @Override + public boolean isInfoEnabled(Marker marker) { + return false; + } + + @Override + public void info(Marker marker, String msg) { + if (isInfoEnabled()) { + error.logInfo(LogLevel.INFO, msg); + } + } + + @Override + public void info(Marker marker, String msg, Object o) { + if (isInfoEnabled()) { + error.logInfo(LogLevel.INFO, msg, o); + } + } + + @Override + public void info(Marker marker, String msg, Object o, Object o1) { + if (isInfoEnabled()) { + error.logInfo(LogLevel.INFO, msg, o, o1); + } + } + + @Override + public void info(Marker marker, String msg, Object... objects) { + if (isInfoEnabled()) { + error.logInfo(LogLevel.INFO, msg, objects); + } + } + + @Override + public void info(Marker marker, String msg, Throwable throwable) { + if (isInfoEnabled()) { + error.logInfo(LogLevel.INFO, msg, throwable); + } + } + + @Deprecated /** Please use method {@link #warn(EcompLoggerErrorCode, String, String)} **/ + public void warn(String msg, Object... params){ + if (isWarnEnabled()) { + error.log(LogLevel.WARN, msg, params); + } + } + + @Override + @Deprecated /** Please use method {@link #warn(EcompLoggerErrorCode, String, String)} **/ + public void warn(String msg, Object o, Object o1) { + if (isWarnEnabled()) { + error.log(LogLevel.WARN, msg, o, o1); + } + } + + @Override + @Deprecated /** Please use method {@link #warn(EcompLoggerErrorCode, String, String)} **/ + public void warn(String msg, Throwable throwable) { + if (isWarnEnabled()) { + error.log(LogLevel.WARN, msg, throwable); + } + } + + @Override + public boolean isWarnEnabled(Marker marker) { + return false; + } + + @Override + @Deprecated /** Please use method {@link #warn(EcompLoggerErrorCode, String, String)} **/ + public void warn(Marker marker, String msg) { + if (isWarnEnabled()) { + error.log(LogLevel.WARN, msg); + } + } + + @Override + @Deprecated /** Please use method {@link #warn(EcompLoggerErrorCode, String, String)} **/ + public void warn(Marker marker, String msg, Object o) { + if (isWarnEnabled()) { + error.log(LogLevel.WARN, msg, o); + } + } + + @Override + @Deprecated /** Please use method {@link #warn(EcompLoggerErrorCode, String, String)} **/ + public void warn(Marker marker, String msg, Object o, Object o1) { + if (isWarnEnabled()) { + error.log(LogLevel.WARN, msg, o, o1); + } + } + + @Override + @Deprecated /** Please use method {@link #warn(EcompLoggerErrorCode, String, String)} **/ + public void warn(Marker marker, String msg, Object... objects) { + if (isWarnEnabled()) { + error.log(LogLevel.WARN, msg, objects); + } + } + + @Override + @Deprecated /** Please use method {@link #warn(EcompLoggerErrorCode, String, String)} **/ + public void warn(Marker marker, String msg, Throwable throwable) { + if (isWarnEnabled()) { + error.log(LogLevel.WARN, msg, throwable); + } + } + + @Deprecated /** Please use method {@link #error(EcompLoggerErrorCode, String, String)} **/ + public void error(String msg, Object... params){ + if (isErrorEnabled()) { + error.log(LogLevel.ERROR, msg, params); + } + } + + @Override + @Deprecated /** Please use method {@link #error(EcompLoggerErrorCode, String, String)} **/ + public void error(String msg, Throwable throwable) { + if (isErrorEnabled()) { + error.log(LogLevel.ERROR, msg, throwable); + } + } + + @Override + public boolean isErrorEnabled(Marker marker) { + return false; + } + + @Override + @Deprecated /** Please use method {@link #error(EcompLoggerErrorCode, String, String)} **/ + public void error(Marker marker, String msg) { + if (isErrorEnabled()) { + error.log(LogLevel.ERROR, msg); + } + } + + @Override + @Deprecated /** Please use method {@link #error(EcompLoggerErrorCode, String, String)} **/ + public void error(Marker marker, String msg, Object o) { + if (isErrorEnabled()) { + error.log(LogLevel.ERROR, msg, o); + } + } + + @Override + @Deprecated /** Please use method {@link #error(EcompLoggerErrorCode, String, String)} **/ + public void error(Marker marker, String msg, Object o, Object o1) { + if (isErrorEnabled()) { + error.log(LogLevel.ERROR, msg, o, o1); + } + } + + @Override + @Deprecated /** Please use method {@link #error(EcompLoggerErrorCode, String, String)} **/ + public void error(Marker marker, String msg, Object... params) { + if (isErrorEnabled()) { + error.log(LogLevel.ERROR, msg, params); + } + } + + @Override + @Deprecated /** Please use method {@link #error(EcompLoggerErrorCode, String, String)} **/ + public void error(Marker marker, String msg, Throwable throwable) { + if (isErrorEnabled()) { + error.log(LogLevel.ERROR, msg, throwable); + } + } + + @Deprecated /** Please use method {@link #error(EcompLoggerErrorCode, String, String)} **/ + public void error(String msg){ + if (isErrorEnabled()) { + error.log(LogLevel.ERROR, msg); + } + } + + @Override + @Deprecated /** Please use method {@link #error(EcompLoggerErrorCode, String, String)} **/ + public void error(String msg, Object o) { + if (isErrorEnabled()) { + error.log(LogLevel.ERROR, msg, o); + } + } + + @Override + @Deprecated /** Please use method {@link #error(EcompLoggerErrorCode, String, String)} **/ + public void error(String msg, Object o, Object o1) { + if (isErrorEnabled()) { + error.log(LogLevel.ERROR, msg, o, o1); + } + } + + /** + * Writes out ERROR logging level message to the application error log + * @param errorLevel code representing the error severity level + * @param serviceName name of the API invoked at the logging component + * @param targetEntity name of the ECOMP component or sub-component, or external entity at which the error occurred or null + * @param errorDescription a human readable description of the error condition + * @param params optional parameters of a given error description + */ + public void error(EcompErrorConfiguration.EcompErrorSeverity errorLevel, + EcompLoggerErrorCode errorCodeEnum, + String serviceName, + String targetEntity, + String errorDescription, Object...params) { + if (isErrorEnabled()) { + error.log(errorLevel, errorCodeEnum, serviceName, targetEntity, errorDescription, params); + } + } + + /** + * Writes out ERROR logging level message to the application error log + * @param errorCodeEnum code representing the error condition + * @param serviceName name of the API invoked at the logging component + * @param targetEntity name of the ECOMP component or sub-component, or external entity at which the error occurred or null + * @param errorDescription a human readable description of the error condition + * @param params optional parameters of a given error description + */ + public void error(EcompLoggerErrorCode errorCodeEnum, + String serviceName, + String targetEntity, + String errorDescription, Object...params) { + if (isErrorEnabled()) { + error.log(LogLevel.ERROR, errorCodeEnum, serviceName, targetEntity, errorDescription, params); + } + } + + /** + * Writes out WARN logging level message to the application error log + * @param errorCodeEnum code representing the error condition + * @param serviceName name of the API invoked at the logging component + * @param targetEntity name of the ECOMP component or sub-component, or external entity at which the error occurred or null + * @param errorDescription a human readable description of the error condition + * @param params optional parameters of a given error description + */ + public void warn(EcompLoggerErrorCode errorCodeEnum, + String serviceName, + String targetEntity, + String errorDescription, Object...params) { + if (isWarnEnabled()) { + error.log(LogLevel.WARN, errorCodeEnum, serviceName, targetEntity, errorDescription, params); + } + } + + /** + * Writes out FATAL logging level message to the application error log + * @param errorCodeEnum code representing the error condition + * @param serviceName name of the API invoked at the logging component + * @param targetEntity name of the ECOMP component or sub-component, or external entity at which the error occurred or null + * @param errorDescription a human readable description of the error condition + * @param params optional parameters of a given error description + */ + public void fatal(EcompLoggerErrorCode errorCodeEnum, + String serviceName, + String targetEntity, + String errorDescription, Object...params) { + if (isErrorEnabled()) { + error.log(LogLevel.FATAL, errorCodeEnum, serviceName, targetEntity, errorDescription, params); + } + } + + + + + + + +} + diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/wrappers/LoggerSdcAudit.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/wrappers/LoggerSdcAudit.java new file mode 100644 index 0000000000..1760701aa1 --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/wrappers/LoggerSdcAudit.java @@ -0,0 +1,86 @@ +package org.openecomp.sdc.common.log.wrappers; + +import org.apache.commons.lang3.StringUtils; +import org.openecomp.sdc.common.api.Constants; +import org.openecomp.sdc.common.log.elements.LoggerAudit; +import org.openecomp.sdc.common.log.elements.LoggerFactory; +import org.openecomp.sdc.common.log.enums.LogLevel; +import org.openecomp.sdc.common.log.enums.Severity; +import org.openecomp.sdc.common.util.ThreadLocalsHolder; +import org.slf4j.MDC; + +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.core.Response; + + +/** + * Created by dd4296 on 12/19/2017. + * + * audit log for asdc using the log library + * this is adapted for filter classes + */ +public class LoggerSdcAudit extends LoggerSdcUtilBase { + + private static String AUDIT_ON = "auditOn"; + private String className; + private final LoggerAudit ecompLoggerAudit; + + public LoggerSdcAudit(Class<?> clazz) { + this.className = clazz.getName(); + ecompLoggerAudit = LoggerFactory.getMdcLogger(LoggerAudit.class, org.slf4j.LoggerFactory.getLogger(clazz)); + } + + public void startLog(ContainerRequestContext requestContext) { + ecompLoggerAudit.clear() + .startTimer() + .setPartnerName(getPartnerName( + requestContext.getHeaderString("user-agent"), + requestContext.getHeaderString("USER_ID"), + getUrl(requestContext))) + .setServiceName(getServiceName(requestContext)) + .setKeyRequestId(ThreadLocalsHolder.getUuid()); + MDC.put(AUDIT_ON, "true"); + } + + public static boolean isFlowBeingTakenCare() { + String auditOn = MDC.get(AUDIT_ON); + return !StringUtils.isEmpty(auditOn) && "true".equals(auditOn); + } + + //this function clears the MDC data that relevant for this class + public void clearMyData(){ + ecompLoggerAudit.clear(); + } + + public void log(String remoteAddress, + ContainerRequestContext requestContext, + Response.StatusType statusInfo, + LogLevel logLevel, + Severity securityLevel, + String message) { + + try { + + String msg = ecompLoggerAudit.getAuditMessage() == null ? + message : ecompLoggerAudit.getAuditMessage(); + ecompLoggerAudit.stopTimer() + .setRemoteHost(remoteAddress) + .setResponseCode(convertHttpCodeToErrorCode(statusInfo.getStatusCode())) + .setStatusCode(Integer.toString(statusInfo.getStatusCode())) + .setResponseDesc(statusInfo.getReasonPhrase()) + .setInstanceUUID(requestContext.getHeaderString(Constants.X_ECOMP_INSTANCE_ID_HEADER)) + .setOptServiceInstanceId(requestContext.getHeaderString(Constants.X_ECOMP_SERVICE_ID_HEADER)) + .setOptClassName(className) + .setOptAlertSeverity(securityLevel) + .setOptCustomField1(requestContext.getMethod() + ": " + getUrl(requestContext)) + .setOptCustomField2(Integer.toString(statusInfo.getStatusCode())) + .log(logLevel, msg); + } + catch (Exception e) { + log.warn("Failed to write to Audit Log. Original Message: {}", message, e); + } + finally { + MDC.put(AUDIT_ON,"false"); + } + } +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcUtilBase.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/wrappers/LoggerSdcUtilBase.java index 3fe49c17e6..4a539f3c2e 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcUtilBase.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/wrappers/LoggerSdcUtilBase.java @@ -1,40 +1,25 @@ -package org.openecomp.sdc.common.ecomplogwrapper; - -import static java.net.HttpURLConnection.HTTP_BAD_METHOD; -import static java.net.HttpURLConnection.HTTP_BAD_REQUEST; -import static java.net.HttpURLConnection.HTTP_CLIENT_TIMEOUT; -import static java.net.HttpURLConnection.HTTP_CONFLICT; -import static java.net.HttpURLConnection.HTTP_ENTITY_TOO_LARGE; -import static java.net.HttpURLConnection.HTTP_FORBIDDEN; -import static java.net.HttpURLConnection.HTTP_GONE; -import static java.net.HttpURLConnection.HTTP_LENGTH_REQUIRED; -import static java.net.HttpURLConnection.HTTP_NOT_ACCEPTABLE; -import static java.net.HttpURLConnection.HTTP_NOT_FOUND; -import static java.net.HttpURLConnection.HTTP_PAYMENT_REQUIRED; -import static java.net.HttpURLConnection.HTTP_PRECON_FAILED; -import static java.net.HttpURLConnection.HTTP_PROXY_AUTH; -import static java.net.HttpURLConnection.HTTP_REQ_TOO_LONG; -import static java.net.HttpURLConnection.HTTP_UNAUTHORIZED; -import static java.net.HttpURLConnection.HTTP_UNSUPPORTED_TYPE; +package org.openecomp.sdc.common.log.wrappers; -import java.util.List; -import java.util.StringTokenizer; +import org.apache.commons.lang3.StringUtils; +import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.ws.rs.container.ContainerRequestContext; +import java.util.List; +import java.util.StringTokenizer; -import org.openecomp.sdc.common.ecomplog.Enums.EcompLoggerErrorCode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import static java.net.HttpURLConnection.*; /** * Created by dd4296 on 12/20/2017. * - * base class for metric and audit ecomplog logging + * base class for metric and audit log logging * holding the specific logic for data extraction */ -public class EcompLoggerSdcUtilBase { +public class LoggerSdcUtilBase { - protected static Logger log = LoggerFactory.getLogger(EcompLoggerSdcUtilBase.class.getName()); + protected static Logger log = LoggerFactory.getLogger(LoggerSdcUtilBase.class.getName()); String getRequestIDfromHeaders(List<Object> requestHeader) { // this method gets list of type object. @@ -44,28 +29,29 @@ public class EcompLoggerSdcUtilBase { } + // this method translates http error code to ECOMP Logger Error code // this is a naive translation and is not a result of any documented format ECOMP specification protected EcompLoggerErrorCode convertHttpCodeToErrorCode(int httpResponseCode) { - if (isSuccessError(httpResponseCode)) + if (isSuccessError(httpResponseCode)) { return EcompLoggerErrorCode.SUCCESS; + } - if (isSchemaError(httpResponseCode)) + if (isSchemaError(httpResponseCode)) { return EcompLoggerErrorCode.SCHEMA_ERROR; - - if (isDataError(httpResponseCode)) + } + if (isDataError(httpResponseCode)) { return EcompLoggerErrorCode.DATA_ERROR; - - if (isPermissionsError(httpResponseCode)) + } + if (isPermissionsError(httpResponseCode)) { return EcompLoggerErrorCode.PERMISSION_ERROR; - - if (isTimeoutOrAvailabilityError(httpResponseCode)) + } + if (isTimeoutOrAvailabilityError(httpResponseCode)) { return EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR; - - if (isBusinessProcessError(httpResponseCode)) + } + if (isBusinessProcessError(httpResponseCode)) { return EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR; - - + } return EcompLoggerErrorCode.UNKNOWN_ERROR; } @@ -78,9 +64,10 @@ public class EcompLoggerSdcUtilBase { case HTTP_CLIENT_TIMEOUT: case HTTP_GONE: return true; + default: + return false; } - return false; } private boolean isPermissionsError(int httpResponseCode) { @@ -125,18 +112,18 @@ public class EcompLoggerSdcUtilBase { protected String getPartnerName(String userAgent, String userId, String url) { - if (!isNullOrEmpty(userId)) { + if (!StringUtils.isEmpty(userId)) { return userId; } String urlUser = getUserIdFromUrl(url); - if (!isNullOrEmpty(urlUser)) + if (!StringUtils.isEmpty(urlUser)) return urlUser; String userAgentName = getUserIdFromUserAgent(userAgent); - if (!isNullOrEmpty(userAgentName)) + if (!StringUtils.isEmpty(userAgentName)) return userAgentName; return ""; @@ -187,10 +174,6 @@ public class EcompLoggerSdcUtilBase { return url; } - private boolean isNullOrEmpty(String str) { - return (str == null || str.isEmpty()); - } - protected String getServiceName(ContainerRequestContext requestContext) { return (requestContext.getUriInfo().getRequestUri().toString()) .replace(requestContext.getUriInfo().getBaseUri().toString(), "/"); diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/monitoring/MonitoringMetricsFetcher.java b/common-app-api/src/main/java/org/openecomp/sdc/common/monitoring/MonitoringMetricsFetcher.java index e5c62d4772..ea92156ce1 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/monitoring/MonitoringMetricsFetcher.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/monitoring/MonitoringMetricsFetcher.java @@ -20,6 +20,14 @@ package org.openecomp.sdc.common.monitoring; +import org.hyperic.sigar.FileSystem; +import org.hyperic.sigar.Sigar; +import org.openecomp.sdc.common.impl.ExternalConfiguration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.management.MBeanServer; +import javax.management.ObjectName; import java.lang.management.ManagementFactory; import java.lang.management.MemoryMXBean; import java.lang.management.RuntimeMXBean; @@ -27,15 +35,6 @@ import java.lang.management.ThreadMXBean; import java.util.HashMap; import java.util.Map; -import javax.management.MBeanServer; -import javax.management.ObjectName; - -import org.hyperic.sigar.FileSystem; -import org.hyperic.sigar.Sigar; -import org.openecomp.sdc.common.impl.ExternalConfiguration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - public class MonitoringMetricsFetcher { private static Logger monitoringLogger = LoggerFactory.getLogger("asdc.fe.monitoring.fetcher"); diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/validator/RequestHeadersValidator.java b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/validator/RequestHeadersValidator.java index 18ec011868..fb9fb1c037 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/validator/RequestHeadersValidator.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/validator/RequestHeadersValidator.java @@ -20,19 +20,17 @@ package org.openecomp.sdc.common.rest.impl.validator; -import java.util.List; -import java.util.Map; +import org.apache.commons.codec.binary.Base64; +import org.openecomp.sdc.common.api.Constants; +import org.openecomp.sdc.common.log.wrappers.Logger; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.MediaType; - -import org.apache.commons.codec.binary.Base64; -import org.openecomp.sdc.common.api.Constants; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import java.util.List; +import java.util.Map; public class RequestHeadersValidator { - private static Logger log = LoggerFactory.getLogger(RequestHeadersValidator.class.getName()); + private static Logger log = Logger.getLogger(RequestHeadersValidator.class.getName()); public static void validateContentType(HttpServletRequest request, MediaType expectedContentType, Map<String, String> headersMap) throws RestRequestValidationException { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/servlets/BasicServlet.java b/common-app-api/src/main/java/org/openecomp/sdc/common/servlets/BasicServlet.java index 48661a0eea..ce4f2a6e6b 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/servlets/BasicServlet.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/servlets/BasicServlet.java @@ -20,17 +20,8 @@ package org.openecomp.sdc.common.servlets; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import org.openecomp.sdc.common.api.Constants; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; - -import javax.servlet.http.HttpServletRequest; -import java.util.concurrent.TimeUnit; public abstract class BasicServlet { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/test/BaseConfDependent.java b/common-app-api/src/main/java/org/openecomp/sdc/common/test/BaseConfDependent.java index df639c70e3..49caf61bcc 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/test/BaseConfDependent.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/test/BaseConfDependent.java @@ -20,13 +20,13 @@ package org.openecomp.sdc.common.test; -import java.io.File; - import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.common.api.ConfigurationSource; import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; +import java.io.File; + public class BaseConfDependent { protected static ConfigurationManager configurationManager; protected static String componentName; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/GeneralUtility.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/GeneralUtility.java index 8890b14dd1..a6cdd90993 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/GeneralUtility.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/GeneralUtility.java @@ -20,15 +20,15 @@ package org.openecomp.sdc.common.util; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.io.FileUtils; +import org.openecomp.sdc.common.api.Constants; + import java.io.File; import java.io.IOException; import java.util.List; import java.util.regex.Pattern; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.io.FileUtils; -import org.openecomp.sdc.common.api.Constants; - public class GeneralUtility { public static boolean generateTextFile(String fileName, String fileData) { @@ -163,4 +163,5 @@ public class GeneralUtility { public static boolean isEmptyString(String str) { return str == null || str.trim().isEmpty(); } + } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/HealthCheckUtil.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/HealthCheckUtil.java index 91222a049c..7c35e4e3b7 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/HealthCheckUtil.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/HealthCheckUtil.java @@ -2,8 +2,7 @@ package org.openecomp.sdc.common.util; import org.apache.commons.collections.CollectionUtils; import org.openecomp.sdc.common.api.HealthCheckInfo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.openecomp.sdc.common.log.wrappers.Logger; import java.util.ArrayList; import java.util.Collection; @@ -13,7 +12,7 @@ import static org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckStatus.DOW public class HealthCheckUtil { - private static Logger log = LoggerFactory.getLogger(HealthCheckUtil.class.getName()); + private static Logger log = Logger.getLogger(HealthCheckUtil.class.getName()); public boolean getAggregateStatus(List<HealthCheckInfo> healthCheckInfos, Collection<String> excludes) { boolean status = true; excludes = CollectionUtils.isEmpty(excludes) ? new ArrayList<>() : excludes; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/HtmlCleaner.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/HtmlCleaner.java index 4cbd9a7760..c9086fc272 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/HtmlCleaner.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/HtmlCleaner.java @@ -20,16 +20,15 @@ package org.openecomp.sdc.common.util; +import org.apache.commons.lang3.StringEscapeUtils; + +import javax.swing.text.html.HTML; +import javax.swing.text.html.HTML.Tag; import java.util.HashSet; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.swing.text.html.HTML; -import javax.swing.text.html.HTML.Tag; - -import org.apache.commons.lang3.StringEscapeUtils; - public class HtmlCleaner { private static Set<String> htmlTags = new HashSet<>(); @@ -57,7 +56,7 @@ public class HtmlCleaner { public static String stripHtml(String input, boolean toEscape) { - if (input == null || true == input.isEmpty()) { + if (input == null || input.isEmpty()) { return input; } @@ -77,7 +76,7 @@ public class HtmlCleaner { if (groupCount > 0) { String tag = matcher.group(1); if (tag != null && htmlTags.contains(tag.toLowerCase())) { - if (false == tagsToRemove.contains(matchTag)) { + if (!tagsToRemove.contains(matchTag)) { tagsToRemove.add(matchTag); } } @@ -87,7 +86,7 @@ public class HtmlCleaner { String stripHtmlStr = removeTagsFromString(tagsToRemove, input); if (stripHtmlStr != null) { - if (true == toEscape) { + if (toEscape) { stripHtmlStr = StringEscapeUtils.escapeHtml4(stripHtmlStr); } } @@ -99,7 +98,7 @@ public class HtmlCleaner { private static String removeTagsFromString(Set<String> tagsToRemove, String input) { String stripStr = input; - if (input == null || true == tagsToRemove.isEmpty()) { + if (input == null || tagsToRemove.isEmpty()) { return input; } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/HttpUtil.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/HttpUtil.java index f4f34a9934..d9f099876a 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/HttpUtil.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/HttpUtil.java @@ -20,17 +20,15 @@ package org.openecomp.sdc.common.util; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import javax.servlet.ServletInputStream; -import javax.servlet.http.HttpServletRequest; - import com.google.gson.Gson; import com.google.gson.GsonBuilder; - import fj.data.Either; +import javax.servlet.ServletInputStream; +import javax.servlet.http.HttpServletRequest; +import java.io.ByteArrayOutputStream; +import java.io.IOException; + public class HttpUtil { public static Either<String, IOException> readJsonStringFromRequest(HttpServletRequest request) { Either<String, IOException> eitherResult; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/JsonUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/JsonUtils.java index 1f60632f1b..fbf94eaaed 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/JsonUtils.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/JsonUtils.java @@ -31,8 +31,8 @@ public class JsonUtils { return null; } - if (false == jsonElement.isJsonNull()) { - if (false == jsonElement.isJsonObject()) { + if (!jsonElement.isJsonNull()) { + if (!jsonElement.isJsonObject()) { return jsonElement.getAsString(); } else { return jsonElement.toString(); diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/PairUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/PairUtils.java index d58b9a970d..eb6c29ce4a 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/PairUtils.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/PairUtils.java @@ -20,12 +20,12 @@ package org.openecomp.sdc.common.util; -import java.util.List; -import java.util.stream.Collectors; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; +import java.util.List; +import java.util.stream.Collectors; + public class PairUtils { public static <L, R> List<L> leftSequence(List<ImmutablePair<L, R>> pairs) { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/SerializationUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/SerializationUtils.java index 4574d3ff86..cf49718600 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/SerializationUtils.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/SerializationUtils.java @@ -20,24 +20,17 @@ package org.openecomp.sdc.common.util; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInput; -import java.io.ObjectInputStream; -import java.io.ObjectOutput; -import java.io.ObjectOutputStream; - +import fj.data.Either; import org.nustaq.serialization.FSTConfiguration; import org.openecomp.sdc.be.config.BeEcompErrorManager; import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.openecomp.sdc.common.log.wrappers.Logger; -import fj.data.Either; +import java.io.*; public class SerializationUtils { - private static Logger log = LoggerFactory.getLogger(SerializationUtils.class.getName()); + private static Logger log = Logger.getLogger(SerializationUtils.class.getName()); private static FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration(); diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/StreamUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/StreamUtils.java index 90371a3403..2d07069388 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/StreamUtils.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/StreamUtils.java @@ -51,7 +51,7 @@ public final class StreamUtils { */ public static <T> Stream<T> takeWhilePlusOneNoEval(Stream<T> stream, Predicate<T> predicate) { List<T> results = new ArrayList<>(); - Consumer<T> listAdder = e -> results.add(e); + Consumer<T> listAdder = results::add; stream.map(e -> { listAdder.accept(e); return e; @@ -64,11 +64,11 @@ public final class StreamUtils { } public static <T> Stream<T> takeWhilePlusOne(Stream<T> stream, Predicate<T> predicate) { - return StreamSupport.stream(takeWhile(stream.spliterator(), new StopAfterFailPredicate<T>(predicate)), false); + return StreamSupport.stream(takeWhile(stream.spliterator(), new StopAfterFailPredicate<>(predicate)), false); } private static <T> Spliterator<T> takeWhile(Spliterator<T> splitr, Predicate<T> predicate) { - return new MySplitIterator<T>(splitr, predicate); + return new MySplitIterator<>(splitr, predicate); } public static class MySplitIterator<T> extends AbstractSpliterator<T> implements Spliterator<T> { @@ -94,18 +94,17 @@ public final class StreamUtils { } private Consumer<? super T> createConsumerWrapper(Consumer<? super T> action) { - Consumer<? super T> cons = new Consumer<T>() { - @Override - public void accept(T t) { - stillGoing = innerPred.test(t); - if (stillGoing) { - action.accept(t); - } - - } - }; - - return cons; + + return new Consumer<T>() { + @Override + public void accept(T t) { + stillGoing = innerPred.test(t); + if (stillGoing) { + action.accept(t); + } + + } + }; } } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java index 864d79eb39..1e4792f4ce 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java @@ -30,11 +30,7 @@ import org.jsoup.Jsoup; import org.jsoup.helper.StringUtil; import org.jsoup.safety.Whitelist; -import java.util.Arrays; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.regex.Pattern; public class ValidationUtils { @@ -92,8 +88,8 @@ public class ValidationUtils { public final static Pattern COLON_PATTERN = Pattern.compile("[:]+"); public final static Pattern AT_PATTERN = Pattern.compile("[@]+"); public final static Pattern AND_PATTERN = Pattern.compile(" [aA][Nn][Dd] "); - protected final static Set<String> CATEGORY_CONJUNCTIONS = new HashSet<String>( - Arrays.asList("of", "to", "for", "as", "a", "an", "the")); + public final static Set<String> CATEGORY_CONJUNCTIONS = new HashSet<>( + Arrays.asList("of", "to", "for", "as", "a", "an", "the")); public final static Pattern COST_PATTERN = Pattern.compile("^[0-9]{1,5}\\.[0-9]{1,3}$"); public final static Pattern ARTIFACT_LABEL_PATTERN = Pattern.compile("^[a-zA-Z0-9 \\-+]+$"); @@ -259,8 +255,7 @@ public class ValidationUtils { public static String removeAllTags(String htmlText) { - String stripped = TAGS_PATTERN.matcher(htmlText).replaceAll("").trim(); - return stripped; + return TAGS_PATTERN.matcher(htmlText).replaceAll("").trim(); } public static String normaliseWhitespace(String str) { @@ -281,9 +276,7 @@ public class ValidationUtils { public static boolean validateIsAscii(String input) { - boolean isAscii = CharMatcher.ASCII.matchesAllOf(input); - - return isAscii; + return CharMatcher.ASCII.matchesAllOf(input); } public static String convertHtmlTagsToEntities(String input) { @@ -384,15 +377,13 @@ public class ValidationUtils { private static String[] splitComponentName(String name) { String normalizedName = name.toLowerCase(); normalizedName = COMPONENT_NAME_DELIMETER_PATTERN.matcher(normalizedName).replaceAll(" "); - String[] split = normalizedName.split(" "); - return split; + return normalizedName.split(" "); } private static String[] splitComponentInstanceName(String name) { String normalizedName = name.toLowerCase(); normalizedName = COMPONENT_INCTANCE_NAME_DELIMETER_PATTERN.matcher(normalizedName).replaceAll(" "); - String[] split = normalizedName.split(" "); - return split; + return normalizedName.split(" "); } public static String convertToSystemName(String name) { @@ -524,13 +515,11 @@ public class ValidationUtils { private static String[] splitComponentName(Pattern pattern, String name) { String normalizedName = name.toLowerCase(); normalizedName = pattern.matcher(normalizedName).replaceAll(" "); - String[] split = normalizedName.split(" "); - return split; + return normalizedName.split(" "); } public static String removeHtmlTagsOnly(String htmlText) { - String stripped = HtmlCleaner.stripHtml(htmlText, false); - return stripped; + return HtmlCleaner.stripHtml(htmlText, false); } public static boolean validateForwardingPathNamePattern(String forwardingPathName) { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java index e8feb1b8e0..93160330fd 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java @@ -20,46 +20,37 @@ package org.openecomp.sdc.common.util; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.HashMap; -import java.util.Map; - import org.apache.commons.codec.binary.Base64; -import org.openecomp.sdc.be.config.Configuration.ApplicationL1CacheConfig; -import org.openecomp.sdc.be.config.Configuration.ApplicationL2CacheConfig; -import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig; -import org.openecomp.sdc.be.config.Configuration.BeMonitoringConfig; -import org.openecomp.sdc.be.config.Configuration.EcompPortalConfig; -import org.openecomp.sdc.be.config.Configuration.ElasticSearchConfig; +import org.openecomp.sdc.be.config.Configuration.*; import org.openecomp.sdc.be.config.Configuration.ElasticSearchConfig.IndicesTimeFrequencyEntry; -import org.openecomp.sdc.be.config.Configuration.OnboardingConfig; -import org.openecomp.sdc.be.config.Configuration.SwitchoverDetectorConfig; -import org.openecomp.sdc.be.config.Configuration.ToscaValidatorsConfig; import org.openecomp.sdc.be.config.DistributionEngineConfiguration; import org.openecomp.sdc.be.config.DistributionEngineConfiguration.ComponentArtifactTypesConfig; import org.openecomp.sdc.be.config.DistributionEngineConfiguration.CreateTopicConfig; import org.openecomp.sdc.be.config.DistributionEngineConfiguration.DistributionNotificationTopicConfig; import org.openecomp.sdc.be.config.DistributionEngineConfiguration.DistributionStatusTopicConfig; import org.openecomp.sdc.be.config.validation.DeploymentArtifactHeatConfiguration; +import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.fe.config.Configuration.FeMonitoringConfig; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.yaml.snakeyaml.TypeDescription; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.error.YAMLException; import org.yaml.snakeyaml.introspector.PropertyUtils; import org.yaml.snakeyaml.nodes.Node; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; + public class YamlToObjectConverter { - private static Logger log = LoggerFactory.getLogger(YamlToObjectConverter.class.getName()); + private static Logger log = Logger.getLogger(YamlToObjectConverter.class.getName()); - private static HashMap<String, Yaml> yamls = new HashMap<String, Yaml>(); + private static HashMap<String, Yaml> yamls = new HashMap<>(); private static Yaml defaultYaml = new Yaml(); @@ -165,7 +156,7 @@ public class YamlToObjectConverter { } public class MyYamlConstructor extends org.yaml.snakeyaml.constructor.Constructor { - private HashMap<String, Class<?>> classMap = new HashMap<String, Class<?>>(); + private HashMap<String, Class<?>> classMap = new HashMap<>(); public MyYamlConstructor(Class<? extends Object> theRoot) { super(theRoot); @@ -204,7 +195,7 @@ public class YamlToObjectConverter { try { File f = new File(fullFileName); - if (false == f.exists()) { + if (!f.exists()) { log.warn("The file " + fullFileName + " cannot be found. Ignore reading configuration."); return null; } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ZipUtil.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ZipUtil.java index f60cc16abe..cac94a5820 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ZipUtil.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ZipUtil.java @@ -20,6 +20,9 @@ package org.openecomp.sdc.common.util; +import org.apache.commons.io.output.ByteArrayOutputStream; +import org.openecomp.sdc.common.log.wrappers.Logger; + import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.file.Files; @@ -31,13 +34,9 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; -import org.apache.commons.io.output.ByteArrayOutputStream; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - public class ZipUtil { - private static Logger log = LoggerFactory.getLogger(ZipUtil.class.getName()); + private static Logger log = Logger.getLogger(ZipUtil.class.getName()); private ZipUtil() { } @@ -52,7 +51,7 @@ public class ZipUtil { public static Map<String, byte[]> readZip(ZipInputStream zis) { - Map<String, byte[]> fileNameToByteArray = new HashMap<String, byte[]>(); + Map<String, byte[]> fileNameToByteArray = new HashMap<>(); byte[] buffer = new byte[1024]; try { @@ -63,7 +62,7 @@ public class ZipUtil { String fileName = ze.getName(); - if (false == ze.isDirectory()) { + if (!ze.isDirectory()) { ByteArrayOutputStream os = new ByteArrayOutputStream(); try { @@ -129,14 +128,13 @@ public class ZipUtil { public static byte[] zipBytes(byte[] input) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try (ZipOutputStream zos = new ZipOutputStream(baos)) { - ZipEntry entry = new ZipEntry("zip"); - entry.setSize(input.length); - zos.putNextEntry(entry); - zos.write(input); - zos.closeEntry(); - zos.close(); - } + ZipOutputStream zos = new ZipOutputStream(baos); + ZipEntry entry = new ZipEntry("zip"); + entry.setSize(input.length); + zos.putNextEntry(entry); + zos.write(input); + zos.closeEntry(); + zos.close(); return baos.toByteArray(); } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/AbstractSdncException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/AbstractSdncException.java index 83e8321ea6..fada7193ed 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/exception/AbstractSdncException.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/AbstractSdncException.java @@ -20,14 +20,13 @@ package org.openecomp.sdc.exception; +import org.openecomp.sdc.common.log.wrappers.Logger; + import java.util.Arrays; import java.util.Formatter; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - public abstract class AbstractSdncException { private String messageId; @@ -36,7 +35,7 @@ public abstract class AbstractSdncException { private String[] variables; - private static Logger log = LoggerFactory.getLogger(AbstractSdncException.class.getName()); + private static Logger log = Logger.getLogger(AbstractSdncException.class.getName()); private final static Pattern ERROR_PARAM_PATTERN = Pattern.compile("%\\d"); diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/AlreadyExistException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/AlreadyExistException.java deleted file mode 100644 index 3baec2067e..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/exception/AlreadyExistException.java +++ /dev/null @@ -1,41 +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.sdc.exception; - -/** - * Exception to be thrown when trying to insert an existing an element that - * already exists. - * - * @author luc boutier - */ -public class AlreadyExistException extends TechnicalException { - private static final long serialVersionUID = -6151150122897145634L; - - /** - * Create a new {@link AlreadyExistException} with the cause. - * - * @param message - * Message. - */ - public AlreadyExistException(String message) { - super(message); - } -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/ConfigurationManager.java b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/ConfigurationManager.java index 0b19c6c910..413c8f825f 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/ConfigurationManager.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/ConfigurationManager.java @@ -20,9 +20,6 @@ package org.openecomp.sdc.fe.config; -import java.util.HashMap; -import java.util.Map; - import org.openecomp.sdc.common.api.BasicConfiguration; import org.openecomp.sdc.common.api.ConfigurationListener; import org.openecomp.sdc.common.api.ConfigurationSource; @@ -33,6 +30,9 @@ import org.openecomp.sdc.common.rest.api.RestConfigurationInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.HashMap; +import java.util.Map; + public class ConfigurationManager implements FileChangeCallback, IEcompConfigurationManager { ConfigurationSource configurationSource = null; @@ -46,7 +46,7 @@ public class ConfigurationManager implements FileChangeCallback, IEcompConfigura instance = this; } - Map<String, Object> configurations = new HashMap<String, Object>(); + Map<String, Object> configurations = new HashMap<>(); private void loadConfigurationFiles() { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/PluginsConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/PluginsConfiguration.java index fbf56216a5..55c7a11cf4 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/PluginsConfiguration.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/PluginsConfiguration.java @@ -1,11 +1,11 @@ package org.openecomp.sdc.fe.config; +import org.openecomp.sdc.common.api.BasicConfiguration; + import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.openecomp.sdc.common.api.BasicConfiguration; - public class PluginsConfiguration extends BasicConfiguration { private List<Plugin> pluginsList; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/fe/monitoring/FeMonitoringService.java b/common-app-api/src/main/java/org/openecomp/sdc/fe/monitoring/FeMonitoringService.java index 68078071f3..0bb33190f8 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/fe/monitoring/FeMonitoringService.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/fe/monitoring/FeMonitoringService.java @@ -20,13 +20,8 @@ package org.openecomp.sdc.fe.monitoring; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.TimeUnit; - -import javax.servlet.ServletContext; - +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import org.apache.http.HttpEntity; import org.apache.http.HttpStatus; import org.apache.http.entity.ContentType; @@ -43,8 +38,11 @@ import org.openecomp.sdc.fe.config.ConfigurationManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; +import javax.servlet.ServletContext; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; public class FeMonitoringService { diff --git a/common-app-api/src/test/java/org/openecomp/sdc/be/config/BeEcompErrorManagerTest.java b/common-app-api/src/test/java/org/openecomp/sdc/be/config/BeEcompErrorManagerTest.java deleted file mode 100644 index 440f7587c7..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/be/config/BeEcompErrorManagerTest.java +++ /dev/null @@ -1,733 +0,0 @@ -package org.openecomp.sdc.be.config; - -import org.junit.Test; -import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity; -import org.openecomp.sdc.common.config.IEcompConfigurationManager; - - -public class BeEcompErrorManagerTest { - - private BeEcompErrorManager createTestSubject() { - return BeEcompErrorManager.getInstance(); - } - - - @Test - public void testGetInstance() throws Exception { - BeEcompErrorManager result; - - // default test - result = BeEcompErrorManager.getInstance(); - } - - - - - @Test - public void testGetConfigurationManager() throws Exception { - BeEcompErrorManager testSubject; - IEcompConfigurationManager result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getConfigurationManager(); - } - - - @Test - public void testLogBeUebAuthenticationError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String reason = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeUebAuthenticationError(context, reason); - } - - - @Test - public void testLogBeHealthCheckRecovery() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeHealthCheckRecovery(context); - } - - - @Test - public void testLogBeHealthCheckTitanRecovery() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeHealthCheckTitanRecovery(context); - } - - - @Test - public void testLogBeHealthCheckElasticSearchRecovery() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeHealthCheckElasticSearchRecovery(context); - } - - - @Test - public void testLogBeHealthCheckUebClusterRecovery() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeHealthCheckUebClusterRecovery(context); - } - - - @Test - public void testLogFeHealthCheckRecovery() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logFeHealthCheckRecovery(context); - } - - - @Test - public void testLogBeHealthCheckError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeHealthCheckError(context); - } - - - @Test - public void testLogBeHealthCheckTitanError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeHealthCheckTitanError(context); - } - - - @Test - public void testLogBeHealthCheckElasticSearchError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeHealthCheckElasticSearchError(context); - } - - - @Test - public void testLogBeHealthCheckUebClusterError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeHealthCheckUebClusterError(context); - } - - - @Test - public void testLogFeHealthCheckError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logFeHealthCheckError(context); - } - - - @Test - public void testLogBeUebConnectionError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String reason = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeUebConnectionError(context, reason); - } - - - @Test - public void testLogBeUebUnkownHostError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String host = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeUebUnkownHostError(context, host); - } - - - @Test - public void testLogBeComponentMissingError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String componentType = ""; - String name = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeComponentMissingError(context, componentType, name); - } - - - @Test - public void testLogBeIncorrectComponentError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String componentType = ""; - String name = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeIncorrectComponentError(context, componentType, name); - } - - - @Test - public void testLogBeInvalidConfigurationError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String parameterName = ""; - String parameterValue = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeInvalidConfigurationError(context, parameterName, parameterValue); - } - - - @Test - public void testLogBeUebObjectNotFoundError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String notFoundObjectName = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeUebObjectNotFoundError(context, notFoundObjectName); - } - - - @Test - public void testLogBeDistributionEngineInvalidArtifactType() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String artifactType = ""; - String validArtifactTypes = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeDistributionEngineInvalidArtifactType(context, artifactType, validArtifactTypes); - } - - - @Test - public void testLogBeMissingConfigurationError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String parameterName = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeMissingConfigurationError(context, parameterName); - } - - - @Test - public void testLogBeConfigurationInvalidListSizeError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String parameterName = ""; - int listMinimumSize = 0; - - // default test - testSubject = createTestSubject(); - testSubject.logBeConfigurationInvalidListSizeError(context, parameterName, listMinimumSize); - } - - - @Test - public void testLogErrorConfigFileFormat() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String description = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logErrorConfigFileFormat(context, description); - } - - - @Test - public void testLogBeMissingArtifactInformationError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String missingInfo = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeMissingArtifactInformationError(context, missingInfo); - } - - - @Test - public void testLogBeArtifactMissingError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String artifactName = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeArtifactMissingError(context, artifactName); - } - - - @Test - public void testLogBeUserMissingError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String userId = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeUserMissingError(context, userId); - } - - - @Test - public void testLogBeInvalidTypeError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String type = ""; - String name = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeInvalidTypeError(context, type, name); - } - - - @Test - public void testLogBeInvalidValueError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String value = ""; - String name = ""; - String type = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeInvalidValueError(context, value, name, type); - } - - - @Test - public void testLogBeArtifactPayloadInvalid() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeArtifactPayloadInvalid(context); - } - - - @Test - public void testLogBeArtifactInformationInvalidError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeArtifactInformationInvalidError(context); - } - - - @Test - public void testLogBeDistributionMissingError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String distributionName = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeDistributionMissingError(context, distributionName); - } - - - @Test - public void testLogBeGraphObjectMissingError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String objectType = ""; - String objectName = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeGraphObjectMissingError(context, objectType, objectName); - } - - - @Test - public void testLogBeInvalidJsonInput() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeInvalidJsonInput(context); - } - - - @Test - public void testLogBeInitializationError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeInitializationError(context); - } - - - @Test - public void testLogBeFailedAddingResourceInstanceError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String resourceName = ""; - String serviceId = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeFailedAddingResourceInstanceError(context, resourceName, serviceId); - } - - - @Test - public void testLogBeUebSystemError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String operation = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeUebSystemError(context, operation); - } - - - @Test - public void testLogBeDistributionEngineSystemError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String operation = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeDistributionEngineSystemError(context, operation); - } - - - @Test - public void testLogBeFailedAddingNodeTypeError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String nodeType = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeFailedAddingNodeTypeError(context, nodeType); - } - - - @Test - public void testLogBeDaoSystemError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeDaoSystemError(context); - } - - - @Test - public void testLogBeSystemError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeSystemError(context); - } - - - @Test - public void testLogBeExecuteRollbackError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeExecuteRollbackError(context); - } - - - @Test - public void testLogBeFailedLockObjectError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String type = ""; - String id = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeFailedLockObjectError(context, type, id); - } - - - @Test - public void testLogBeFailedCreateNodeError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String nodeName = ""; - String status = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeFailedCreateNodeError(context, nodeName, status); - } - - - @Test - public void testLogBeFailedUpdateNodeError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String nodeName = ""; - String status = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeFailedUpdateNodeError(context, nodeName, status); - } - - - @Test - public void testLogBeFailedDeleteNodeError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String nodeName = ""; - String status = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeFailedDeleteNodeError(context, nodeName, status); - } - - - @Test - public void testLogBeFailedRetrieveNodeError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String nodeName = ""; - String status = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeFailedRetrieveNodeError(context, nodeName, status); - } - - - @Test - public void testLogBeFailedFindParentError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String node = ""; - String status = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeFailedFindParentError(context, node, status); - } - - - @Test - public void testLogBeFailedFindAllNodesError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String nodeType = ""; - String parentNode = ""; - String status = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeFailedFindAllNodesError(context, nodeType, parentNode, status); - } - - - @Test - public void testLogBeFailedFindAssociationError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String nodeType = ""; - String fromNode = ""; - String status = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeFailedFindAssociationError(context, nodeType, fromNode, status); - } - - - @Test - public void testLogBeComponentCleanerSystemError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String operation = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeComponentCleanerSystemError(context, operation); - } - - - @Test - public void testLogBeRestApiGeneralError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logBeRestApiGeneralError(context); - } - - - @Test - public void testLogFqdnResolveError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String description = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logFqdnResolveError(context, description); - } - - - @Test - public void testLogSiteSwitchoverInfo() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String description = ""; - - // default test - testSubject = createTestSubject(); - testSubject.logSiteSwitchoverInfo(context, description); - } - - - @Test - public void testLogInternalAuthenticationError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String description = ""; - ErrorSeverity severity = null; - - // test 1 - testSubject = createTestSubject(); - severity = null; - testSubject.logInternalAuthenticationError(context, description, severity); - } - - - @Test - public void testLogInternalConnectionError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String description = ""; - ErrorSeverity severity = null; - - // test 1 - testSubject = createTestSubject(); - severity = null; - testSubject.logInternalConnectionError(context, description, severity); - } - - - @Test - public void testLogInternalDataError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String description = ""; - ErrorSeverity severity = null; - - // test 1 - testSubject = createTestSubject(); - severity = null; - testSubject.logInternalDataError(context, description, severity); - } - - - @Test - public void testLogInvalidInputError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String description = ""; - ErrorSeverity severity = null; - - // test 1 - testSubject = createTestSubject(); - severity = null; - testSubject.logInvalidInputError(context, description, severity); - } - - - @Test - public void testLogInternalFlowError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String description = ""; - ErrorSeverity severity = null; - - // test 1 - testSubject = createTestSubject(); - severity = null; - testSubject.logInternalFlowError(context, description, severity); - } - - - @Test - public void testLogInternalUnexpectedError() throws Exception { - BeEcompErrorManager testSubject; - String context = ""; - String description = ""; - ErrorSeverity severity = null; - - // test 1 - testSubject = createTestSubject(); - severity = null; - testSubject.logInternalUnexpectedError(context, description, severity); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/be/config/CleanComponentsConfigurationTest.java b/common-app-api/src/test/java/org/openecomp/sdc/be/config/CleanComponentsConfigurationTest.java deleted file mode 100644 index f7124d3eb4..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/be/config/CleanComponentsConfigurationTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.openecomp.sdc.be.config; - -import java.util.List; - -import org.junit.Test; - - -public class CleanComponentsConfigurationTest { - - private CleanComponentsConfiguration createTestSubject() { - return new CleanComponentsConfiguration(); - } - - - @Test - public void testGetCleanIntervalInMinutes() throws Exception { - CleanComponentsConfiguration testSubject; - long result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCleanIntervalInMinutes(); - } - - - - - - @Test - public void testGetComponentsToClean() throws Exception { - CleanComponentsConfiguration testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getComponentsToClean(); - } - - - @Test - public void testSetComponentsToClean() throws Exception { - CleanComponentsConfiguration testSubject; - List<String> componentsToClean = null; - - // default test - testSubject = createTestSubject(); - testSubject.setComponentsToClean(componentsToClean); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/be/config/ConfigurationTest.java b/common-app-api/src/test/java/org/openecomp/sdc/be/config/ConfigurationTest.java deleted file mode 100644 index 0604e80ffc..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/be/config/ConfigurationTest.java +++ /dev/null @@ -1,1453 +0,0 @@ -package org.openecomp.sdc.be.config; - -import java.util.Date; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.junit.Test; -import org.openecomp.sdc.be.config.Configuration.ApplicationL1CacheConfig; -import org.openecomp.sdc.be.config.Configuration.ApplicationL2CacheConfig; -import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig; -import org.openecomp.sdc.be.config.Configuration.BeMonitoringConfig; -import org.openecomp.sdc.be.config.Configuration.CassandrConfig; -import org.openecomp.sdc.be.config.Configuration.EcompPortalConfig; -import org.openecomp.sdc.be.config.Configuration.ElasticSearchConfig; -import org.openecomp.sdc.be.config.Configuration.OnboardingConfig; -import org.openecomp.sdc.be.config.Configuration.SwitchoverDetectorConfig; -import org.openecomp.sdc.be.config.Configuration.ToscaValidatorsConfig; -import org.openecomp.sdc.be.config.Configuration.VfModuleProperty; - - -public class ConfigurationTest { - - private Configuration createTestSubject() { - return new Configuration(); - } - - - @Test - public void testGetGenericAssetNodeTypes() throws Exception { - Configuration testSubject; - Map<String, String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getGenericAssetNodeTypes(); - } - - - @Test - public void testSetGenericAssetNodeTypes() throws Exception { - Configuration testSubject; - Map<String, String> genericAssetNodeTypes = null; - - // default test - testSubject = createTestSubject(); - testSubject.setGenericAssetNodeTypes(genericAssetNodeTypes); - } - - - @Test - public void testGetSwitchoverDetector() throws Exception { - Configuration testSubject; - SwitchoverDetectorConfig result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getSwitchoverDetector(); - } - - - @Test - public void testSetSwitchoverDetector() throws Exception { - Configuration testSubject; - SwitchoverDetectorConfig switchoverDetector = null; - - // default test - testSubject = createTestSubject(); - testSubject.setSwitchoverDetector(switchoverDetector); - } - - - @Test - public void testGetApplicationL1Cache() throws Exception { - Configuration testSubject; - ApplicationL1CacheConfig result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getApplicationL1Cache(); - } - - - @Test - public void testSetApplicationL1Cache() throws Exception { - Configuration testSubject; - ApplicationL1CacheConfig applicationL1Cache = null; - - // default test - testSubject = createTestSubject(); - testSubject.setApplicationL1Cache(applicationL1Cache); - } - - - @Test - public void testGetApplicationL2Cache() throws Exception { - Configuration testSubject; - ApplicationL2CacheConfig result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getApplicationL2Cache(); - } - - - @Test - public void testSetApplicationL2Cache() throws Exception { - Configuration testSubject; - ApplicationL2CacheConfig applicationL2Cache = null; - - // default test - testSubject = createTestSubject(); - testSubject.setApplicationL2Cache(applicationL2Cache); - } - - - @Test - public void testGetCassandraConfig() throws Exception { - Configuration testSubject; - CassandrConfig result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCassandraConfig(); - } - - - @Test - public void testSetCassandraConfig() throws Exception { - Configuration testSubject; - CassandrConfig cassandraKeySpace = null; - - // default test - testSubject = createTestSubject(); - testSubject.setCassandraConfig(cassandraKeySpace); - } - - - @Test - public void testGetIdentificationHeaderFields() throws Exception { - Configuration testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getIdentificationHeaderFields(); - } - - - @Test - public void testSetIdentificationHeaderFields() throws Exception { - Configuration testSubject; - List<String> identificationHeaderFields = null; - - // default test - testSubject = createTestSubject(); - testSubject.setIdentificationHeaderFields(identificationHeaderFields); - } - - - @Test - public void testGetReleased() throws Exception { - Configuration testSubject; - Date result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getReleased(); - } - - - @Test - public void testGetVersion() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getVersion(); - } - - - @Test - public void testSetReleased() throws Exception { - Configuration testSubject; - Date released = null; - - // default test - testSubject = createTestSubject(); - testSubject.setReleased(released); - } - - - @Test - public void testSetVersion() throws Exception { - Configuration testSubject; - String version = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setVersion(version); - } - - - @Test - public void testGetProtocols() throws Exception { - Configuration testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getProtocols(); - } - - - @Test - public void testSetProtocols() throws Exception { - Configuration testSubject; - List<String> protocols = null; - - // default test - testSubject = createTestSubject(); - testSubject.setProtocols(protocols); - } - - - @Test - public void testGetUsers() throws Exception { - Configuration testSubject; - Map<String, String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getUsers(); - } - - - @Test - public void testSetUsers() throws Exception { - Configuration testSubject; - Map<String, String> users = null; - - // default test - testSubject = createTestSubject(); - testSubject.setUsers(users); - } - - - @Test - public void testGetBeFqdn() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getBeFqdn(); - } - - - @Test - public void testSetBeFqdn() throws Exception { - Configuration testSubject; - String beHost = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setBeFqdn(beHost); - } - - - @Test - public void testGetBeHttpPort() throws Exception { - Configuration testSubject; - Integer result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getBeHttpPort(); - } - - - @Test - public void testSetBeHttpPort() throws Exception { - Configuration testSubject; - Integer beHttpPort = 0; - - // default test - testSubject = createTestSubject(); - testSubject.setBeHttpPort(beHttpPort); - } - - - @Test - public void testGetBeSslPort() throws Exception { - Configuration testSubject; - Integer result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getBeSslPort(); - } - - - @Test - public void testSetBeSslPort() throws Exception { - Configuration testSubject; - Integer beSslPort = 0; - - // default test - testSubject = createTestSubject(); - testSubject.setBeSslPort(beSslPort); - } - - - @Test - public void testGetBeContext() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getBeContext(); - } - - - @Test - public void testSetBeContext() throws Exception { - Configuration testSubject; - String beContext = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setBeContext(beContext); - } - - - @Test - public void testGetBeProtocol() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getBeProtocol(); - } - - - @Test - public void testSetBeProtocol() throws Exception { - Configuration testSubject; - String beProtocol = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setBeProtocol(beProtocol); - } - - - @Test - public void testGetNeo4j() throws Exception { - Configuration testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getNeo4j(); - } - - - @Test - public void testSetNeo4j() throws Exception { - Configuration testSubject; - Map<String, Object> neo4j = null; - - // default test - testSubject = createTestSubject(); - testSubject.setNeo4j(neo4j); - } - - - @Test - public void testGetElasticSearch() throws Exception { - Configuration testSubject; - ElasticSearchConfig result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getElasticSearch(); - } - - - @Test - public void testSetElasticSearch() throws Exception { - Configuration testSubject; - ElasticSearchConfig elasticSearch = null; - - // default test - testSubject = createTestSubject(); - testSubject.setElasticSearch(elasticSearch); - } - - - @Test - public void testGetTitanCfgFile() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getTitanCfgFile(); - } - - - @Test - public void testSetTitanCfgFile() throws Exception { - Configuration testSubject; - String titanCfgFile = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setTitanCfgFile(titanCfgFile); - } - - - @Test - public void testGetTitanMigrationKeySpaceCfgFile() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getTitanMigrationKeySpaceCfgFile(); - } - - - @Test - public void testSetTitanMigrationKeySpaceCfgFile() throws Exception { - Configuration testSubject; - String titanMigrationKeySpaceCfgFile = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setTitanMigrationKeySpaceCfgFile(titanMigrationKeySpaceCfgFile); - } - - - @Test - public void testGetTitanInMemoryGraph() throws Exception { - Configuration testSubject; - Boolean result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getTitanInMemoryGraph(); - } - - - @Test - public void testSetTitanInMemoryGraph() throws Exception { - Configuration testSubject; - Boolean titanInMemoryGraph = null; - - // default test - testSubject = createTestSubject(); - testSubject.setTitanInMemoryGraph(titanInMemoryGraph); - } - - - @Test - public void testGetStartMigrationFrom() throws Exception { - Configuration testSubject; - int result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getStartMigrationFrom(); - } - - - @Test - public void testSetStartMigrationFrom() throws Exception { - Configuration testSubject; - int startMigrationFrom = 0; - - // default test - testSubject = createTestSubject(); - testSubject.setStartMigrationFrom(startMigrationFrom); - } - - - @Test - public void testGetTitanLockTimeout() throws Exception { - Configuration testSubject; - Long result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getTitanLockTimeout(); - } - - - @Test - public void testSetTitanLockTimeout() throws Exception { - Configuration testSubject; - Long titanLockTimeout = null; - - // default test - testSubject = createTestSubject(); - testSubject.setTitanLockTimeout(titanLockTimeout); - } - - - @Test - public void testGetTitanHealthCheckReadTimeout() throws Exception { - Configuration testSubject; - Long result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getTitanHealthCheckReadTimeout(); - } - - - - - @Test - public void testSetTitanHealthCheckReadTimeout() throws Exception { - Configuration testSubject; - Long titanHealthCheckReadTimeout = null; - - // default test - testSubject = createTestSubject(); - testSubject.setTitanHealthCheckReadTimeout(titanHealthCheckReadTimeout); - } - - - @Test - public void testGetTitanReconnectIntervalInSeconds() throws Exception { - Configuration testSubject; - Long result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getTitanReconnectIntervalInSeconds(); - } - - - - - @Test - public void testSetTitanReconnectIntervalInSeconds() throws Exception { - Configuration testSubject; - Long titanReconnectIntervalInSeconds = null; - - // default test - testSubject = createTestSubject(); - testSubject.setTitanReconnectIntervalInSeconds(titanReconnectIntervalInSeconds); - } - - - @Test - public void testGetEsReconnectIntervalInSeconds() throws Exception { - Configuration testSubject; - Long result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getEsReconnectIntervalInSeconds(); - } - - - - - @Test - public void testSetEsReconnectIntervalInSeconds() throws Exception { - Configuration testSubject; - Long esReconnectIntervalInSeconds = null; - - // default test - testSubject = createTestSubject(); - testSubject.setEsReconnectIntervalInSeconds(esReconnectIntervalInSeconds); - } - - - @Test - public void testGetArtifactTypes() throws Exception { - Configuration testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getArtifactTypes(); - } - - - @Test - public void testSetArtifactTypes() throws Exception { - Configuration testSubject; - List<String> artifactTypes = null; - - // default test - testSubject = createTestSubject(); - testSubject.setArtifactTypes(artifactTypes); - } - - - @Test - public void testGetExcludeResourceCategory() throws Exception { - Configuration testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getExcludeResourceCategory(); - } - - - @Test - public void testSetExcludeResourceCategory() throws Exception { - Configuration testSubject; - List<String> excludeResourceCategory = null; - - // default test - testSubject = createTestSubject(); - testSubject.setExcludeResourceCategory(excludeResourceCategory); - } - - - @Test - public void testGetExcludeResourceType() throws Exception { - Configuration testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getExcludeResourceType(); - } - - - @Test - public void testSetExcludeResourceType() throws Exception { - Configuration testSubject; - List<String> excludeResourceType = null; - - // default test - testSubject = createTestSubject(); - testSubject.setExcludeResourceType(excludeResourceType); - } - - - @Test - public void testGetToscaArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getToscaArtifacts(); - } - - - @Test - public void testSetToscaArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> toscaArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setToscaArtifacts(toscaArtifacts); - } - - - @Test - public void testGetInformationalResourceArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInformationalResourceArtifacts(); - } - - - @Test - public void testSetInformationalResourceArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> informationalResourceArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInformationalResourceArtifacts(informationalResourceArtifacts); - } - - - @Test - public void testGetInformationalServiceArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInformationalServiceArtifacts(); - } - - - @Test - public void testSetInformationalServiceArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> informationalServiceArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInformationalServiceArtifacts(informationalServiceArtifacts); - } - - - @Test - public void testGetServiceApiArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getServiceApiArtifacts(); - } - - - @Test - public void testSetServiceApiArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> serviceApiArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setServiceApiArtifacts(serviceApiArtifacts); - } - - - @Test - public void testGetServiceDeploymentArtifacts() throws Exception { - Configuration testSubject; - Map<String, ArtifactTypeConfig> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getServiceDeploymentArtifacts(); - } - - - @Test - public void testSetServiceDeploymentArtifacts() throws Exception { - Configuration testSubject; - Map<String, ArtifactTypeConfig> serviceDeploymentArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setServiceDeploymentArtifacts(serviceDeploymentArtifacts); - } - - - @Test - public void testGetResourceDeploymentArtifacts() throws Exception { - Configuration testSubject; - Map<String, ArtifactTypeConfig> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResourceDeploymentArtifacts(); - } - - - @Test - public void testSetResourceDeploymentArtifacts() throws Exception { - Configuration testSubject; - Map<String, ArtifactTypeConfig> resourceDeploymentArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setResourceDeploymentArtifacts(resourceDeploymentArtifacts); - } - - - @Test - public void testSetResourceInstanceDeploymentArtifacts() throws Exception { - Configuration testSubject; - Map<String, ArtifactTypeConfig> resourceInstanceDeploymentArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setResourceInstanceDeploymentArtifacts(resourceInstanceDeploymentArtifacts); - } - - - @Test - public void testGetResourceInstanceDeploymentArtifacts() throws Exception { - Configuration testSubject; - Map<String, ArtifactTypeConfig> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResourceInstanceDeploymentArtifacts(); - } - - - @Test - public void testGetExcludeServiceCategory() throws Exception { - Configuration testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getExcludeServiceCategory(); - } - - - @Test - public void testSetExcludeServiceCategory() throws Exception { - Configuration testSubject; - List<String> excludeServiceCategory = null; - - // default test - testSubject = createTestSubject(); - testSubject.setExcludeServiceCategory(excludeServiceCategory); - } - - - @Test - public void testGetLicenseTypes() throws Exception { - Configuration testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getLicenseTypes(); - } - - - @Test - public void testSetLicenseTypes() throws Exception { - Configuration testSubject; - List<String> licenseTypes = null; - - // default test - testSubject = createTestSubject(); - testSubject.setLicenseTypes(licenseTypes); - } - - - @Test - public void testGetAdditionalInformationMaxNumberOfKeys() throws Exception { - Configuration testSubject; - Integer result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getAdditionalInformationMaxNumberOfKeys(); - } - - - @Test - public void testSetAdditionalInformationMaxNumberOfKeys() throws Exception { - Configuration testSubject; - Integer additionalInformationMaxNumberOfKeys = 0; - - // default test - testSubject = createTestSubject(); - testSubject.setAdditionalInformationMaxNumberOfKeys(additionalInformationMaxNumberOfKeys); - } - - - @Test - public void testGetSystemMonitoring() throws Exception { - Configuration testSubject; - BeMonitoringConfig result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getSystemMonitoring(); - } - - - @Test - public void testSetSystemMonitoring() throws Exception { - Configuration testSubject; - BeMonitoringConfig systemMonitoring = null; - - // default test - testSubject = createTestSubject(); - testSubject.setSystemMonitoring(systemMonitoring); - } - - - @Test - public void testGetDefaultHeatArtifactTimeoutMinutes() throws Exception { - Configuration testSubject; - Integer result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDefaultHeatArtifactTimeoutMinutes(); - } - - - @Test - public void testSetDefaultHeatArtifactTimeoutMinutes() throws Exception { - Configuration testSubject; - Integer defaultHeatArtifactTimeoutMinutes = 0; - - // default test - testSubject = createTestSubject(); - testSubject.setDefaultHeatArtifactTimeoutMinutes(defaultHeatArtifactTimeoutMinutes); - } - - - @Test - public void testGetUebHealthCheckReconnectIntervalInSeconds() throws Exception { - Configuration testSubject; - Long result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getUebHealthCheckReconnectIntervalInSeconds(); - } - - - @Test - public void testSetUebHealthCheckReconnectIntervalInSeconds() throws Exception { - Configuration testSubject; - Long uebHealthCheckReconnectIntervalInSeconds = null; - - // default test - testSubject = createTestSubject(); - testSubject.setUebHealthCheckReconnectIntervalInSeconds(uebHealthCheckReconnectIntervalInSeconds); - } - - - @Test - public void testGetUebHealthCheckReadTimeout() throws Exception { - Configuration testSubject; - Long result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getUebHealthCheckReadTimeout(); - } - - - @Test - public void testSetUebHealthCheckReadTimeout() throws Exception { - Configuration testSubject; - Long uebHealthCheckReadTimeout = null; - - // default test - testSubject = createTestSubject(); - testSubject.setUebHealthCheckReadTimeout(uebHealthCheckReadTimeout); - } - - - @Test - public void testGetCleanComponentsConfiguration() throws Exception { - Configuration testSubject; - CleanComponentsConfiguration result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCleanComponentsConfiguration(); - } - - - @Test - public void testSetCleanComponentsConfiguration() throws Exception { - Configuration testSubject; - CleanComponentsConfiguration cleanComponentsConfiguration = null; - - // default test - testSubject = createTestSubject(); - testSubject.setCleanComponentsConfiguration(cleanComponentsConfiguration); - } - - - @Test - public void testToString() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.toString(); - } - - - @Test - public void testGetUnLoggedUrls() throws Exception { - Configuration testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getUnLoggedUrls(); - } - - - @Test - public void testSetUnLoggedUrls() throws Exception { - Configuration testSubject; - List<String> unLoggedUrls = null; - - // default test - testSubject = createTestSubject(); - testSubject.setUnLoggedUrls(unLoggedUrls); - } - - - @Test - public void testGetDeploymentResourceArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDeploymentResourceArtifacts(); - } - - - @Test - public void testSetDeploymentResourceArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> deploymentResourceArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setDeploymentResourceArtifacts(deploymentResourceArtifacts); - } - - - @Test - public void testGetHeatEnvArtifactHeader() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getHeatEnvArtifactHeader(); - } - - - @Test - public void testSetHeatEnvArtifactHeader() throws Exception { - Configuration testSubject; - String heatEnvArtifactHeader = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setHeatEnvArtifactHeader(heatEnvArtifactHeader); - } - - - @Test - public void testGetHeatEnvArtifactFooter() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getHeatEnvArtifactFooter(); - } - - - @Test - public void testSetHeatEnvArtifactFooter() throws Exception { - Configuration testSubject; - String heatEnvArtifactFooter = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setHeatEnvArtifactFooter(heatEnvArtifactFooter); - } - - - @Test - public void testGetDeploymentResourceInstanceArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDeploymentResourceInstanceArtifacts(); - } - - - @Test - public void testSetDeploymentResourceInstanceArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> deploymentResourceInstanceArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setDeploymentResourceInstanceArtifacts(deploymentResourceInstanceArtifacts); - } - - - @Test - public void testGetArtifactsIndex() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getArtifactsIndex(); - } - - - @Test - public void testSetArtifactsIndex() throws Exception { - Configuration testSubject; - String artifactsIndex = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setArtifactsIndex(artifactsIndex); - } - - - @Test - public void testGetResourceInformationalDeployedArtifacts() throws Exception { - Configuration testSubject; - Map<String, ArtifactTypeConfig> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResourceInformationalDeployedArtifacts(); - } - - - @Test - public void testSetResourceInformationalDeployedArtifacts() throws Exception { - Configuration testSubject; - Map<String, ArtifactTypeConfig> resourceInformationalDeployedArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setResourceInformationalDeployedArtifacts(resourceInformationalDeployedArtifacts); - } - - - @Test - public void testGetResourceTypes() throws Exception { - Configuration testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResourceTypes(); - } - - - @Test - public void testSetResourceTypes() throws Exception { - Configuration testSubject; - List<String> resourceTypes = null; - - // default test - testSubject = createTestSubject(); - testSubject.setResourceTypes(resourceTypes); - } - - - @Test - public void testGetToscaFilesDir() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getToscaFilesDir(); - } - - - @Test - public void testSetToscaFilesDir() throws Exception { - Configuration testSubject; - String toscaFilesDir = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setToscaFilesDir(toscaFilesDir); - } - - - @Test - public void testGetHeatTranslatorPath() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getHeatTranslatorPath(); - } - - - @Test - public void testSetHeatTranslatorPath() throws Exception { - Configuration testSubject; - String heatTranslatorPath = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setHeatTranslatorPath(heatTranslatorPath); - } - - - @Test - public void testGetRequirementsToFulfillBeforeCert() throws Exception { - Configuration testSubject; - Map<String, Set<String>> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRequirementsToFulfillBeforeCert(); - } - - - @Test - public void testSetRequirementsToFulfillBeforeCert() throws Exception { - Configuration testSubject; - Map<String, Set<String>> requirementsToFulfillBeforeCert = null; - - // default test - testSubject = createTestSubject(); - testSubject.setRequirementsToFulfillBeforeCert(requirementsToFulfillBeforeCert); - } - - - @Test - public void testGetCapabilitiesToConsumeBeforeCert() throws Exception { - Configuration testSubject; - Map<String, Set<String>> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCapabilitiesToConsumeBeforeCert(); - } - - - @Test - public void testSetCapabilitiesToConsumeBeforeCert() throws Exception { - Configuration testSubject; - Map<String, Set<String>> capabilitiesToConsumeBeforeCert = null; - - // default test - testSubject = createTestSubject(); - testSubject.setCapabilitiesToConsumeBeforeCert(capabilitiesToConsumeBeforeCert); - } - - - @Test - public void testGetOnboarding() throws Exception { - Configuration testSubject; - OnboardingConfig result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getOnboarding(); - } - - - @Test - public void testSetOnboarding() throws Exception { - Configuration testSubject; - OnboardingConfig onboarding = null; - - // default test - testSubject = createTestSubject(); - testSubject.setOnboarding(onboarding); - } - - - @Test - public void testGetEcompPortal() throws Exception { - Configuration testSubject; - EcompPortalConfig result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getEcompPortal(); - } - - - @Test - public void testSetEcompPortal() throws Exception { - Configuration testSubject; - EcompPortalConfig ecompPortal = null; - - // default test - testSubject = createTestSubject(); - testSubject.setEcompPortal(ecompPortal); - } - - - @Test - public void testGetToscaValidators() throws Exception { - Configuration testSubject; - ToscaValidatorsConfig result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getToscaValidators(); - } - - - @Test - public void testSetToscaValidators() throws Exception { - Configuration testSubject; - ToscaValidatorsConfig toscaValidators = null; - - // default test - testSubject = createTestSubject(); - testSubject.setToscaValidators(toscaValidators); - } - - - @Test - public void testIsDisableAudit() throws Exception { - Configuration testSubject; - boolean result; - - // default test - testSubject = createTestSubject(); - result = testSubject.isDisableAudit(); - } - - - @Test - public void testSetDisableAudit() throws Exception { - Configuration testSubject; - boolean enableAudit = false; - - // default test - testSubject = createTestSubject(); - testSubject.setDisableAudit(enableAudit); - } - - - @Test - public void testGetResourceInformationalArtifacts() throws Exception { - Configuration testSubject; - Map<String, ArtifactTypeConfig> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResourceInformationalArtifacts(); - } - - - @Test - public void testSetResourceInformationalArtifacts() throws Exception { - Configuration testSubject; - Map<String, ArtifactTypeConfig> resourceInformationalArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setResourceInformationalArtifacts(resourceInformationalArtifacts); - } - - - @Test - public void testGetVfModuleProperties() throws Exception { - Configuration testSubject; - Map<String, VfModuleProperty> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getVfModuleProperties(); - } - - - @Test - public void testSetVfModuleProperties() throws Exception { - Configuration testSubject; - Map<String, VfModuleProperty> vfModuleProperties = null; - - // default test - testSubject = createTestSubject(); - testSubject.setVfModuleProperties(vfModuleProperties); - } - - - @Test - public void testGetToscaConformanceLevel() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getToscaConformanceLevel(); - } - - - @Test - public void testSetToscaConformanceLevel() throws Exception { - Configuration testSubject; - String toscaConformanceLevel = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setToscaConformanceLevel(toscaConformanceLevel); - } - - - @Test - public void testGetMinToscaConformanceLevel() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getMinToscaConformanceLevel(); - } - - - @Test - public void testSetMinToscaConformanceLevel() throws Exception { - Configuration testSubject; - String toscaConformanceLevel = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setMinToscaConformanceLevel(toscaConformanceLevel); - } - - - @Test - public void testGetDefaultImports() throws Exception { - Configuration testSubject; - List<Map<String, Map<String, String>>> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDefaultImports(); - } - - - @Test - public void testSetDefaultImports() throws Exception { - Configuration testSubject; - LinkedList<Map<String, Map<String, String>>> defaultImports = null; - - // default test - testSubject = createTestSubject(); - testSubject.setDefaultImports(defaultImports); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/be/config/DistributionEngineConfigurationTest.java b/common-app-api/src/test/java/org/openecomp/sdc/be/config/DistributionEngineConfigurationTest.java index cceedef12c..1f777a73db 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/be/config/DistributionEngineConfigurationTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/be/config/DistributionEngineConfigurationTest.java @@ -1,7 +1,5 @@ package org.openecomp.sdc.be.config; -import java.util.List; - import org.junit.Test; import org.openecomp.sdc.be.config.DistributionEngineConfiguration.ComponentArtifactTypesConfig; import org.openecomp.sdc.be.config.DistributionEngineConfiguration.CreateTopicConfig; @@ -9,8 +7,7 @@ import org.openecomp.sdc.be.config.DistributionEngineConfiguration.DistributionN import org.openecomp.sdc.be.config.DistributionEngineConfiguration.DistributionStatusTopicConfig; import org.openecomp.sdc.common.http.config.ExternalServiceConfig; -import java.util.*; -import org.junit.Assert; +import java.util.List; public class DistributionEngineConfigurationTest { diff --git a/common-app-api/src/test/java/org/openecomp/sdc/be/config/DmaapConsumerConfigurationTest.java b/common-app-api/src/test/java/org/openecomp/sdc/be/config/DmaapConsumerConfigurationTest.java index b773be49cc..a4087b34c5 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/be/config/DmaapConsumerConfigurationTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/be/config/DmaapConsumerConfigurationTest.java @@ -1,7 +1,5 @@ package org.openecomp.sdc.be.config; -import javax.annotation.Generated; - import org.junit.Test; import org.openecomp.sdc.be.config.DmaapConsumerConfiguration.Credential; diff --git a/common-app-api/src/test/java/org/openecomp/sdc/be/config/ErrorConfigurationTest.java b/common-app-api/src/test/java/org/openecomp/sdc/be/config/ErrorConfigurationTest.java deleted file mode 100644 index d9e6066224..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/be/config/ErrorConfigurationTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.openecomp.sdc.be.config; - -import java.util.Map; - -import org.junit.Test; - - -public class ErrorConfigurationTest { - - private ErrorConfiguration createTestSubject() { - return new ErrorConfiguration(); - } - - - @Test - public void testGetErrors() throws Exception { - ErrorConfiguration testSubject; - Map<String, ErrorInfo> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getErrors(); - } - - - @Test - public void testSetErrors() throws Exception { - ErrorConfiguration testSubject; - Map<String, ErrorInfo> errors = null; - - // default test - testSubject = createTestSubject(); - testSubject.setErrors(errors); - } - - - - - - @Test - public void testToString() throws Exception { - ErrorConfiguration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.toString(); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/be/config/ErrorInfoTest.java b/common-app-api/src/test/java/org/openecomp/sdc/be/config/ErrorInfoTest.java deleted file mode 100644 index 4c95543fb9..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/be/config/ErrorInfoTest.java +++ /dev/null @@ -1,108 +0,0 @@ -package org.openecomp.sdc.be.config; - -import org.junit.Test; -import org.openecomp.sdc.be.config.ErrorInfo.ErrorInfoType; - - -public class ErrorInfoTest { - - private ErrorInfo createTestSubject() { - return new ErrorInfo(); - } - - - @Test - public void testGetCode() throws Exception { - ErrorInfo testSubject; - Integer result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCode(); - } - - - @Test - public void testSetCode() throws Exception { - ErrorInfo testSubject; - Integer code = 0; - - // default test - testSubject = createTestSubject(); - testSubject.setCode(code); - } - - - @Test - public void testGetMessage() throws Exception { - ErrorInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getMessage(); - } - - - @Test - public void testSetMessage() throws Exception { - ErrorInfo testSubject; - String message = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setMessage(message); - } - - - @Test - public void testGetMessageId() throws Exception { - ErrorInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getMessageId(); - } - - - @Test - public void testSetMessageId() throws Exception { - ErrorInfo testSubject; - String messageId = ""; - - // test 1 - testSubject = createTestSubject(); - messageId = null; - testSubject.setMessageId(messageId); - - // test 2 - testSubject = createTestSubject(); - messageId = ""; - testSubject.setMessageId(messageId); - } - - - @Test - public void testGetErrorInfoType() throws Exception { - ErrorInfo testSubject; - ErrorInfoType result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getErrorInfoType(); - } - - - - - @Test - public void testToString() throws Exception { - ErrorInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.toString(); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/be/config/Neo4jErrorsConfigurationTest.java b/common-app-api/src/test/java/org/openecomp/sdc/be/config/Neo4jErrorsConfigurationTest.java deleted file mode 100644 index 6b7b163f45..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/be/config/Neo4jErrorsConfigurationTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.openecomp.sdc.be.config; - -import java.util.Map; - -import org.junit.Test; - - -public class Neo4jErrorsConfigurationTest { - - private Neo4jErrorsConfiguration createTestSubject() { - return new Neo4jErrorsConfiguration(); - } - - - @Test - public void testGetErrors() throws Exception { - Neo4jErrorsConfiguration testSubject; - Map<String, String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getErrors(); - } - - - @Test - public void testSetErrors() throws Exception { - Neo4jErrorsConfiguration testSubject; - Map<String, String> errors = null; - - // default test - testSubject = createTestSubject(); - testSubject.setErrors(errors); - } - - - - - - @Test - public void testToString() throws Exception { - Neo4jErrorsConfiguration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.toString(); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/be/config/validation/DeploymentArtifactHeatConfigurationTest.java b/common-app-api/src/test/java/org/openecomp/sdc/be/config/validation/DeploymentArtifactHeatConfigurationTest.java deleted file mode 100644 index d2c394bff2..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/be/config/validation/DeploymentArtifactHeatConfigurationTest.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.openecomp.sdc.be.config.validation; - -import java.util.Map; - -import org.junit.Test; - - -public class DeploymentArtifactHeatConfigurationTest { - - private DeploymentArtifactHeatConfiguration createTestSubject() { - return new DeploymentArtifactHeatConfiguration(); - } - - - @Test - public void testGetHeat_template_version() throws Exception { - DeploymentArtifactHeatConfiguration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getHeat_template_version(); - } - - - @Test - public void testSetHeat_template_version() throws Exception { - DeploymentArtifactHeatConfiguration testSubject; - String heat_template_version = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setHeat_template_version(heat_template_version); - } - - - @Test - public void testGetResources() throws Exception { - DeploymentArtifactHeatConfiguration testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResources(); - } - - - @Test - public void testSetResources() throws Exception { - DeploymentArtifactHeatConfiguration testSubject; - Map<String, Object> resources = null; - - // default test - testSubject = createTestSubject(); - testSubject.setResources(resources); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/api/ArtifactGroupTypeEnumTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/api/ArtifactGroupTypeEnumTest.java index 8eab423743..d5013bd315 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/api/ArtifactGroupTypeEnumTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/api/ArtifactGroupTypeEnumTest.java @@ -1,9 +1,9 @@ package org.openecomp.sdc.common.api; -import java.util.List; - import org.junit.Test; +import java.util.List; + public class ArtifactGroupTypeEnumTest { diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/api/ArtifactTypeEnumTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/api/ArtifactTypeEnumTest.java deleted file mode 100644 index 525080e535..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/api/ArtifactTypeEnumTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.openecomp.sdc.common.api; - -import java.util.List; - -import org.junit.Test; - - -public class ArtifactTypeEnumTest { - - private ArtifactTypeEnum createTestSubject() { - return ArtifactTypeEnum.AAI_SERVICE_MODEL; - } - - - @Test - public void testGetType() throws Exception { - ArtifactTypeEnum testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getType(); - } - - - @Test - public void testSetType() throws Exception { - ArtifactTypeEnum testSubject; - String type = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setType(type); - } - - - @Test - public void testFindType() throws Exception { - String type = ""; - ArtifactTypeEnum result; - - // default test - result = ArtifactTypeEnum.findType(type); - } - - - @Test - public void testGetAllTypes() throws Exception { - List<String> result; - - // default test - result = ArtifactTypeEnum.getAllTypes(); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/api/ConfigurationListenerTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/api/ConfigurationListenerTest.java index bdfedd89cf..e381ff613d 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/api/ConfigurationListenerTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/api/ConfigurationListenerTest.java @@ -1,7 +1,5 @@ package org.openecomp.sdc.common.api; -import javax.annotation.Generated; - import org.junit.Test; public class ConfigurationListenerTest { diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/api/HealthCheckInfoTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/api/HealthCheckInfoTest.java index 0da2aa3271..c06273eee9 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/api/HealthCheckInfoTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/api/HealthCheckInfoTest.java @@ -1,10 +1,10 @@ package org.openecomp.sdc.common.api; -import java.util.List; - import org.junit.Test; import org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckStatus; +import java.util.List; + public class HealthCheckInfoTest { private HealthCheckInfo createTestSubject() { diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/api/ResponseInfoTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/api/ResponseInfoTest.java deleted file mode 100644 index d05484db40..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/api/ResponseInfoTest.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.openecomp.sdc.common.api; - -import org.junit.Test; -import org.openecomp.sdc.common.api.ResponseInfo.ResponseStatusEnum; - - -public class ResponseInfoTest { - - private ResponseInfo createTestSubject() { - return new ResponseInfo(null, ""); - } - - - @Test - public void testGetApplicativeStatus() throws Exception { - ResponseInfo testSubject; - ResponseStatusEnum result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getApplicativeStatus(); - } - - - @Test - public void testSetApplicativeStatus() throws Exception { - ResponseInfo testSubject; - ResponseStatusEnum applicativeStatus = null; - - // default test - testSubject = createTestSubject(); - testSubject.setApplicativeStatus(applicativeStatus); - } - - - @Test - public void testGetDescription() throws Exception { - ResponseInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDescription(); - } - - - @Test - public void testSetDescription() throws Exception { - ResponseInfo testSubject; - String description = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setDescription(description); - } - - - -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/api/ToscaNodeTypeInfoTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/api/ToscaNodeTypeInfoTest.java deleted file mode 100644 index 42b057e521..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/api/ToscaNodeTypeInfoTest.java +++ /dev/null @@ -1,134 +0,0 @@ -package org.openecomp.sdc.common.api; - -import java.util.List; - -import org.junit.Test; - - -public class ToscaNodeTypeInfoTest { - - private ToscaNodeTypeInfo createTestSubject() { - return new ToscaNodeTypeInfo(); - } - - - @Test - public void testGetTemplateName() throws Exception { - ToscaNodeTypeInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getTemplateName(); - } - - - @Test - public void testSetTemplateName() throws Exception { - ToscaNodeTypeInfo testSubject; - String templateName = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setTemplateName(templateName); - } - - - @Test - public void testGetNodeName() throws Exception { - ToscaNodeTypeInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getNodeName(); - } - - - @Test - public void testSetNodeName() throws Exception { - ToscaNodeTypeInfo testSubject; - String nodeName = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setNodeName(nodeName); - } - - - @Test - public void testGetTemplateVersion() throws Exception { - ToscaNodeTypeInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getTemplateVersion(); - } - - - @Test - public void testSetTemplateVersion() throws Exception { - ToscaNodeTypeInfo testSubject; - String templateVersion = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setTemplateVersion(templateVersion); - } - - - @Test - public void testGetInterfaces() throws Exception { - ToscaNodeTypeInfo testSubject; - List<ToscaNodeTypeInterface> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInterfaces(); - } - - - @Test - public void testSetInterfaces() throws Exception { - ToscaNodeTypeInfo testSubject; - List<ToscaNodeTypeInterface> interfaces = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInterfaces(interfaces); - } - - - @Test - public void testGetIconPath() throws Exception { - ToscaNodeTypeInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getIconPath(); - } - - - @Test - public void testSetIconPath() throws Exception { - ToscaNodeTypeInfo testSubject; - String iconPath = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setIconPath(iconPath); - } - - - @Test - public void testToString() throws Exception { - ToscaNodeTypeInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.toString(); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/api/ToscaNodeTypeInterfaceTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/api/ToscaNodeTypeInterfaceTest.java deleted file mode 100644 index 9c19d3132d..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/api/ToscaNodeTypeInterfaceTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.openecomp.sdc.common.api; - -import java.util.List; - -import org.junit.Test; - - -public class ToscaNodeTypeInterfaceTest { - - private ToscaNodeTypeInterface createTestSubject() { - return new ToscaNodeTypeInterface(); - } - - - @Test - public void testGetScripts() throws Exception { - ToscaNodeTypeInterface testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getScripts(); - } - - - @Test - public void testSetScripts() throws Exception { - ToscaNodeTypeInterface testSubject; - List<String> scripts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setScripts(scripts); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/api/UploadArtifactInfoTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/api/UploadArtifactInfoTest.java index 9df5fad7ba..6b3c23bd71 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/api/UploadArtifactInfoTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/api/UploadArtifactInfoTest.java @@ -1,7 +1,5 @@ package org.openecomp.sdc.common.api; -import javax.annotation.Generated; - import org.junit.Assert; import org.junit.Test; diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/api/YamlSuffixEnumTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/api/YamlSuffixEnumTest.java deleted file mode 100644 index aeea08999f..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/api/YamlSuffixEnumTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.openecomp.sdc.common.api; - -import java.util.List; - -import org.junit.Test; - - -public class YamlSuffixEnumTest { - - private YamlSuffixEnum createTestSubject() { - return YamlSuffixEnum.YAML; - } - - - @Test - public void testGetSuffix() throws Exception { - YamlSuffixEnum testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getSuffix(); - } - - - @Test - public void testSetSuufix() throws Exception { - YamlSuffixEnum testSubject; - String suffix = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setSuufix(suffix); - } - - - @Test - public void testGetSuffixes() throws Exception { - List<String> result; - - // default test - result = YamlSuffixEnum.getSuffixes(); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/config/EcompErrorConfigurationTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/config/EcompErrorConfigurationTest.java index 7ebe341b9c..60e088ecbb 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/config/EcompErrorConfigurationTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/config/EcompErrorConfigurationTest.java @@ -1,12 +1,9 @@ package org.openecomp.sdc.common.config; -import java.util.Map; - -import javax.annotation.Generated; - -import org.junit.Assert; import org.junit.Test; +import java.util.Map; + public class EcompErrorConfigurationTest { diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/config/EcompErrorInfoTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/config/EcompErrorInfoTest.java index 65fc197e62..c5ef7cbff9 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/config/EcompErrorInfoTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/config/EcompErrorInfoTest.java @@ -1,7 +1,5 @@ package org.openecomp.sdc.common.config; -import javax.annotation.Generated; - import org.junit.Test; public class EcompErrorInfoTest { diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsvTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsvTest.java index bdcbca016d..8bd503de3b 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsvTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsvTest.java @@ -1,7 +1,5 @@ package org.openecomp.sdc.common.config.generation; -import javax.annotation.Generated; - import org.junit.Test; public class GenerateEcompErrorsCsvTest { diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKeysEnumTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKeysEnumTest.java deleted file mode 100644 index ec55db5c95..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKeysEnumTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.openecomp.sdc.common.datastructure; - -import org.junit.Test; - - -public class AuditingFieldsKeysEnumTest { - - private AuditingFieldsKeysEnum createTestSubject() { - return AuditingFieldsKeysEnum.AUDIT_ACTION; - } - - - @Test - public void testGetValueClass() throws Exception { - AuditingFieldsKeysEnum testSubject; - Class<?> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getValueClass(); - } - - - @Test - public void testGetDisplayName() throws Exception { - AuditingFieldsKeysEnum testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDisplayName(); - } - - - @Test - public void testSetDisplayName() throws Exception { - AuditingFieldsKeysEnum testSubject; - String displayName = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setDisplayName(displayName); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEventTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEventTest.java deleted file mode 100644 index 4d5d97b7fa..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEventTest.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.openecomp.sdc.common.datastructure; - -import java.util.Map; - -import org.junit.Test; - - -public class ESTimeBasedEventTest { - - private ESTimeBasedEvent createTestSubject() { - return new ESTimeBasedEvent(); - } - - - - - @Test - public void testCalculateYearIndexSuffix() throws Exception { - ESTimeBasedEvent testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.calculateYearIndexSuffix(); - } - - - @Test - public void testCalculateMonthIndexSuffix() throws Exception { - ESTimeBasedEvent testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.calculateMonthIndexSuffix(); - } - - - @Test - public void testCalculateDayIndexSuffix() throws Exception { - ESTimeBasedEvent testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.calculateDayIndexSuffix(); - } - - - @Test - public void testCalculateHourIndexSuffix() throws Exception { - ESTimeBasedEvent testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.calculateHourIndexSuffix(); - } - - - @Test - public void testCalculateMinuteIndexSuffix() throws Exception { - ESTimeBasedEvent testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.calculateMinuteIndexSuffix(); - } - - - - - - @Test - public void testGetTimestamp() throws Exception { - ESTimeBasedEvent testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getTimestamp(); - } - - - @Test - public void testSetTimestamp() throws Exception { - ESTimeBasedEvent testSubject; - String timestamp = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setTimestamp(timestamp); - } - - - @Test - public void testGetFields() throws Exception { - ESTimeBasedEvent testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getFields(); - } - - - @Test - public void testSetFields() throws Exception { - ESTimeBasedEvent testSubject; - Map<String, Object> fields = null; - - // default test - testSubject = createTestSubject(); - testSubject.setFields(fields); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/MonitoringFieldsKeysEnumTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/MonitoringFieldsKeysEnumTest.java deleted file mode 100644 index 515ee0bb76..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/MonitoringFieldsKeysEnumTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.openecomp.sdc.common.datastructure; - -import org.junit.Test; - - -public class MonitoringFieldsKeysEnumTest { - - private MonitoringFieldsKeysEnum createTestSubject() { - return MonitoringFieldsKeysEnum.MONITORING_APP_ID; - } - - - @Test - public void testGetValueClass() throws Exception { - MonitoringFieldsKeysEnum testSubject; - Class<?> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getValueClass(); - } - - - @Test - public void testGetDisplayName() throws Exception { - MonitoringFieldsKeysEnum testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDisplayName(); - } - - - @Test - public void testSetDisplayName() throws Exception { - MonitoringFieldsKeysEnum testSubject; - String displayName = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setDisplayName(displayName); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/WrapperTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/WrapperTest.java deleted file mode 100644 index 9c18861d40..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/WrapperTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.openecomp.sdc.common.datastructure; - -import org.junit.Test; - - -public class WrapperTest { - - private Wrapper createTestSubject() { - return new Wrapper(null); - } - - - - - @Test - public void testIsEmpty() throws Exception { - Wrapper testSubject; - boolean result; - - // default test - testSubject = createTestSubject(); - result = testSubject.isEmpty(); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/ecomplog/EcompLoggerMetricTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/ecomplog/EcompLoggerMetricTest.java deleted file mode 100644 index e3efad46ed..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/ecomplog/EcompLoggerMetricTest.java +++ /dev/null @@ -1,316 +0,0 @@ -package org.openecomp.sdc.common.ecomplog; - -import org.junit.Test; -import org.openecomp.sdc.common.ecomplog.Enums.Severity; -import org.openecomp.sdc.common.ecomplog.api.IEcompMdcWrapper; - -public class EcompLoggerMetricTest { - - private EcompLoggerMetric createTestSubject() { - return new EcompLoggerMetric(new EcompMDCWrapper(new Stopwatch())); - } - - - @Test - public void testGetInstance() throws Exception { - EcompLoggerMetric result; - - // default test - result = EcompLoggerMetric.getInstance(); - } - - - @Test - public void testStartTimer() throws Exception { - EcompLoggerMetric testSubject; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.startTimer(); - } - - - @Test - public void testSetKeyRequestId() throws Exception { - EcompLoggerMetric testSubject; - String keyRequestId = ""; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.setKeyRequestId(keyRequestId); - } - - - @Test - public void testStopTimer() throws Exception { - EcompLoggerMetric testSubject; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.stopTimer(); - } - - - @Test - public void testSetAutoServerFQDN() throws Exception { - EcompLoggerMetric testSubject; - String serverFQDN = ""; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.setAutoServerFQDN(serverFQDN); - } - - - @Test - public void testSetAutoServerIPAddress() throws Exception { - EcompLoggerMetric testSubject; - String serverIPAddress = ""; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.setAutoServerIPAddress(serverIPAddress); - } - - - @Test - public void testSetInstanceUUID() throws Exception { - EcompLoggerMetric testSubject; - String instanceUUID = ""; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.setInstanceUUID(instanceUUID); - } - - - @Test - public void testSetOptProcessKey() throws Exception { - EcompLoggerMetric testSubject; - String processKey = ""; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.setOptProcessKey(processKey); - } - - - @Test - public void testSetOptAlertSeverity() throws Exception { - EcompLoggerMetric testSubject; - Severity alertSeverity = null; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.setOptAlertSeverity(alertSeverity.OK); - } - - - @Test - public void testSetOptCustomField1() throws Exception { - EcompLoggerMetric testSubject; - String customField1 = ""; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.setOptCustomField1(customField1); - } - - - @Test - public void testSetOptCustomField2() throws Exception { - EcompLoggerMetric testSubject; - String customField2 = ""; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.setOptCustomField2(customField2); - } - - - @Test - public void testSetOptCustomField3() throws Exception { - EcompLoggerMetric testSubject; - String customField3 = ""; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.setOptCustomField3(customField3); - } - - - @Test - public void testSetOptCustomField4() throws Exception { - EcompLoggerMetric testSubject; - String customField4 = ""; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.setOptCustomField4(customField4); - } - - - @Test - public void testSetRemoteHost() throws Exception { - EcompLoggerMetric testSubject; - String remoteHost = ""; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.setRemoteHost(remoteHost); - } - - - @Test - public void testSetServiceName() throws Exception { - EcompLoggerMetric testSubject; - String serviceName = ""; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.setServiceName(serviceName); - } - - - @Test - public void testSetStatusCode() throws Exception { - EcompLoggerMetric testSubject; - String statusCode = ""; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.setStatusCode(statusCode); - } - - - @Test - public void testSetPartnerName() throws Exception { - EcompLoggerMetric testSubject; - String partnerName = ""; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.setPartnerName(partnerName); - } - - - @Test - public void testSetResponseCode() throws Exception { - EcompLoggerMetric testSubject; - int responseCode = 0; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.setResponseCode(responseCode); - } - - - @Test - public void testSetResponseDesc() throws Exception { - EcompLoggerMetric testSubject; - String responseDesc = ""; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.setResponseDesc(responseDesc); - } - - - @Test - public void testSetOptServiceInstanceId() throws Exception { - EcompLoggerMetric testSubject; - String serviceInstanceId = ""; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.setOptServiceInstanceId(serviceInstanceId); - } - - - @Test - public void testSetOptClassName() throws Exception { - EcompLoggerMetric testSubject; - String className = ""; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.setOptClassName(className); - } - - - @Test - public void testSetTargetEntity() throws Exception { - EcompLoggerMetric testSubject; - String targetEntity = ""; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.setTargetEntity(targetEntity); - } - - - @Test - public void testSetTargetServiceName() throws Exception { - EcompLoggerMetric testSubject; - String targetServiceName = ""; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.setTargetServiceName(targetServiceName); - } - - - @Test - public void testSetTargetVirtualEntity() throws Exception { - EcompLoggerMetric testSubject; - String targetVirtualEntity = ""; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.setTargetVirtualEntity(targetVirtualEntity); - } - - - @Test - public void testClear() throws Exception { - EcompLoggerMetric testSubject; - EcompLoggerMetric result; - - // default test - testSubject = createTestSubject(); - result = testSubject.clear(); - } - - - @Test - public void testInitializeMandatoryFields() throws Exception { - EcompLoggerMetric testSubject; - - // default test - testSubject = createTestSubject(); - testSubject.initializeMandatoryFields(); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/http/config/TimeoutsTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/http/config/TimeoutsTest.java index d7b14f64ee..385b69b17f 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/http/config/TimeoutsTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/http/config/TimeoutsTest.java @@ -1,7 +1,5 @@ package org.openecomp.sdc.common.http.config; -import javax.annotation.Generated; - import org.junit.Assert; import org.junit.Test; diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/kpi/api/ASDCKpiApiTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/kpi/api/ASDCKpiApiTest.java deleted file mode 100644 index 3ff24f2b07..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/kpi/api/ASDCKpiApiTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.openecomp.sdc.common.kpi.api; - -import org.junit.Test; - - -public class ASDCKpiApiTest { - - private ASDCKpiApi createTestSubject() { - return new ASDCKpiApi(); - } - - - @Test - public void testCountImportResourcesKPI() throws Exception { - - // default test - ASDCKpiApi.countImportResourcesKPI(); - } - - - @Test - public void testCountCreatedResourcesKPI() throws Exception { - - // default test - ASDCKpiApi.countCreatedResourcesKPI(); - } - - - @Test - public void testCountCreatedServicesKPI() throws Exception { - - // default test - ASDCKpiApi.countCreatedServicesKPI(); - } - - - @Test - public void testCountUsersAuthorizations() throws Exception { - - // default test - ASDCKpiApi.countUsersAuthorizations(); - } - - - @Test - public void testCountActivatedDistribution() throws Exception { - - // default test - ASDCKpiApi.countActivatedDistribution(); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/listener/AppContextListenerTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/listener/AppContextListenerTest.java deleted file mode 100644 index 298f6fe85d..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/listener/AppContextListenerTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.openecomp.sdc.common.listener; - -import java.util.Map; - -import javax.servlet.ServletContext; -import javax.servlet.ServletContextEvent; - -import org.junit.Test; - - -public class AppContextListenerTest { - - private AppContextListener createTestSubject() { - return new AppContextListener(); - } - - - - - - @Test - public void testContextDestroyed() throws Exception { - AppContextListener testSubject; - ServletContextEvent context = null; - - // default test - testSubject = createTestSubject(); - testSubject.contextDestroyed(context); - } - - - - -// @Test - public void testGetManifestInfo() throws Exception { - ServletContext application = null; - Map<String, String> result; - - // default test - result = AppContextListener.getManifestInfo(application); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java new file mode 100644 index 0000000000..155ea4fb0b --- /dev/null +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java @@ -0,0 +1,99 @@ +/*- + * ============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.sdc.common.log.elements; + +import org.junit.Before; +import org.junit.Test; +import org.slf4j.MDC; + +import static org.junit.Assert.*; +import static org.openecomp.sdc.common.log.api.ILogConfiguration.*; + +public class LogFieldsMdcHandlerTest { + + private LogFieldsMdcHandler ecompMdcWrapper; + + @Before + public void init(){ + ecompMdcWrapper = new LogFieldsMdcHandler(); + ecompMdcWrapper.clear(); + MDC.clear(); + } + + @Test + public void isMDCParamEmpty_shouldReturnTrue_onNonNullValueInMDC(){ + MDC.put("Key","value1"); + assertFalse(ecompMdcWrapper.isMDCParamEmpty("Key")); + } + @Test + public void isMDCParamEmpty_shouldReturnFalse_onEmptyStringInMDC(){ + MDC.put("Key",""); + assertTrue(ecompMdcWrapper.isMDCParamEmpty("Key")); + } + + @Test + public void isMDCParamEmpty_shouldReturnFalse_onNullValueInMDC(){ + MDC.put("Key",null); + assertTrue(ecompMdcWrapper.isMDCParamEmpty("Key")); + } + + @Test + public void startTimer_shouldFilecompMdcWrappereginTimestampField(){ + ecompMdcWrapper.startMetricTimer(); + assertFalse(ecompMdcWrapper.isMDCParamEmpty(MDC_METRIC_BEGIN_TIMESTAMP)); + } + + @Test + public void stopTimer_shouldFillEndTimestampField_ifStartTimerWasCalledPreviously(){ + ecompMdcWrapper.startAuditTimer(); + ecompMdcWrapper.stopAuditTimer(); + assertFalse(ecompMdcWrapper.isMDCParamEmpty(MDC_END_TIMESTAMP)); + } + + @Test + public void clear_shouldRemoveAllMandatoryAndOptionalFields_And_OnlyThem(){ + ecompMdcWrapper.setClassName("class1"); + ecompMdcWrapper.setPartnerName("partner1"); + ecompMdcWrapper.setOptCustomField1("of1"); + ecompMdcWrapper.clear(); + assertNull(MDC.get(MDC_CLASS_NAME)); + assertNull(MDC.get(MDC_PARTNER_NAME)); + assertNull(MDC.get(MDC_OPT_FIELD1)); + } + + @Test + public void clear_shouldNotThrowAnException_WhenNoFieldWasAssignedAsMandatoryOrOptional(){ + ecompMdcWrapper.setClassName("class1"); + ecompMdcWrapper.setPartnerName("partner1"); + ecompMdcWrapper.setOptCustomField1("of1"); + Exception exp = null; + try { + ecompMdcWrapper.clear(); + } + catch (Exception e) + { + exp =e; + } + assertNull(exp); + } + +} + diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAsdcUtilTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAsdcUtilTest.java new file mode 100644 index 0000000000..23c54ce1cc --- /dev/null +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAsdcUtilTest.java @@ -0,0 +1,170 @@ +package org.openecomp.sdc.common.log.elements; + + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode; +import org.openecomp.sdc.common.log.enums.LogLevel; +import org.openecomp.sdc.common.log.enums.Severity; +import org.openecomp.sdc.common.log.wrappers.LoggerSdcAudit; +import org.openecomp.sdc.common.log.wrappers.LoggerSdcUtilBase; + +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.core.UriInfo; +import java.net.URI; +import java.net.URISyntaxException; + +import static java.net.HttpURLConnection.*; +import static org.junit.Assert.*; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.when; + +/** + * Created by dd4296 on 12/19/2017. + * + * test get partner name + */ +@RunWith(MockitoJUnitRunner.class) +public class LoggerAsdcUtilTest { + + private final String chromeUserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"; + private final String firefoxUserAgent = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.13) Gecko/20080313 Firefox"; + private final String explorerUserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)"; + + private final String testUserId = "ml007"; + private final String urlWithUserName = "/api/v1/user/" + testUserId; + + class SdcEelfAuditTest extends LoggerSdcAudit { + + SdcEelfAuditTest(Class<?> clazz) { + super(clazz); + } + + public String getPartnerName(String userAgent, String userID, String url) { + return super.getPartnerName(userAgent, userID, url); + } + } + + @Mock + private ContainerRequestContext requestContext; + @Mock + UriInfo uriInfo; + + private SdcEelfAuditTest asdcEelfAudit; + + @Before + public void Init () throws URISyntaxException { + asdcEelfAudit = new SdcEelfAuditTest(LoggerAsdcUtilTest.class); + when(requestContext.getHeaderString(anyString())).thenReturn("ab2222"); + when(requestContext.getUriInfo()).thenReturn(uriInfo); + URI uri = new URI("http:/abc.com/getId"); + when(uriInfo.getRequestUri()).thenReturn(uri); + when(uriInfo.getBaseUri()).thenReturn(uri); + + } + + @Test + public void extract_user_id_from_userAgentTest() { + + String userIdChrome = asdcEelfAudit.getPartnerName(chromeUserAgent, "", ""); + assertEquals(userIdChrome.toLowerCase(), "chrome_FE".toLowerCase()); + + String userIdFireFox = asdcEelfAudit.getPartnerName(firefoxUserAgent, "", ""); + assertEquals(userIdFireFox.toLowerCase(), "firefox_FE".toLowerCase()); + + String userIdIE = asdcEelfAudit.getPartnerName(explorerUserAgent, "", ""); + assertEquals(userIdIE.toLowerCase(), "explorer_FE".toLowerCase()); + } + + @Test + public void extract_user_id_from_urlTest() { + + String userId = asdcEelfAudit.getPartnerName("", "", urlWithUserName); + assertEquals(testUserId, userId); + } + + @Test + public void extract_user_id_from_paramTest() { + + String userId = asdcEelfAudit.getPartnerName("", testUserId, ""); + assertEquals(userId, testUserId); + } + + @Test + public void extract_user_id_priorityTest() { + + String userId = asdcEelfAudit.getPartnerName(chromeUserAgent, testUserId, urlWithUserName); + assertEquals(userId, testUserId); + + String userIdUrl = asdcEelfAudit.getPartnerName(chromeUserAgent, "", urlWithUserName); + assertEquals(userIdUrl, testUserId); + + String userIdUserAgent = asdcEelfAudit.getPartnerName(chromeUserAgent, "", ""); + assertEquals(userIdUserAgent.toLowerCase(), "chrome_FE".toLowerCase()); + } + + @Test + public void check_http_error_convert_to_eelf_code() { + class LoggerSdcUtilBaseTest extends LoggerSdcUtilBase { + public EcompLoggerErrorCode convertHttpCodeToErrorCode(int httpResponseCode) { + return super.convertHttpCodeToErrorCode(httpResponseCode); + } + } + + LoggerSdcUtilBaseTest utilBase = new LoggerSdcUtilBaseTest(); + + Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_BAD_REQUEST), EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR); + Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_UNAUTHORIZED), EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR); + Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_NOT_FOUND), EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR); + Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_CLIENT_TIMEOUT), EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR); + Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_GONE), EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR); + + Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_PAYMENT_REQUIRED), EcompLoggerErrorCode.PERMISSION_ERROR); + Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_FORBIDDEN), EcompLoggerErrorCode.PERMISSION_ERROR); + Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_BAD_METHOD), EcompLoggerErrorCode.PERMISSION_ERROR); + Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_PROXY_AUTH), EcompLoggerErrorCode.PERMISSION_ERROR); + + Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_NOT_ACCEPTABLE), EcompLoggerErrorCode.DATA_ERROR); + Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_LENGTH_REQUIRED), EcompLoggerErrorCode.DATA_ERROR); + Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_PRECON_FAILED), EcompLoggerErrorCode.DATA_ERROR); + Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_REQ_TOO_LONG), EcompLoggerErrorCode.DATA_ERROR); + Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_ENTITY_TOO_LARGE), EcompLoggerErrorCode.DATA_ERROR); + Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_UNSUPPORTED_TYPE), EcompLoggerErrorCode.DATA_ERROR); + + Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_CONFLICT), EcompLoggerErrorCode.SCHEMA_ERROR); + + Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_OK), EcompLoggerErrorCode.SUCCESS); + + Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_INTERNAL_ERROR), EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR); + Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_NOT_IMPLEMENTED), EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR); + Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_BAD_GATEWAY), EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR); + Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_UNAVAILABLE), EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR); + Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_GATEWAY_TIMEOUT), EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR); + Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_VERSION), EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR); + + } + + @Test + public void takenCareOf_shouldBeTrue_ifStartedLogWasCalled(){ + asdcEelfAudit.startLog(requestContext); + assertTrue(asdcEelfAudit.isFlowBeingTakenCare()); + } + + @Test + public void takenCareOf_shouldBeFalse_ifStartedLogWasNoCalled(){ + assertFalse(asdcEelfAudit.isFlowBeingTakenCare()); + } + + @Test + public void takenCareOf_shouldBeFalse_ifStartedLogWasCalleAndLogWasCalledToo(){ + asdcEelfAudit.startLog(requestContext); + + asdcEelfAudit.log(null,null,null, LogLevel.INFO, Severity.OK, "message"); + assertFalse(asdcEelfAudit.isFlowBeingTakenCare()); + } + +} diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAuditTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAuditTest.java new file mode 100644 index 0000000000..1cc4024c4a --- /dev/null +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAuditTest.java @@ -0,0 +1,96 @@ +package org.openecomp.sdc.common.log.elements; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode; +import org.openecomp.sdc.common.log.enums.LogLevel; +import org.openecomp.sdc.common.log.enums.Severity; +import org.openecomp.sdc.common.log.enums.StatusCode; +import org.slf4j.Logger; +import org.slf4j.MDC; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.UUID; + +import static org.openecomp.sdc.common.log.api.ILogConfiguration.*; +import static org.openecomp.sdc.common.log.elements.LogFieldsMdcHandler.hostAddress; + +@RunWith(MockitoJUnitRunner.class) +public class LoggerAuditTest { + @Mock + private Logger logger; + + private LoggerAudit auditLog; + + @Before + public void init() { + auditLog = new LoggerAudit(LogFieldsMdcHandler.getInstance(), logger); + } + + @After + public void tearDown() { + MDC.clear(); + } + + @Test + public void whenNoAuditFieldsArePopulated_ShouldReturnAssertTrue_onMdcMap() { + auditLog.clear() + .log(LogLevel.INFO, "some error code"); + Assert.assertNotNull(MDC.get(MDC_SERVER_FQDN)); + Assert.assertNotNull(MDC.get(MDC_SERVER_IP_ADDRESS)); + } + + @Test + public void whenAllAuditFieldsArePopulated_ShouldReturnAssertTrue_onEachMACField() throws UnknownHostException { + + String uuid = UUID.randomUUID().toString(); + String hostName = InetAddress.getByName(hostAddress).getCanonicalHostName(); + String hostAddress = InetAddress.getLocalHost().getHostAddress(); + + auditLog.clear() + .startTimer() + .stopTimer() + .setKeyRequestId(uuid) + .setInstanceUUID(MDC_INSTANCE_UUID) + .setRemoteHost(MDC_REMOTE_HOST) + .setServiceName(MDC_SERVICE_NAME) + .setResponseCode(EcompLoggerErrorCode.DATA_ERROR) + .setStatusCode("201") + .setResponseDesc(MDC_RESPONSE_DESC) + .setPartnerName(MDC_PARTNER_NAME) + + .setOptClassName(LoggerAuditTest.class.toString()) + .setOptAlertSeverity(Severity.CRITICAL) + .setOptProcessKey(MDC_PROCESS_KEY) + .setOptServiceInstanceId(MDC_SERVICE_INSTANCE_ID) + .log(LogLevel.DEBUG, ""); + + + Assert.assertFalse(LogFieldsMdcHandler.getInstance().isMDCParamEmpty(MDC_AUDIT_BEGIN_TIMESTAMP)); + Assert.assertFalse(LogFieldsMdcHandler.getInstance().isMDCParamEmpty(MDC_END_TIMESTAMP)); + Assert.assertFalse(LogFieldsMdcHandler.getInstance().isMDCParamEmpty(MDC_ELAPSED_TIME)); + + Assert.assertEquals(MDC.get(MDC_SERVER_IP_ADDRESS), hostAddress); + Assert.assertEquals(MDC.get(MDC_SERVER_FQDN), hostName); + Assert.assertEquals(MDC.get(MDC_REMOTE_HOST), MDC_REMOTE_HOST); + Assert.assertEquals(MDC.get(MDC_STATUS_CODE), StatusCode.COMPLETE.getStatusCodeEnum()); + + Assert.assertEquals(MDC.get(MDC_KEY_REQUEST_ID), uuid); + Assert.assertEquals(MDC.get(MDC_SERVICE_NAME), MDC_SERVICE_NAME); + Assert.assertEquals(MDC.get(MDC_PARTNER_NAME), MDC_PARTNER_NAME); + Assert.assertEquals(MDC.get(MDC_RESPONSE_CODE), String.valueOf(EcompLoggerErrorCode.DATA_ERROR.getErrorCode())); + Assert.assertEquals(MDC.get(MDC_RESPONSE_DESC), MDC_RESPONSE_DESC); + Assert.assertEquals(MDC.get(MDC_INSTANCE_UUID), MDC_INSTANCE_UUID); + Assert.assertEquals(MDC.get(MDC_CLASS_NAME), LoggerAuditTest.class.toString()); + + Assert.assertEquals(MDC.get(MDC_ALERT_SEVERITY), String.valueOf(Severity.CRITICAL.getSeverityType())); + Assert.assertEquals(MDC.get(MDC_PROCESS_KEY), MDC_PROCESS_KEY); + Assert.assertEquals(MDC.get(MDC_SERVICE_INSTANCE_ID), MDC_SERVICE_INSTANCE_ID); + } +} diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerDebugTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerDebugTest.java new file mode 100644 index 0000000000..4b1742eab8 --- /dev/null +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerDebugTest.java @@ -0,0 +1,89 @@ +package org.openecomp.sdc.common.log.elements; + +/** + * Created by dd4296 on 12/25/2017. + */ + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.openecomp.sdc.common.log.enums.LogLevel; +import org.openecomp.sdc.common.util.ThreadLocalsHolder; +import org.slf4j.Logger; +import org.slf4j.MDC; + +import java.net.UnknownHostException; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.openecomp.sdc.common.log.api.ILogConfiguration.*; + +@RunWith(MockitoJUnitRunner.class) +public class LoggerDebugTest { + + @Mock + private Logger logger; + + private LoggerDebug debugLog; + + @Before + public void init() { + debugLog = new LoggerDebug(LogFieldsMdcHandler.getInstance(), logger); + ThreadLocalsHolder.setUuid(null); + MDC.clear(); + } + + @Test + public void whenNoFieldsIsPopulated_RequestedMdcFieldsAreEmpty() { + debugLog.clear() + .log(LogLevel.DEBUG, "some error code"); + assertNull(MDC.get(MDC_KEY_REQUEST_ID)); + } + + @Test + public void debugLogCheckValidationValidFieldsTest() { + debugLog.clear() + .startTimer() + .setKeyRequestId("uuid") + .log(LogLevel.DEBUG, "some error code"); + + Assert.assertEquals(MDC.get(MDC_KEY_REQUEST_ID), "uuid"); + } + + @Test + public void whenOnlyDebugUUIDFieldsIsPopulated_ShouldReturnAssertTrue_onUUIDFieldCheck() { + debugLog.clear() + .setKeyRequestId("uuid") + .log(LogLevel.DEBUG, "some error code"); + + Assert.assertEquals(MDC.get(MDC_KEY_REQUEST_ID), "uuid"); + } + + @Test + public void whenAllDebugFieldsArePopulated_ShouldReturnAssertTrue_onEachMACFieldCheck() throws UnknownHostException { + debugLog.clear() + .startTimer() + .setKeyRequestId(MDC_KEY_REQUEST_ID) + .log(LogLevel.DEBUG, "some message"); + + Assert.assertTrue(LogFieldsMdcHandler.getInstance().isMDCParamEmpty(MDC_END_TIMESTAMP)); + Assert.assertTrue(LogFieldsMdcHandler.getInstance().isMDCParamEmpty(MDC_ELAPSED_TIME)); + Assert.assertTrue(LogFieldsMdcHandler.getInstance().isMDCParamEmpty(MDC_STATUS_CODE)); + } + + + @Test + public void validateMandatoryFields(){ + assertEquals(MDC_KEY_REQUEST_ID, debugLog.checkMandatoryFieldsExistInMDC().trim()); + } + + @Test + public void validateMandatoryFieldsWhenFieldIsSet(){ + debugLog.clear() + .setKeyRequestId("1234"); + assertEquals("", debugLog.checkMandatoryFieldsExistInMDC()); + } +} diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerErrorTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerErrorTest.java new file mode 100644 index 0000000000..e7fd3455e5 --- /dev/null +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerErrorTest.java @@ -0,0 +1,72 @@ +package org.openecomp.sdc.common.log.elements; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.openecomp.sdc.common.config.EcompErrorCode; +import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode; +import org.openecomp.sdc.common.log.enums.LogLevel; +import org.openecomp.sdc.common.util.ThreadLocalsHolder; +import org.slf4j.Logger; +import org.slf4j.MDC; + +import static org.junit.Assert.assertEquals; +import static org.openecomp.sdc.common.log.api.ILogConfiguration.*; + +@RunWith(MockitoJUnitRunner.class) +public class LoggerErrorTest { + private LoggerError errorLog; + + @Mock + private Logger logger; + @Before + public void init() { + errorLog = LoggerFactory.getMdcLogger(LoggerError.class, logger); + MDC.clear(); + } + + @Test + public void allFieldsArePresentTest() { + ThreadLocalsHolder.setUuid("uuid"); + errorLog.log(LogLevel.ERROR, EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR, "service", "entity", "server error"); + + Assert.assertEquals(MDC.get(MDC_ERROR_CODE), String.valueOf(EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR.getErrorCode())); + Assert.assertEquals("uuid", MDC.get(MDC_KEY_REQUEST_ID)); + Assert.assertEquals("entity", MDC.get(MDC_TARGET_ENTITY)); + Assert.assertEquals("service", MDC.get(MDC_SERVICE_NAME)); + } + + @Test + public void missingFieldsTest() { + errorLog.clear() + .log(LogLevel.ERROR,"some message"); + } + + @Test + public void convertEcompErrorForLogging_correctName() { + assertEquals(EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR, EcompLoggerErrorCode.getByValue(EcompErrorCode.E_210.name())); + } + + @Test + public void convertEcompErrorForLogging_correctName_2() { + assertEquals(EcompLoggerErrorCode.DATA_ERROR, EcompLoggerErrorCode.getByValue(EcompErrorCode.E_399.name())); + } + + @Test + public void convertEcompErrorForLogging_NotConvertable() { + assertEquals(EcompLoggerErrorCode.UNKNOWN_ERROR, EcompLoggerErrorCode.getByValue("ABC")); + } + + @Test + public void convertEcompErrorForLogging_NotConvertable_2() { + assertEquals(EcompLoggerErrorCode.UNKNOWN_ERROR, EcompLoggerErrorCode.getByValue("E_ABC")); + } + + @Test + public void convertEcompErrorForLogging_Success() { + assertEquals(EcompLoggerErrorCode.SUCCESS, EcompLoggerErrorCode.getByValue("E_0")); + } +} diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerMetricTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerMetricTest.java new file mode 100644 index 0000000000..cee7da585f --- /dev/null +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerMetricTest.java @@ -0,0 +1,112 @@ +package org.openecomp.sdc.common.log.elements; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.openecomp.sdc.common.log.enums.LogLevel; +import org.openecomp.sdc.common.log.enums.Severity; +import org.openecomp.sdc.common.util.ThreadLocalsHolder; +import org.slf4j.Logger; +import org.slf4j.MDC; + +import javax.ws.rs.core.Response; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.UUID; + +import static org.openecomp.sdc.common.log.api.ILogConfiguration.*; +import static org.openecomp.sdc.common.log.elements.LogFieldsMdcHandler.hostAddress; + +/** + * Created by dd4296 on 12/31/2017. + */ +@RunWith(MockitoJUnitRunner.class) +public class LoggerMetricTest { + @Mock + private Logger logger; + + @Mock + Response.StatusType statusType; + + private LoggerMetric metricLog; + + @Before + public void init() { + metricLog = new LoggerMetric(LogFieldsMdcHandler.getInstance(), logger); + } + + @After + public void tearDown() { + MDC.clear(); + ThreadLocalsHolder.setUuid(null); + } + + @Test + public void whenNoMetricFieldsArePopulated_ShouldReturnassertEquals_onMdcMap() { + metricLog.clear() + .log(LogLevel.DEBUG, "some error code"); + Assert.assertNotNull(MDC.get(MDC_SERVER_FQDN)); + Assert.assertNotNull(MDC.get(MDC_SERVER_IP_ADDRESS)); + } + + @Test + public void whenAllMetricFieldsArePopulated_ShouldReturnassertEquals_onEachMACField() throws UnknownHostException { + String uuid = UUID.randomUUID().toString(); + ThreadLocalsHolder.setUuid(uuid); + + String hostName = InetAddress.getByName(hostAddress).getCanonicalHostName(); + String hostAddress = InetAddress.getLocalHost().getHostAddress(); + + metricLog.clear() + .startTimer() + .stopTimer() + .setInstanceUUID(MDC_INSTANCE_UUID) + .setRemoteHost(MDC_REMOTE_HOST) + .setServiceName(MDC_SERVICE_NAME) + .setResponseCode(500) + .setStatusCode("201") + .setResponseDesc(MDC_RESPONSE_DESC) + .setPartnerName(MDC_PARTNER_NAME) + + .setOptClassName(LoggerMetricTest.class.toString()) + .setOptAlertSeverity(Severity.CRITICAL) + .setOptProcessKey(MDC_PROCESS_KEY) + .setOptServiceInstanceId(MDC_SERVICE_INSTANCE_ID) + + .setTargetEntity(MDC_TARGET_ENTITY) + .setTargetServiceName(MDC_TARGET_SERVICE_NAME) + .setTargetVirtualEntity(MDC_TARGET_VIRTUAL_ENTITY) + + .log(LogLevel.DEBUG, ""); + + + Assert.assertFalse(LogFieldsMdcHandler.getInstance().isMDCParamEmpty(MDC_METRIC_BEGIN_TIMESTAMP)); + Assert.assertFalse(LogFieldsMdcHandler.getInstance().isMDCParamEmpty(MDC_END_TIMESTAMP)); + Assert.assertFalse(LogFieldsMdcHandler.getInstance().isMDCParamEmpty(MDC_ELAPSED_TIME)); + + Assert.assertEquals(MDC.get(MDC_SERVER_IP_ADDRESS),hostAddress); + Assert.assertEquals(MDC.get(MDC_SERVER_FQDN), hostName); + Assert.assertEquals(MDC.get(MDC_REMOTE_HOST), MDC_REMOTE_HOST); + Assert.assertEquals(MDC.get(MDC_STATUS_CODE) ,"201"); + + Assert.assertEquals(MDC.get(MDC_KEY_REQUEST_ID), uuid); + Assert.assertEquals(MDC.get(MDC_SERVICE_NAME) ,MDC_SERVICE_NAME); + Assert.assertEquals(MDC.get(MDC_PARTNER_NAME) ,MDC_PARTNER_NAME); + Assert.assertEquals(MDC.get(MDC_RESPONSE_CODE) ,"500"); + Assert.assertEquals(MDC.get(MDC_RESPONSE_DESC) ,MDC_RESPONSE_DESC); + Assert.assertEquals(MDC.get(MDC_INSTANCE_UUID) ,MDC_INSTANCE_UUID); + Assert.assertEquals(MDC.get(MDC_CLASS_NAME) ,LoggerMetricTest.class.toString()); + + Assert.assertEquals(MDC.get(MDC_ALERT_SEVERITY) ,String.valueOf(Severity.CRITICAL.getSeverityType())); + Assert.assertEquals(MDC.get(MDC_PROCESS_KEY) ,MDC_PROCESS_KEY); + Assert.assertEquals(MDC.get(MDC_SERVICE_INSTANCE_ID) ,MDC_SERVICE_INSTANCE_ID); + + Assert.assertEquals(MDC.get(MDC_TARGET_ENTITY) ,MDC_TARGET_ENTITY); + Assert.assertEquals(MDC.get(MDC_TARGET_SERVICE_NAME) ,MDC_TARGET_SERVICE_NAME); + Assert.assertEquals(MDC.get(MDC_TARGET_VIRTUAL_ENTITY) ,MDC_TARGET_VIRTUAL_ENTITY); + } +} diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/log/wrappers/LoggerTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/log/wrappers/LoggerTest.java new file mode 100644 index 0000000000..b965a0bc55 --- /dev/null +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/log/wrappers/LoggerTest.java @@ -0,0 +1,261 @@ +package org.openecomp.sdc.common.log.wrappers; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.openecomp.sdc.common.log.api.ILogConfiguration; +import org.openecomp.sdc.common.log.elements.LoggerError; +import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode; +import org.openecomp.sdc.common.log.enums.LogLevel; +import org.openecomp.sdc.common.log.enums.Severity; +import org.openecomp.sdc.common.util.ThreadLocalsHolder; +import org.slf4j.MDC; +import org.slf4j.Marker; + +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; +import java.net.URI; +import java.net.URISyntaxException; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.contains; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.*; +import static org.openecomp.sdc.common.log.api.ILogConfiguration.*; + +@RunWith(MockitoJUnitRunner.class) +public class LoggerTest { + + private final static String targetEntity = "DCEA"; + private final static String serviceName = "testService"; + private final static String message = "Logger message"; + private final static String exceptionMsg= "Exception testing"; + private final static String missingFieldsMessageFragment = "mandatory parameters for ECOMP logging"; + + @Mock + private org.slf4j.Logger logger; + @Mock + private ContainerRequestContext requestContext; + @Mock + private UriInfo uriInfo; + @Mock + private Response.StatusType statusType; + + @InjectMocks + private Logger commonLogger; + + @Captor + private ArgumentCaptor<String> captor; + + @Before + public void setUp() { + MDC.clear(); + } + + @Test + public void validateErrorLogWhenErrorSettingsProvided() { + when(logger.isErrorEnabled()).thenReturn(true); + commonLogger.error(EcompLoggerErrorCode.PERMISSION_ERROR, serviceName, targetEntity, message); + + verify(logger).error(any(Marker.class), captor.capture(), any(Object[].class)); + assertEquals(message, captor.getValue()); + assertEquals(String.valueOf(EcompLoggerErrorCode.PERMISSION_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE)); + assertEquals(LogLevel.ERROR.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY)); + assertEquals(targetEntity, MDC.get(ILogConfiguration.MDC_TARGET_ENTITY)); + assertEquals(serviceName, MDC.get(ILogConfiguration.MDC_SERVICE_NAME)); + } + + @Test + public void validateWarnMessageIsLoggedWhenAllErrorSettingsProvided() { + when(logger.isErrorEnabled()).thenReturn(true); + commonLogger.error(EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR, serviceName, targetEntity, message); + + verify(logger).error(any(Marker.class), captor.capture(), any(Object[].class)); + assertEquals(message, captor.getValue()); + assertEquals(String.valueOf(EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE)); + assertEquals(LogLevel.ERROR.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY)); + assertEquals(targetEntity, MDC.get(ILogConfiguration.MDC_TARGET_ENTITY)); + assertEquals(serviceName, MDC.get(ILogConfiguration.MDC_SERVICE_NAME)); + } + + @Test + public void validateFatalMessageIsLoggedWhenAllErrorSettingsProvided() { + when(logger.isErrorEnabled()).thenReturn(true); + commonLogger.fatal(EcompLoggerErrorCode.PERMISSION_ERROR, serviceName, targetEntity, message); + + verify(logger).error(any(Marker.class), captor.capture(), any(Object[].class)); + assertEquals(message, captor.getValue()); + assertEquals(String.valueOf(EcompLoggerErrorCode.PERMISSION_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE)); + assertEquals(LogLevel.FATAL.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY)); + assertEquals(targetEntity, MDC.get(ILogConfiguration.MDC_TARGET_ENTITY)); + assertEquals(serviceName, MDC.get(ILogConfiguration.MDC_SERVICE_NAME)); + } + + @Test + public void validateErrorMessageIsNotLoggedWhenErrorLevelIsDisabledEvenIfErrorSettingsProvided() { + commonLogger.error(EcompLoggerErrorCode.PERMISSION_ERROR, serviceName, targetEntity, message); + verify(logger, never()).error(any(Marker.class), any(String.class)); + } + + @Test + public void validateErrorLogWhenErrorSettingsProvidedPartially() { + when(logger.isErrorEnabled()).thenReturn(true); + commonLogger.error(message); + + verify(logger).error(any(Marker.class), eq(message), any(Object[].class)); + assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE)); + assertEquals(LogLevel.ERROR.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY)); + assertNull(MDC.get(ILogConfiguration.MDC_TARGET_ENTITY)); + assertEquals(LoggerError.defaultServiceName, MDC.get(ILogConfiguration.MDC_SERVICE_NAME)); + } + + @Test + public void errorMessageIsNotLoggedWhenErrorLevelIsDisabled() { + commonLogger.error(message); + verify(logger, times(0)).error(any(Marker.class), anyString()); + } + + @Test + public void traceMessageWithExceptionIsNotLoggedWhenTraceLevelIsDisabled() { + commonLogger.trace(message, new UnsupportedOperationException()); + verify(logger, times(0)).trace(any(Marker.class), anyString()); + } + + @Test + public void verifyInfoMessage() { + when(logger.isInfoEnabled()).thenReturn(true); + commonLogger.info("Text"); + assertEquals(LogLevel.INFO.name(), MDC.get(MDC_ERROR_CATEGORY)); + assertEquals(String.valueOf(EcompLoggerErrorCode.SUCCESS.getErrorCode()), MDC.get(MDC_ERROR_CODE)); + assertEquals(LoggerError.defaultServiceName, MDC.get(ILogConfiguration.MDC_SERVICE_NAME)); + } + + @Test + public void verifyWarnMessage() { + when(logger.isWarnEnabled()).thenReturn(true); + commonLogger.warn("Text"); + assertEquals(LogLevel.WARN.name(), MDC.get(MDC_ERROR_CATEGORY)); + assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(MDC_ERROR_CODE)); + assertEquals(LoggerError.defaultServiceName, MDC.get(ILogConfiguration.MDC_SERVICE_NAME)); + } + + @Test + public void validateErrorLogWithExceptionWhenErrorSettingsProvidedPartially() { + ThreadLocalsHolder.setUuid("uuid"); + final String logFieldsNotProvidedMsg = "mandatory parameters for ECOMP logging, missing fields: ServiceName PartnerName"; + when(logger.isWarnEnabled()).thenReturn(true); + commonLogger.warn(message, new NullPointerException(exceptionMsg)); + + //the expected warn message + verify(logger).warn(any(Marker.class), contains(message), any(Object[].class)); + assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE)); + assertEquals(LogLevel.WARN.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY)); + assertEquals("uuid", MDC.get(ILogConfiguration.MDC_KEY_REQUEST_ID)); + assertNull(MDC.get(ILogConfiguration.MDC_TARGET_ENTITY)); + assertEquals(LoggerError.defaultServiceName, MDC.get(ILogConfiguration.MDC_SERVICE_NAME)); + } + + + @Test + public void validateDebugLogWithException() { + final String msg = "Debug message"; + ThreadLocalsHolder.setUuid("uuid"); + when(logger.isDebugEnabled()).thenReturn(true); + commonLogger.debug(msg, new RuntimeException()); + + verify(logger).debug(any(Marker.class), eq(msg), any(RuntimeException.class)); + } + + @Test + public void validateTraceLogWithExceptionAndPartialParamsAndDebugLevelDisabled() { + final String msg = "Debug message"; + when(logger.isTraceEnabled()).thenReturn(true); + commonLogger.trace(msg, new RuntimeException()); + + verify(logger).trace(any(Marker.class), eq(msg), any(RuntimeException.class)); + } + + @Test + public void warnMessageWithParameterIsNotLoggedIfWarnLevelIsDisabled() { + commonLogger.warn("msg", "param"); + verify(logger, times(0)).warn(any(Marker.class), + anyString(), any(Object.class)); + } + + @Test + public void verifyMdcValuesAreStoredWhenAuditAndErrorLoggersAreInvokedSequentially() throws URISyntaxException { + final String uuid = "12345"; + final String message = "message"; + when(requestContext.getHeaderString(anyString())).thenReturn("ab2222"); + when(requestContext.getUriInfo()).thenReturn(uriInfo); + when(logger.isErrorEnabled()).thenReturn(true); + + URI uri = new URI("http:/abc.com/getId"); + when(uriInfo.getRequestUri()).thenReturn(uri); + when(uriInfo.getBaseUri()).thenReturn(uri); + when(statusType.getStatusCode()).thenReturn(200); + when(statusType.getReasonPhrase()).thenReturn("OK"); + LoggerSdcAudit audit = new LoggerSdcAudit(this.getClass()); + ThreadLocalsHolder.setUuid(uuid); + audit.startLog(requestContext); + audit.log("abc.log.com", requestContext, statusType, LogLevel.INFO, Severity.OK, message); + + commonLogger.error(message); + verify(logger).error(any(Marker.class), eq(message), any(Object[].class)); + assertEquals(uuid, MDC.get(MDC_KEY_REQUEST_ID)); + assertEquals("/", MDC.get(MDC_SERVICE_NAME)); + assertEquals(LogLevel.ERROR.name(), MDC.get(MDC_ERROR_CATEGORY)); + assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(MDC_ERROR_CODE)); + } + + @Test + public void verifyLoggerDoesNothingWhenTheLevelIsNotSet() { + if (commonLogger.isDebugEnabled()) { + commonLogger.debug("text"); + } + verify(logger, times(0)).debug(any(Marker.class), anyString(), eq((Object[])null)); + } + + @Test + public void verifyLoggerTraceMethodIsCalledWhenTheLevelIsSet() { + ThreadLocalsHolder.setUuid("1234"); + when(logger.isTraceEnabled()).thenReturn(true); + if (commonLogger.isTraceEnabled()) { + commonLogger.trace("text"); + } + verify(logger, times(1)).trace(any(Marker.class), anyString(), eq((Object[])null)); + } + + + @Test + public void verifyMdcValuesAreStoredWhenTraceLoggerIsInvokedAfterAuditStart() throws URISyntaxException { + final String uuid = "12345"; + final String message = "message"; + when(requestContext.getHeaderString(anyString())).thenReturn("ab2222"); + when(requestContext.getUriInfo()).thenReturn(uriInfo); + when(logger.isTraceEnabled()).thenReturn(true); + + URI uri = new URI("http:/abc.com/getId"); + when(uriInfo.getRequestUri()).thenReturn(uri); + when(uriInfo.getBaseUri()).thenReturn(uri); + LoggerSdcAudit audit = new LoggerSdcAudit(this.getClass()); + ThreadLocalsHolder.setUuid(uuid); + audit.startLog(requestContext); + + commonLogger.trace(message); + verify(logger).trace(any(Marker.class), captor.capture(), eq((Object[])null)); + assertEquals(message, captor.getValue()); + assertEquals(uuid, MDC.get(MDC_KEY_REQUEST_ID)); + } + + +} diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/monitoring/MonitoringEventTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/monitoring/MonitoringEventTest.java deleted file mode 100644 index 66f519197c..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/monitoring/MonitoringEventTest.java +++ /dev/null @@ -1,242 +0,0 @@ -package org.openecomp.sdc.common.monitoring; - -import org.junit.Test; - - -public class MonitoringEventTest { - - private MonitoringEvent createTestSubject() { - return new MonitoringEvent(); - } - - - @Test - public void testGetHostid() throws Exception { - MonitoringEvent testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getHostid(); - } - - - @Test - public void testSetHostid() throws Exception { - MonitoringEvent testSubject; - String hostid = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setHostid(hostid); - } - - - @Test - public void testGetHostcpu() throws Exception { - MonitoringEvent testSubject; - Long result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getHostcpu(); - } - - - @Test - public void testSetHostcpu() throws Exception { - MonitoringEvent testSubject; - Long hostcpu = null; - - // default test - testSubject = createTestSubject(); - testSubject.setHostcpu(hostcpu); - } - - - @Test - public void testGetHostmem() throws Exception { - MonitoringEvent testSubject; - Double result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getHostmem(); - } - - - @Test - public void testSetHostmem() throws Exception { - MonitoringEvent testSubject; - Double hostmem = null; - - // default test - testSubject = createTestSubject(); - testSubject.setHostmem(hostmem); - } - - - @Test - public void testGetHostdisk() throws Exception { - MonitoringEvent testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getHostdisk(); - } - - - @Test - public void testSetHostdisk() throws Exception { - MonitoringEvent testSubject; - String hostdisk = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setHostdisk(hostdisk); - } - - - @Test - public void testGetJvmid() throws Exception { - MonitoringEvent testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getJvmid(); - } - - - @Test - public void testSetJvmid() throws Exception { - MonitoringEvent testSubject; - String jvmid = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setJvmid(jvmid); - } - - - @Test - public void testGetJvmcpu() throws Exception { - MonitoringEvent testSubject; - Long result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getJvmcpu(); - } - - - @Test - public void testSetJvmcpu() throws Exception { - MonitoringEvent testSubject; - Long jvmcpu = null; - - // default test - testSubject = createTestSubject(); - testSubject.setJvmcpu(jvmcpu); - } - - - @Test - public void testGetJvmmem() throws Exception { - MonitoringEvent testSubject; - Long result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getJvmmem(); - } - - - @Test - public void testSetJvmmem() throws Exception { - MonitoringEvent testSubject; - Long jvmmem = null; - - // default test - testSubject = createTestSubject(); - testSubject.setJvmmem(jvmmem); - } - - - @Test - public void testGetJvmtnum() throws Exception { - MonitoringEvent testSubject; - Integer result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getJvmtnum(); - } - - - @Test - public void testSetJvmtnum() throws Exception { - MonitoringEvent testSubject; - Integer jvmtnum = 0; - - // default test - testSubject = createTestSubject(); - testSubject.setJvmtnum(jvmtnum); - } - - - @Test - public void testGetAppid() throws Exception { - MonitoringEvent testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getAppid(); - } - - - @Test - public void testSetAppid() throws Exception { - MonitoringEvent testSubject; - String appid = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setAppid(appid); - } - - - @Test - public void testGetAppstat() throws Exception { - MonitoringEvent testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getAppstat(); - } - - - @Test - public void testSetAppstat() throws Exception { - MonitoringEvent testSubject; - String appstat = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setAppstat(appstat); - } - - - @Test - public void testToString() throws Exception { - MonitoringEvent testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.toString(); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/rest/api/RestConfigurationInfoTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/rest/api/RestConfigurationInfoTest.java deleted file mode 100644 index efbb7d799d..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/rest/api/RestConfigurationInfoTest.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.openecomp.sdc.common.rest.api; - -import org.junit.Test; - - -public class RestConfigurationInfoTest { - - private RestConfigurationInfo createTestSubject() { - return new RestConfigurationInfo(); - } - - - @Test - public void testGetReadTimeoutInSec() throws Exception { - RestConfigurationInfo testSubject; - Integer result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getReadTimeoutInSec(); - } - - - @Test - public void testSetReadTimeoutInSec() throws Exception { - RestConfigurationInfo testSubject; - Integer readTimeoutInSec = 0; - - // default test - testSubject = createTestSubject(); - testSubject.setReadTimeoutInSec(readTimeoutInSec); - } - - - @Test - public void testGetIgnoreCertificate() throws Exception { - RestConfigurationInfo testSubject; - Boolean result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getIgnoreCertificate(); - } - - - @Test - public void testSetIgnoreCertificate() throws Exception { - RestConfigurationInfo testSubject; - Boolean ignoreCertificate = null; - - // default test - testSubject = createTestSubject(); - testSubject.setIgnoreCertificate(ignoreCertificate); - } - - - @Test - public void testGetConnectionPoolSize() throws Exception { - RestConfigurationInfo testSubject; - Integer result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getConnectionPoolSize(); - } - - - @Test - public void testSetConnectionPoolSize() throws Exception { - RestConfigurationInfo testSubject; - Integer connectionPoolSize = 0; - - // default test - testSubject = createTestSubject(); - testSubject.setConnectionPoolSize(connectionPoolSize); - } - - - @Test - public void testGetConnectTimeoutInSec() throws Exception { - RestConfigurationInfo testSubject; - Integer result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getConnectTimeoutInSec(); - } - - - @Test - public void testSetConnectTimeoutInSec() throws Exception { - RestConfigurationInfo testSubject; - Integer connectTimeoutInSec = 0; - - // default test - testSubject = createTestSubject(); - testSubject.setConnectTimeoutInSec(connectTimeoutInSec); - } - - - @Test - public void testToString() throws Exception { - RestConfigurationInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.toString(); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java index 8cab6b4ed4..51490a6827 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java @@ -20,15 +20,6 @@ package org.openecomp.sdc.common.test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import org.junit.Test; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.util.GeneralUtility; @@ -40,6 +31,13 @@ import org.slf4j.LoggerFactory; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.Yaml; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.*; + public class CommonUtilsTest { private static Logger log = LoggerFactory.getLogger(CommonUtilsTest.class.getName()); @@ -138,35 +136,35 @@ public class CommonUtilsTest { @Test public void testRemoveHtml() { - assertTrue("gooboo".equals(ValidationUtils.removeHtmlTags("<b>goo<b></b></b><b>boo</b>"))); - assertTrue("goo<boo".equals(ValidationUtils.removeHtmlTags("<b>goo<b></b><</b><b>boo</b>"))); - assertTrue("goo boo".equals(ValidationUtils.removeHtmlTags("goo boo"))); - assertTrue("goo# . boo12".equals(ValidationUtils.removeHtmlTags("goo# . boo12"))); + assertEquals("gooboo", ValidationUtils.removeHtmlTags("<b>goo<b></b></b><b>boo</b>")); + assertEquals("goo<boo", ValidationUtils.removeHtmlTags("<b>goo<b></b><</b><b>boo</b>")); + assertEquals("goo boo", ValidationUtils.removeHtmlTags("goo boo")); + assertEquals("goo# . boo12", ValidationUtils.removeHtmlTags("goo# . boo12")); } @Test public void testnormaliseWhitespace() { - assertTrue("goo boo".equals(ValidationUtils.normaliseWhitespace("goo boo"))); - assertTrue("goo boo ".equals(ValidationUtils.normaliseWhitespace("goo boo "))); - assertTrue("goo boo".equals(ValidationUtils.normaliseWhitespace("goo boo"))); + assertEquals("goo boo", ValidationUtils.normaliseWhitespace("goo boo")); + assertEquals("goo boo ", ValidationUtils.normaliseWhitespace("goo boo ")); + assertEquals("goo boo", ValidationUtils.normaliseWhitespace("goo boo")); } @Test public void teststripOctets() { - assertTrue("goo boo".equals(ValidationUtils.stripOctets("goo%1F boo"))); - assertTrue("goo boo ".equals(ValidationUtils.stripOctets("goo boo %1F"))); - assertTrue("goo boo".equals(ValidationUtils.stripOctets("%1Fgoo boo"))); + assertEquals("goo boo", ValidationUtils.stripOctets("goo%1F boo")); + assertEquals("goo boo ", ValidationUtils.stripOctets("goo boo %1F")); + assertEquals("goo boo", ValidationUtils.stripOctets("%1Fgoo boo")); } @Test public void testRemoveNoneUtf8Chars() { - assertTrue("goo boo".equals(ValidationUtils.removeNoneUtf8Chars("goo boo"))); - assertTrue("goo boo!!._".equals(ValidationUtils.removeNoneUtf8Chars("goo boo!!._"))); - assertTrue("goo boo".equals(ValidationUtils.removeNoneUtf8Chars("goo boo"))); - assertTrue("goo bo123o".equals(ValidationUtils.removeNoneUtf8Chars("goo bo123o"))); - assertTrue("goo bo123o".equals(ValidationUtils.removeNoneUtf8Chars("goo קקbo123oגכקק"))); - assertTrue("goo bo123o".equals(ValidationUtils.removeNoneUtf8Chars("goo bo1������23o"))); + assertEquals("goo boo", ValidationUtils.removeNoneUtf8Chars("goo boo")); + assertEquals("goo boo!!._", ValidationUtils.removeNoneUtf8Chars("goo boo!!._")); + assertEquals("goo boo", ValidationUtils.removeNoneUtf8Chars("goo boo")); + assertEquals("goo bo123o", ValidationUtils.removeNoneUtf8Chars("goo bo123o")); + assertEquals("goo bo123o", ValidationUtils.removeNoneUtf8Chars("goo קקbo123oגכקק")); + assertEquals("goo bo123o", ValidationUtils.removeNoneUtf8Chars("goo bo1������23o")); } @Test @@ -334,15 +332,15 @@ public class CommonUtilsTest { @Test public void normalizeFileNameTest() { - assertTrue("too.jpeg".equals(ValidationUtils.normalizeFileName("too.jpeg"))); - assertTrue("too..jpeg".equals(ValidationUtils.normalizeFileName("too..jpeg"))); - assertTrue("too..jpeg".equals(ValidationUtils.normalizeFileName("t*o:o..jpe<>g"))); - assertTrue("goo.too..jpeg".equals(ValidationUtils.normalizeFileName("goo.t*o:o..jpe<>g"))); - assertTrue("goo.too..jpeg".equals(ValidationUtils.normalizeFileName(" goo.t*o:o..jpe<>g "))); - assertTrue("goo-too-mo.jpeg".equals(ValidationUtils.normalizeFileName("goo too----mo.jpeg"))); - assertTrue("goo-too-mo.jpeg".equals(ValidationUtils.normalizeFileName(".\\..\\goo too----mo.jpeg"))); - assertTrue("goo-too-mo.jpeg".equals(ValidationUtils.normalizeFileName("__--goo too----mo.jpeg--__"))); - assertTrue("goo-too-mo.jpeg".equals(ValidationUtils.normalizeFileName("_ -goo too----mo.jpeg _-- _-"))); + assertEquals("too.jpeg", ValidationUtils.normalizeFileName("too.jpeg")); + assertEquals("too..jpeg", ValidationUtils.normalizeFileName("too..jpeg")); + assertEquals("too..jpeg", ValidationUtils.normalizeFileName("t*o:o..jpe<>g")); + assertEquals("goo.too..jpeg", ValidationUtils.normalizeFileName("goo.t*o:o..jpe<>g")); + assertEquals("goo.too..jpeg", ValidationUtils.normalizeFileName(" goo.t*o:o..jpe<>g ")); + assertEquals("goo-too-mo.jpeg", ValidationUtils.normalizeFileName("goo too----mo.jpeg")); + assertEquals("goo-too-mo.jpeg", ValidationUtils.normalizeFileName(".\\..\\goo too----mo.jpeg")); + assertEquals("goo-too-mo.jpeg", ValidationUtils.normalizeFileName("__--goo too----mo.jpeg--__")); + assertEquals("goo-too-mo.jpeg", ValidationUtils.normalizeFileName("_ -goo too----mo.jpeg _-- _-")); } @@ -466,7 +464,7 @@ public class CommonUtilsTest { options.setDefaultScalarStyle(DumperOptions.ScalarStyle.FOLDED); Yaml yaml = new Yaml(options); - Map<String, Object> parameters = new HashMap<String, Object>(); + Map<String, Object> parameters = new HashMap<>(); parameters.put("k1", "val"); parameters.put("k2", "\"val\""); diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/test/E2EHttpClientTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/test/E2EHttpClientTest.java index 9dbb146d5a..5617403de8 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/test/E2EHttpClientTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/test/E2EHttpClientTest.java @@ -1,10 +1,5 @@ package org.openecomp.sdc.common.test; -import java.net.MalformedURLException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - import org.junit.Ignore; import org.junit.Test; import org.openecomp.sdc.common.http.client.api.HttpExecuteException; @@ -13,6 +8,11 @@ import org.openecomp.sdc.common.http.client.api.HttpResponse; import org.openecomp.sdc.common.http.config.HttpClientConfig; import org.openecomp.sdc.common.http.config.Timeouts; +import java.net.MalformedURLException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + public class E2EHttpClientTest { @Ignore diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/test/TestExternalConfiguration.java b/common-app-api/src/test/java/org/openecomp/sdc/common/test/TestExternalConfiguration.java index d2ec093f39..839190b30f 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/test/TestExternalConfiguration.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/test/TestExternalConfiguration.java @@ -20,18 +20,8 @@ package org.openecomp.sdc.common.test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import org.junit.Before; import org.junit.Test; import org.openecomp.sdc.be.config.DistributionEngineConfiguration; @@ -46,6 +36,13 @@ import org.openecomp.sdc.common.test.config.TestNotExistConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.*; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class TestExternalConfiguration { private static Logger log = LoggerFactory.getLogger(TestExternalConfiguration.class.getName()); @@ -80,7 +77,7 @@ public class TestExternalConfiguration { TestConfiguration testConfiguration = configurationSource.getAndWatchConfiguration(TestConfiguration.class, configurationListener); - assertTrue(testConfiguration != null); + assertNotNull(testConfiguration); log.debug("{}", testConfiguration); assertEquals(testConfiguration.getBeHost(), "172.20.37.245"); assertEquals(testConfiguration.getBeProtocol(), "http"); @@ -104,7 +101,7 @@ public class TestExternalConfiguration { TestNotExistConfiguration testConfiguration = configurationSource .getAndWatchConfiguration(TestNotExistConfiguration.class, configurationListener); - assertTrue(testConfiguration == null); + assertNull(testConfiguration); } @@ -129,7 +126,7 @@ public class TestExternalConfiguration { TestConfiguration testConfiguration = configurationSource.getAndWatchConfiguration(TestConfiguration.class, configurationListener); - assertTrue(testConfiguration != null); + assertNotNull(testConfiguration); log.debug("{}", testConfiguration); assertEquals(testConfiguration.getBeHost(), "172.20.37.245"); assertEquals(testConfiguration.getBeProtocol(), "http"); @@ -157,7 +154,7 @@ public class TestExternalConfiguration { FileWriter fw = null; BufferedWriter out = null; try { - List<String> lines = new ArrayList<String>(); + List<String> lines = new ArrayList<>(); String line = null; fr = new FileReader(f1); br = new BufferedReader(fr); @@ -223,7 +220,7 @@ public class TestExternalConfiguration { DistributionEngineConfiguration deConfiguration = configurationSource .getAndWatchConfiguration(DistributionEngineConfiguration.class, configurationListener); - assertTrue(deConfiguration != null); + assertNotNull(deConfiguration); log.debug("{}", deConfiguration); assertEquals(deConfiguration.getDistributionNotifTopicName(), "ASDC-DISTR-NOTIF-TOPIC"); assertEquals(deConfiguration.getDistributionStatusTopicName(), "ASDC-DISTR-STATUS-TOPIC"); @@ -236,12 +233,12 @@ public class TestExternalConfiguration { assertEquals(deConfiguration.getEnvironments().size(), 1); assertEquals(deConfiguration.getEnvironments().iterator().next(), "PROD"); - assertEquals(deConfiguration.getDistribNotifResourceArtifactTypes().getInfo(), null); + assertNull(deConfiguration.getDistribNotifResourceArtifactTypes().getInfo()); assertEquals(deConfiguration.getDistribNotifResourceArtifactTypes().getLifecycle().size(), 2); assertTrue(deConfiguration.getDistribNotifResourceArtifactTypes().getLifecycle().contains("HEAT")); assertTrue(deConfiguration.getDistribNotifResourceArtifactTypes().getLifecycle().contains("DG_XML")); - assertEquals(deConfiguration.getDistribNotifServiceArtifactTypes().getLifecycle(), null); + assertNull(deConfiguration.getDistribNotifServiceArtifactTypes().getLifecycle()); assertEquals(deConfiguration.getDistribNotifServiceArtifactTypes().getInfo().size(), 1); assertTrue(deConfiguration.getDistribNotifServiceArtifactTypes().getInfo().contains("MURANO-PKG")); diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/test/YamlTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/test/YamlTest.java index 81e17849b1..78465fbac4 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/test/YamlTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/test/YamlTest.java @@ -20,14 +20,14 @@ package org.openecomp.sdc.common.test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import org.apache.commons.codec.binary.Base64; import org.junit.BeforeClass; import org.junit.Test; import org.openecomp.sdc.common.util.YamlToObjectConverter; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + public class YamlTest { private static YamlToObjectConverter yamlToObjectConverter; diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/test/config/TestConfiguration.java b/common-app-api/src/test/java/org/openecomp/sdc/common/test/config/TestConfiguration.java index f8acf549fa..5674441454 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/test/config/TestConfiguration.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/test/config/TestConfiguration.java @@ -20,13 +20,13 @@ package org.openecomp.sdc.common.test.config; -import static java.lang.String.format; +import org.openecomp.sdc.common.api.BasicConfiguration; import java.util.Date; import java.util.List; import java.util.Map; -import org.openecomp.sdc.common.api.BasicConfiguration; +import static java.lang.String.format; public class TestConfiguration extends BasicConfiguration { diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/test/config/TestNotExistConfiguration.java b/common-app-api/src/test/java/org/openecomp/sdc/common/test/config/TestNotExistConfiguration.java index 76f694f5b8..303532c772 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/test/config/TestNotExistConfiguration.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/test/config/TestNotExistConfiguration.java @@ -20,10 +20,10 @@ package org.openecomp.sdc.common.test.config; -import static java.lang.String.format; - import org.openecomp.sdc.common.api.BasicConfiguration; +import static java.lang.String.format; + public class TestNotExistConfiguration extends BasicConfiguration { /** diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/util/CapabilityTypeNameEnumTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/util/CapabilityTypeNameEnumTest.java deleted file mode 100644 index 67862928ce..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/util/CapabilityTypeNameEnumTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.openecomp.sdc.common.util; - -import org.junit.Test; - - -public class CapabilityTypeNameEnumTest { - - private CapabilityTypeNameEnum createTestSubject() { - return CapabilityTypeNameEnum.ATTACHMENT; - } - - - @Test - public void testGetCapabilityName() throws Exception { - CapabilityTypeNameEnum testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCapabilityName(); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/util/GeneralUtilityTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/util/GeneralUtilityTest.java deleted file mode 100644 index ebfffe572a..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/util/GeneralUtilityTest.java +++ /dev/null @@ -1,124 +0,0 @@ -package org.openecomp.sdc.common.util; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - - -public class GeneralUtilityTest { - - private GeneralUtility createTestSubject() { - return new GeneralUtility(); - } - - - @Test - public void testGenerateTextFile() throws Exception { - String fileName = ""; - String fileData = ""; - boolean result; - - // default test - result = GeneralUtility.generateTextFile(fileName, fileData); - } - - - @Test - public void testIsBase64Encoded() throws Exception { - byte[] data = new byte[] { ' ' }; - boolean result; - - // default test - result = GeneralUtility.isBase64Encoded(data); - } - - - @Test - public void testIsBase64Encoded_1() throws Exception { - String str = ""; - boolean result; - - // default test - result = GeneralUtility.isBase64Encoded(str); - } - - - @Test - public void testIsExceedingLimit() throws Exception { - String str = ""; - int limit = 0; - boolean result; - - // test 1 - str = null; - result = GeneralUtility.isExceedingLimit(str, limit); - Assert.assertEquals(false, result); - - // test 2 - str = ""; - result = GeneralUtility.isExceedingLimit(str, limit); - Assert.assertEquals(false, result); - } - - - @Test - public void testIsExceedingLimit_1() throws Exception { - List<String> strList = null; - int limit = 0; - int delimiterLength = 0; - boolean result; - - // test 1 - strList = null; - result = GeneralUtility.isExceedingLimit(strList, limit, delimiterLength); - Assert.assertEquals(false, result); - } - - - @Test - public void testGetFilenameExtension() throws Exception { - String fileName = ""; - String result; - - // test 1 - fileName = null; - result = GeneralUtility.getFilenameExtension(fileName); - Assert.assertEquals("", result); - - // test 2 - fileName = ""; - result = GeneralUtility.getFilenameExtension(fileName); - Assert.assertEquals("", result); - } - - - @Test - public void testCalculateMD5Base64EncodedByByteArray() throws Exception { - byte[] payload = new byte[] { ' ' }; - String result; - - // default test - result = GeneralUtility.calculateMD5Base64EncodedByByteArray(payload); - } - - - @Test - public void testCalculateMD5Base64EncodedByString() throws Exception { - String data = ""; - String result; - - // default test - result = GeneralUtility.calculateMD5Base64EncodedByString(data); - } - - - @Test - public void testIsEmptyString() throws Exception { - String str = ""; - boolean result; - - // default test - result = GeneralUtility.isEmptyString(str); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/util/GsonFactoryTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/util/GsonFactoryTest.java deleted file mode 100644 index 0840d27934..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/util/GsonFactoryTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.openecomp.sdc.common.util; - -import org.junit.Test; - -import com.google.gson.Gson; - - -public class GsonFactoryTest { - - private GsonFactory createTestSubject() { - return new GsonFactory(); - } - - - @Test - public void testGetGson() throws Exception { - Gson result; - - // default test - result = GsonFactory.getGson(); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/util/SerializationUtilsTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/util/SerializationUtilsTest.java index f403bca574..95394afc91 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/util/SerializationUtilsTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/util/SerializationUtilsTest.java @@ -1,10 +1,7 @@ package org.openecomp.sdc.common.util; -import javax.annotation.Generated; - -import org.junit.Test; - import fj.data.Either; +import org.junit.Test; public class SerializationUtilsTest { diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/util/StreamUtilsTests.java b/common-app-api/src/test/java/org/openecomp/sdc/common/util/StreamUtilsTests.java index deb9029e0d..5ee8f42b6b 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/util/StreamUtilsTests.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/util/StreamUtilsTests.java @@ -20,7 +20,9 @@ package org.openecomp.sdc.common.util; -import static org.junit.Assert.assertTrue; +import fj.data.Either; +import static org.junit.Assert.assertEquals; +import org.junit.Test; import java.util.ArrayList; import java.util.Arrays; @@ -29,16 +31,14 @@ import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.junit.Test; - -import fj.data.Either; +import static org.junit.Assert.assertTrue; public class StreamUtilsTests { @Test public void testTakeWhilePredicateNotMet() { List<Either<Integer, Boolean>> list = buildListWith10Integers(); - assertTrue(StreamUtils.takeWhile(list.stream(), p -> p.isLeft()).count() == 10); + assertEquals(10, StreamUtils.takeWhile(list.stream(), Either::isLeft).count()); } @Test @@ -46,8 +46,8 @@ public class StreamUtilsTests { List<Either<Integer, Boolean>> list = buildListWith10Integers(); addToBooleansToList(list); - final Stream<Either<Integer, Boolean>> takeWhileStream = StreamUtils.takeWhile(list.stream(), p -> p.isLeft()); - assertTrue(takeWhileStream.filter(p -> p.isRight()).count() == 0); + final Stream<Either<Integer, Boolean>> takeWhileStream = StreamUtils.takeWhile(list.stream(), Either::isLeft); + assertEquals(0, takeWhileStream.filter(Either::isRight).count()); } @Test @@ -67,12 +67,12 @@ public class StreamUtilsTests { }; List<Integer> num1to10 = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - Stream<Either<Integer, Boolean>> streamEithers = num1to10.stream().map(e -> cons.apply(e)); - List<Either<Integer, Boolean>> collect = StreamUtils.takeWhilePlusOneNoEval(streamEithers, e -> e.isLeft()) + Stream<Either<Integer, Boolean>> streamEithers = num1to10.stream().map(cons::apply); + List<Either<Integer, Boolean>> collect = StreamUtils.takeWhilePlusOneNoEval(streamEithers, Either::isLeft) .collect(Collectors.toList()); assertTrue(bucket.size() <= 6); assertTrue(collect.size() <= 6); - assertTrue(collect.stream().filter(e -> e.isRight()).count() == 1); + assertEquals(1, collect.stream().filter(Either::isRight).count()); } @@ -80,7 +80,7 @@ public class StreamUtilsTests { public void testTakeWhilePlusOnePredicateNotMet() { List<Either<Integer, Boolean>> list = buildListWith10Integers(); - assertTrue(StreamUtils.takeWhilePlusOne(list.stream(), p -> p.isLeft()).count() == 10); + assertEquals(10, StreamUtils.takeWhilePlusOne(list.stream(), Either::isLeft).count()); } @Test @@ -89,8 +89,8 @@ public class StreamUtilsTests { addToBooleansToList(list); final Stream<Either<Integer, Boolean>> takeWhilePlusOneStream = StreamUtils.takeWhilePlusOne(list.stream(), - p -> p.isLeft()); - assertTrue(takeWhilePlusOneStream.filter(p -> p.isRight()).count() == 1); + Either::isLeft); + assertEquals(1, takeWhilePlusOneStream.filter(Either::isRight).count()); } private void addToBooleansToList(List<Either<Integer, Boolean>> list) { @@ -108,15 +108,15 @@ public class StreamUtilsTests { @Test public void myTest() { - List<Integer> list = new ArrayList<Integer>(); + List<Integer> list = new ArrayList<>(); for (int i = 0; i < 10; i++) { list.add(i); } - List<Either<Integer, Boolean>> container = new ArrayList<Either<Integer, Boolean>>(); - list.stream().map(e -> myBusinessLogic(e, container)).filter(p -> p.isRight()).findAny(); + List<Either<Integer, Boolean>> container = new ArrayList<>(); + list.stream().map(e -> myBusinessLogic(e, container)).filter(Either::isRight).findAny(); // Actual Results are in container - assertTrue(container.size() == 6); + assertEquals(6, container.size()); } diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/util/ValidationUtilsTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/util/ValidationUtilsTest.java deleted file mode 100644 index 9b30039023..0000000000 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/util/ValidationUtilsTest.java +++ /dev/null @@ -1,603 +0,0 @@ -package org.openecomp.sdc.common.util; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - - -public class ValidationUtilsTest { - - private ValidationUtils createTestSubject() { - return new ValidationUtils(); - } - - - @Test - public void testValidateArtifactLabel() throws Exception { - String label = ""; - boolean result; - - // default test - result = ValidationUtils.validateArtifactLabel(label); - } - - - @Test - public void testValidateArtifactDisplayName() throws Exception { - String displayName = ""; - boolean result; - - // default test - result = ValidationUtils.validateArtifactDisplayName(displayName); - } - - - - - @Test - public void testNormalizeCategoryName4Display() throws Exception { - String str = ""; - String result; - - // test 1 - str = "123"; - result = ValidationUtils.normalizeCategoryName4Display(str); - Assert.assertEquals("123", result); - - // test 2 - str = "123#123"; - result = ValidationUtils.normalizeCategoryName4Display(str); - Assert.assertEquals("123#123", result); - } - - - @Test - public void testNormalizeCategoryName4Uniqueness() throws Exception { - String str = ""; - String result; - - // default test - result = ValidationUtils.normalizeCategoryName4Uniqueness(str); - } - - - @Test - public void testValidateCategoryDisplayNameLength() throws Exception { - String label = ""; - boolean result; - - // default test - result = ValidationUtils.validateCategoryDisplayNameLength(label); - } - - - @Test - public void testValidateProductFullNameLength() throws Exception { - String fullName = ""; - boolean result; - - // default test - result = ValidationUtils.validateProductFullNameLength(fullName); - } - - - @Test - public void testValidateArtifactLabelLength() throws Exception { - String label = ""; - boolean result; - - // default test - result = ValidationUtils.validateArtifactLabelLength(label); - } - - - @Test - public void testValidateResourceInstanceNameLength() throws Exception { - String resourceInstanceName = ""; - boolean result; - - // default test - result = ValidationUtils.validateResourceInstanceNameLength(resourceInstanceName); - } - - - @Test - public void testValidateResourceInstanceName() throws Exception { - String resourceInstanceName = ""; - boolean result; - - // default test - result = ValidationUtils.validateResourceInstanceName(resourceInstanceName); - } - - - @Test - public void testValidateUrlLength() throws Exception { - String url = ""; - boolean result; - - // default test - result = ValidationUtils.validateUrlLength(url); - } - - - @Test - public void testValidateArtifactNameLength() throws Exception { - String artifactName = ""; - boolean result; - - // default test - result = ValidationUtils.validateArtifactNameLength(artifactName); - } - - - @Test - public void testValidateComponentNamePattern() throws Exception { - String componentName = ""; - boolean result; - - // default test - result = ValidationUtils.validateComponentNamePattern(componentName); - } - - - @Test - public void testValidateComponentNameLength() throws Exception { - String componentName = ""; - boolean result; - - // default test - result = ValidationUtils.validateComponentNameLength(componentName); - } - - - @Test - public void testValidateIcon() throws Exception { - String icon = ""; - boolean result; - - // default test - result = ValidationUtils.validateIcon(icon); - } - - - @Test - public void testValidateIconLength() throws Exception { - String icon = ""; - boolean result; - - // default test - result = ValidationUtils.validateIconLength(icon); - } - - - @Test - public void testValidateProjectCode() throws Exception { - String projectCode = ""; - boolean result; - - // default test - result = ValidationUtils.validateProjectCode(projectCode); - } - - - @Test - public void testValidateProjectCodeLegth() throws Exception { - String projectCode = ""; - boolean result; - - // default test - result = ValidationUtils.validateProjectCodeLegth(projectCode); - } - - - @Test - public void testValidateContactId() throws Exception { - String contactId = ""; - boolean result; - - // default test - result = ValidationUtils.validateContactId(contactId); - } - - - @Test - public void testValidateCost() throws Exception { - String cost = ""; - boolean result; - - // default test - result = ValidationUtils.validateCost(cost); - } - - - @Test - public void testRemoveHtmlTags() throws Exception { - String str = ""; - String result; - - // default test - result = ValidationUtils.removeHtmlTags(str); - } - - - @Test - public void testRemoveAllTags() throws Exception { - String htmlText = ""; - String result; - - // default test - result = ValidationUtils.removeAllTags(htmlText); - } - - - @Test - public void testNormaliseWhitespace() throws Exception { - String str = ""; - String result; - - // default test - result = ValidationUtils.normaliseWhitespace(str); - } - - - @Test - public void testStripOctets() throws Exception { - String str = ""; - String result; - - // default test - result = ValidationUtils.stripOctets(str); - } - - - @Test - public void testRemoveNoneUtf8Chars() throws Exception { - String input = ""; - String result; - - // default test - result = ValidationUtils.removeNoneUtf8Chars(input); - } - - - @Test - public void testValidateIsEnglish() throws Exception { - String input = ""; - boolean result; - - // default test - result = ValidationUtils.validateIsEnglish(input); - } - - - @Test - public void testValidateIsAscii() throws Exception { - String input = ""; - boolean result; - - // default test - result = ValidationUtils.validateIsAscii(input); - } - - - @Test - public void testConvertHtmlTagsToEntities() throws Exception { - String input = ""; - String result; - - // default test - result = ValidationUtils.convertHtmlTagsToEntities(input); - } - - - - - - - - - @Test - public void testValidateTagListLength() throws Exception { - int tagListLength = 0; - boolean result; - - // default test - result = ValidationUtils.validateTagListLength(tagListLength); - } - - - @Test - public void testValidateDescriptionLength() throws Exception { - String description = ""; - boolean result; - - // default test - result = ValidationUtils.validateDescriptionLength(description); - } - - - @Test - public void testValidateStringNotEmpty() throws Exception { - String value = ""; - boolean result; - - // test 1 - value = null; - result = ValidationUtils.validateStringNotEmpty(value); - Assert.assertEquals(false, result); - - // test 2 - value = ""; - result = ValidationUtils.validateStringNotEmpty(value); - Assert.assertEquals(false, result); - } - - - @Test - public void testValidateListNotEmpty() throws Exception { - List<?> list = null; - boolean result; - - // test 1 - list = null; - result = ValidationUtils.validateListNotEmpty(list); - Assert.assertEquals(false, result); - } - - - @Test - public void testValidateVendorName() throws Exception { - String vendorName = ""; - boolean result; - - // default test - result = ValidationUtils.validateVendorName(vendorName); - } - - - @Test - public void testValidateVendorNameLength() throws Exception { - String vendorName = ""; - boolean result; - - // default test - result = ValidationUtils.validateVendorNameLength(vendorName); - } - - - @Test - public void testValidateResourceVendorModelNumberLength() throws Exception { - String resourceVendorModelNumber = ""; - boolean result; - - // default test - result = ValidationUtils.validateResourceVendorModelNumberLength(resourceVendorModelNumber); - } - - - @Test - public void testValidateVendorRelease() throws Exception { - String vendorRelease = ""; - boolean result; - - // default test - result = ValidationUtils.validateVendorRelease(vendorRelease); - } - - - @Test - public void testValidateVendorReleaseLength() throws Exception { - String vendorRelease = ""; - boolean result; - - // default test - result = ValidationUtils.validateVendorReleaseLength(vendorRelease); - } - - - @Test - public void testValidateServiceTypeLength() throws Exception { - String serviceType = ""; - boolean result; - - // default test - result = ValidationUtils.validateServiceTypeLength(serviceType); - } - - - @Test - public void testValidateServiceRoleLength() throws Exception { - String serviceRole = ""; - boolean result; - - // default test - result = ValidationUtils.validateServiceRoleLength(serviceRole); - } - - - @Test - public void testHasBeenCertified() throws Exception { - String version = ""; - boolean result; - - // default test - result = ValidationUtils.hasBeenCertified(version); - } - - - @Test - public void testNormaliseComponentName() throws Exception { - String name = ""; - String result; - - // default test - result = ValidationUtils.normaliseComponentName(name); - } - - - @Test - public void testNormalizeComponentInstanceName() throws Exception { - String name = ""; - String result; - - // default test - result = ValidationUtils.normalizeComponentInstanceName(name); - } - - - - - - @Test - public void testConvertToSystemName() throws Exception { - String name = ""; - String result; - - // default test - result = ValidationUtils.convertToSystemName(name); - } - - - @Test - public void testNormalizeFileName() throws Exception { - String filename = ""; - String result; - - // default test - result = ValidationUtils.normalizeFileName(filename); - } - - - - - - @Test - public void testValidateUrl() throws Exception { - String url = ""; - boolean result; - - // default test - result = ValidationUtils.validateUrl(url); - } - - - @Test - public void testCleanArtifactDisplayName() throws Exception { - String strIn = ""; - String result; - - // default test - result = ValidationUtils.cleanArtifactDisplayName(strIn); - } - - - @Test - public void testNormalizeArtifactLabel() throws Exception { - String strIn = ""; - String result; - - // default test - result = ValidationUtils.normalizeArtifactLabel(strIn); - } - - - @Test - public void testValidateAdditionalInformationKeyName() throws Exception { - String str = ""; - boolean result; - - // default test - result = ValidationUtils.validateAdditionalInformationKeyName(str); - } - - - - - - - - - @Test - public void testValidateConsumerName() throws Exception { - String consumerName = ""; - boolean result; - - // default test - result = ValidationUtils.validateConsumerName(consumerName); - } - - - @Test - public void testIsUTF8Str() throws Exception { - String str = ""; - boolean result; - - // default test - result = ValidationUtils.isUTF8Str(str); - } - - - @Test - public void testValidateConsumerPassSalt() throws Exception { - String consumerSalt = ""; - boolean result; - - // default test - result = ValidationUtils.validateConsumerPassSalt(consumerSalt); - } - - - @Test - public void testIsFloatNumber() throws Exception { - String number = ""; - boolean result; - - // default test - result = ValidationUtils.isFloatNumber(number); - } - - - @Test - public void testValidateCertifiedVersion() throws Exception { - String version = ""; - boolean result; - - // default test - result = ValidationUtils.validateCertifiedVersion(version); - } - - - @Test - public void testValidateMinorVersion() throws Exception { - String version = ""; - boolean result; - - // default test - result = ValidationUtils.validateMinorVersion(version); - } - - - @Test - public void testNormaliseProductName() throws Exception { - String name = ""; - String result; - - // default test - result = ValidationUtils.normaliseProductName(name); - } - - - - - - @Test - public void testRemoveHtmlTagsOnly() throws Exception { - String htmlText = ""; - String result; - - // default test - result = ValidationUtils.removeHtmlTagsOnly(htmlText); - } -}
\ No newline at end of file diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/util/ZipUtilTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/util/ZipUtilTest.java index 314208554d..b98fa08066 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/util/ZipUtilTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/util/ZipUtilTest.java @@ -1,12 +1,9 @@ package org.openecomp.sdc.common.util; -import java.util.Map; -import java.util.zip.ZipInputStream; - -import javax.annotation.Generated; - import org.junit.Test; +import java.util.Map; + public class ZipUtilTest { // private ZipUtil createTestSubject() { diff --git a/common-app-api/src/test/java/org/openecomp/sdc/exception/ResponseFormatTest.java b/common-app-api/src/test/java/org/openecomp/sdc/exception/ResponseFormatTest.java index ba6e14eff7..e1ec9eb040 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/exception/ResponseFormatTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/exception/ResponseFormatTest.java @@ -1,7 +1,5 @@ package org.openecomp.sdc.exception; -import javax.annotation.Generated; - import org.junit.Test; import org.openecomp.sdc.exception.ResponseFormat.RequestErrorWrapper; diff --git a/common-app-api/src/test/java/org/openecomp/sdc/fe/config/ConfigurationTest.java b/common-app-api/src/test/java/org/openecomp/sdc/fe/config/ConfigurationTest.java index 4afafaefd4..516fbf7909 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/fe/config/ConfigurationTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/fe/config/ConfigurationTest.java @@ -1,11 +1,11 @@ package org.openecomp.sdc.fe.config; -import java.util.Date; -import java.util.List; - import org.junit.Test; import org.openecomp.sdc.fe.config.Configuration.FeMonitoringConfig; +import java.util.Date; +import java.util.List; + public class ConfigurationTest { |