From 5ed13032ff4803aa27cd1f1986ba34037be9c479 Mon Sep 17 00:00:00 2001 From: Tomasz Golabek Date: Fri, 5 Apr 2019 14:46:13 +0200 Subject: Some unit tests for catalog-be Code coverage for some classes from catalog-be increased. Some refactor made if needed. Change-Id: I1b292cfbe4b0d2aa4fbe22871da3228aa434b823 Issue-ID: SDC-2220 Signed-off-by: Tomasz Golabek --- .../sdc/be/auditing/impl/AuditingManager.java | 12 +++++--- .../be/auditing/impl/ConfigurationProvider.java | 32 ++++++++++++++++++++++ .../sdc/config/CatalogBESpringConfig.java | 27 ++++++++++++++++++ 3 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/ConfigurationProvider.java (limited to 'catalog-be/src/main/java/org') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/AuditingManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/AuditingManager.java index f7c46b2eb9..4e2b85eeb6 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/AuditingManager.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/AuditingManager.java @@ -16,12 +16,13 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= + * Modifications copyright (c) 2019 Nokia + * ================================================================================ */ package org.openecomp.sdc.be.auditing.impl; import org.openecomp.sdc.be.auditing.api.AuditEventFactory; -import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao; import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; @@ -30,6 +31,7 @@ import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent; import org.openecomp.sdc.common.log.elements.LogFieldsMdcHandler; import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.common.log.wrappers.LoggerSdcAudit; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component @@ -39,15 +41,17 @@ public class AuditingManager { private final AuditingDao auditingDao; private final AuditCassandraDao cassandraDao; + private final ConfigurationProvider configurationProvider; - public AuditingManager(AuditingDao auditingDao, AuditCassandraDao cassandraDao) { + @Autowired + public AuditingManager(AuditingDao auditingDao, AuditCassandraDao cassandraDao, ConfigurationProvider configurationProvider) { this.auditingDao = auditingDao; this.cassandraDao = cassandraDao; + this.configurationProvider = configurationProvider; } - public String auditEvent(AuditEventFactory factory) { - if (ConfigurationManager.getConfigurationManager().getConfiguration().isDisableAudit()) { + if (configurationProvider.getConfiguration().isDisableAudit()) { return null; } String msg = factory.getLogMessage(); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/ConfigurationProvider.java b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/ConfigurationProvider.java new file mode 100644 index 0000000000..eea1b30e2d --- /dev/null +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/ConfigurationProvider.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.sdc.be.auditing.impl; + +import org.openecomp.sdc.be.config.Configuration; +import org.openecomp.sdc.be.config.ConfigurationManager; +import org.springframework.stereotype.Component; + +@Component("configurationProvider") +public class ConfigurationProvider { + + public Configuration getConfiguration() { + return ConfigurationManager.getConfigurationManager().getConfiguration(); + } +} diff --git a/catalog-be/src/main/java/org/openecomp/sdc/config/CatalogBESpringConfig.java b/catalog-be/src/main/java/org/openecomp/sdc/config/CatalogBESpringConfig.java index aa5cdac691..75f7154f18 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/config/CatalogBESpringConfig.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/config/CatalogBESpringConfig.java @@ -1,5 +1,27 @@ +/*- + * ============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========================================================= + * Modifications copyright (c) 2019 Nokia + * ================================================================================ + */ package org.openecomp.sdc.config; +import org.openecomp.sdc.be.auditing.impl.ConfigurationProvider; import org.openecomp.sdc.be.components.impl.ComponentLocker; import org.openecomp.sdc.be.components.impl.lock.ComponentLockAspect; import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic; @@ -41,6 +63,11 @@ public class CatalogBESpringConfig { return new LifecycleBusinessLogic(); } + @Bean(name = "configurationProvider") + public ConfigurationProvider configurationProvider() { + return new ConfigurationProvider(); + } + @Bean(name = "transactionManager") public TransactionManager transactionManager() { return new TransactionManager(); -- cgit 1.2.3-korg