diff options
author | Patrick Brady <pb071s@att.com> | 2017-06-01 10:45:37 -0700 |
---|---|---|
committer | Patrick Brady <pb071s@att.com> | 2017-06-02 13:05:15 -0700 |
commit | c7d0075d223eab9f89fd28853c4b138792059be9 (patch) | |
tree | 40aa3e41e598ea7a59bcf6899a2004c1abab11c2 /appc-common/src | |
parent | 8aac2df744820304ee29354333661699e9695939 (diff) |
Merge of new rebased code
Change-Id: I9b8d1f69eb3e0af1935ed8304fea4bf54c1aac47
Signed-off-by: Patrick Brady <pb071s@att.com>
Diffstat (limited to 'appc-common/src')
19 files changed, 971 insertions, 33 deletions
diff --git a/appc-common/src/main/java/org/openecomp/appc/Constants.java b/appc-common/src/main/java/org/openecomp/appc/Constants.java index bd72acfcf..7ddf38d03 100644 --- a/appc-common/src/main/java/org/openecomp/appc/Constants.java +++ b/appc-common/src/main/java/org/openecomp/appc/Constants.java @@ -50,9 +50,15 @@ public final class Constants { @SuppressWarnings("nls") public static final String ATTRIBUTE_ERROR_MESSAGE = "error-message"; - public static final String DG_OUTPUT_STATUS_MESSAGE = "output.status.message"; + /** + * The name for the success message attribute to be set in the context + */ + @SuppressWarnings("nls") + public static final String ATTRIBUTE_SUCCESS_MESSAGE = "success-message"; public static final String DG_ATTRIBUTE_STATUS = "SvcLogic.status"; + public static final String DG_OUTPUT_STATUS_CODE = "output.status.code"; + public static final String DG_OUTPUT_STATUS_MESSAGE = "output.status.message"; /** * The property that defines the name of the DG service logic to be loaded @@ -156,20 +162,12 @@ public final class Constants { */ public static final String PROPERTY_STACK_STATE_CHANGE_TIMEOUT ="org.openecomp.appc.stack.state.change.timeout" ; - /** - * Private default constructor prevents instantiation - */ - @SuppressWarnings("nls") public static final String STATUS_GETTER = "status-getter"; - - - @SuppressWarnings("nls") public static final String VM_FUSION_STATUS_GETTER = "fusion-vm-status-getter"; - /** * The name for the status vm attribute to be set in the context when executing a vmstatuscheck. */ @@ -177,6 +175,34 @@ public final class Constants { @SuppressWarnings("nls") public static final String STATUS_OF_VM = "status-vm"; + /** + * Yang revision value to be used while generating YANG module + */ + public static final String YANG_REVISION = "2017-03-03"; + /** + * Yang revision format to be used while formatting YANG revision date + */ + public static final String YANG_REVISION_FORMAT = "YYYY-MM-DD"; + + /** + * Base container for yang that is generated to store in MD-SAL datastore + */ + public static final String YANG_BASE_CONTAINER = "vnf-config-repo"; + + /** + *VNF config list for yang that is generated to store in MD-SAL datastore + */ + public static final String YANG_VNF_CONFIG_LIST = "vnf-config-list"; + + /** + *Base container of VNF configuration data for yang that is generated to store in MD-SAL datastore + */ + public static final String YANG_VNF_CONFIG = "vnf-config"; + + /** + * Private default constructor prevents instantiation + */ + private Constants() { } diff --git a/appc-common/src/main/java/org/openecomp/appc/cache/CacheStrategies.java b/appc-common/src/main/java/org/openecomp/appc/cache/CacheStrategies.java new file mode 100644 index 000000000..780dbc59b --- /dev/null +++ b/appc-common/src/main/java/org/openecomp/appc/cache/CacheStrategies.java @@ -0,0 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : APP-C + * ================================================================================ + * 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.appc.cache; + + +public enum CacheStrategies { + LRU; +} diff --git a/appc-common/src/main/java/org/openecomp/appc/cache/CacheStrategy.java b/appc-common/src/main/java/org/openecomp/appc/cache/CacheStrategy.java new file mode 100644 index 000000000..c269ad231 --- /dev/null +++ b/appc-common/src/main/java/org/openecomp/appc/cache/CacheStrategy.java @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : APP-C + * ================================================================================ + * 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.appc.cache; + + +public interface CacheStrategy <K,V>{ + V getObject(K key); + void putObject(K key,V value); +} diff --git a/appc-common/src/main/java/org/openecomp/appc/cache/MetadataCache.java b/appc-common/src/main/java/org/openecomp/appc/cache/MetadataCache.java new file mode 100644 index 000000000..db5915bcf --- /dev/null +++ b/appc-common/src/main/java/org/openecomp/appc/cache/MetadataCache.java @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : APP-C + * ================================================================================ + * 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.appc.cache; + + +public interface MetadataCache <K,V>{ + V getObject(K key); + void putObject(K key,V value); +} diff --git a/appc-common/src/main/java/org/openecomp/appc/cache/impl/LRUCache.java b/appc-common/src/main/java/org/openecomp/appc/cache/impl/LRUCache.java new file mode 100644 index 000000000..0e8ba7308 --- /dev/null +++ b/appc-common/src/main/java/org/openecomp/appc/cache/impl/LRUCache.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : APP-C + * ================================================================================ + * 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.appc.cache.impl; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.openecomp.appc.cache.CacheStrategy; + +public class LRUCache<K,V> implements CacheStrategy<K,V> { + + private Map<K,V> map; + + LRUCache(final Integer capacity){ + map = new LinkedHashMap<K,V>(capacity, 0.75F, true){ + @Override + protected boolean removeEldestEntry(Map.Entry<K, V> eldest){ + return size() > capacity; + } + }; + } + + @Override + public V getObject(K key) { + return map.get(key); + } + + @Override + public void putObject(K key, V value) { + map.put(key,value); + } +} diff --git a/appc-common/src/main/java/org/openecomp/appc/cache/impl/MetadataCacheFactory.java b/appc-common/src/main/java/org/openecomp/appc/cache/impl/MetadataCacheFactory.java new file mode 100644 index 000000000..358b3bfd5 --- /dev/null +++ b/appc-common/src/main/java/org/openecomp/appc/cache/impl/MetadataCacheFactory.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : APP-C + * ================================================================================ + * 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.appc.cache.impl; + +import org.openecomp.appc.cache.CacheStrategies; +import org.openecomp.appc.cache.CacheStrategy; +import org.openecomp.appc.cache.MetadataCache; + +public class MetadataCacheFactory { + + private static class ReferenceHolder{ + private static final MetadataCacheFactory FACTORY = new MetadataCacheFactory(); + } + private MetadataCacheFactory(){ + + } + + public static MetadataCacheFactory getInstance(){ + return ReferenceHolder.FACTORY; + } + + public MetadataCache getMetadataCache(){ + return new MetadataCacheImpl(); + } + public MetadataCache getMetadataCache(CacheStrategies cacheStrategy){ + return new MetadataCacheImpl(cacheStrategy); + } + + + +} diff --git a/appc-common/src/main/java/org/openecomp/appc/cache/impl/MetadataCacheImpl.java b/appc-common/src/main/java/org/openecomp/appc/cache/impl/MetadataCacheImpl.java new file mode 100644 index 000000000..e54de8781 --- /dev/null +++ b/appc-common/src/main/java/org/openecomp/appc/cache/impl/MetadataCacheImpl.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : APP-C + * ================================================================================ + * 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.appc.cache.impl; + +import org.openecomp.appc.cache.CacheStrategies; +import org.openecomp.appc.cache.CacheStrategy; +import org.openecomp.appc.cache.MetadataCache; + + +public class MetadataCacheImpl<K,V> implements MetadataCache<K,V> { + + private CacheStrategy strategy; + + MetadataCacheImpl(){ + this(CacheStrategies.LRU); + } + + MetadataCacheImpl(CacheStrategies strategy){ + this.strategy = initializeStrategy(strategy); + } + + private CacheStrategy initializeStrategy(CacheStrategies strategy) { + switch (strategy){ + case LRU: + return new LRUCache<>(50); + } + return null; + } + + @Override + public V getObject(K key) { + return (V)strategy.getObject(key); + } + + @Override + public void putObject(K key, V value) { + strategy.putObject(key,value); + } +} diff --git a/appc-common/src/main/java/org/openecomp/appc/configuration/Configuration.java b/appc-common/src/main/java/org/openecomp/appc/configuration/Configuration.java index f64129011..d93b7588e 100644 --- a/appc-common/src/main/java/org/openecomp/appc/configuration/Configuration.java +++ b/appc-common/src/main/java/org/openecomp/appc/configuration/Configuration.java @@ -37,10 +37,10 @@ import org.slf4j.Logger; */ public interface Configuration { - String PROPERTY_BOOTSTRAP_FILE_NAME = "org.openecomp.appc.bootstrap.file"; + String PROPERTY_BOOTSTRAP_FILE_NAME = "org_openecomp_appc_bootstrap_file"; // String DEFAULT_BOOTSTRAP_FILE_NAME = "appc.properties"; - String PROPERTY_BOOTSTRAP_FILE_PATH = "org.openecomp.appc.bootstrap.path"; - String DEFAULT_BOOTSTRAP_FILE_PATH = "${user.home},etc,../etc"; + String PROPERTY_BOOTSTRAP_FILE_PATH = "org_openecomp_appc_bootstrap_path"; // + String DEFAULT_BOOTSTRAP_FILE_PATH = "/opt/openecomp/appc/data/properties,${user.home},etc,../etc"; String PROPERTY_RESOURCE_BUNDLES = "org.openecomp.appc.resources"; String DEFAULT_RESOURCE_BUNDLES = "org/openecomp/appc/i18n/MessageResources"; diff --git a/appc-common/src/main/java/org/openecomp/appc/configuration/ConfigurationFactory.java b/appc-common/src/main/java/org/openecomp/appc/configuration/ConfigurationFactory.java index bbfd90de1..17a356745 100644 --- a/appc-common/src/main/java/org/openecomp/appc/configuration/ConfigurationFactory.java +++ b/appc-common/src/main/java/org/openecomp/appc/configuration/ConfigurationFactory.java @@ -113,7 +113,7 @@ public final class ConfigurationFactory { /** * The default properties resource to be loaded */ - private static final String DEFAULT_PROPERTIES = "org/openecomp/appc/default.properties"; + private static final String DEFAULT_PROPERTIES = "/opt/openecomp/appc/data/properties/appc.properties"; /** * This collection allows for special configurations to be created and maintained, organized by some identification diff --git a/appc-common/src/main/java/org/openecomp/appc/configuration/package.html b/appc-common/src/main/java/org/openecomp/appc/configuration/package.html index 4460a9e5c..5991f91b5 100644 --- a/appc-common/src/main/java/org/openecomp/appc/configuration/package.html +++ b/appc-common/src/main/java/org/openecomp/appc/configuration/package.html @@ -168,3 +168,4 @@ </p> </body> </html> +>>>>>>> app-controller/master:appc-common/src/main/java/org/openecomp/appc/configuration/package.html diff --git a/appc-common/src/main/java/org/openecomp/appc/i18n/Msg.java b/appc-common/src/main/java/org/openecomp/appc/i18n/Msg.java index 3e4237258..21f088323 100644 --- a/appc-common/src/main/java/org/openecomp/appc/i18n/Msg.java +++ b/appc-common/src/main/java/org/openecomp/appc/i18n/Msg.java @@ -254,6 +254,11 @@ public enum Msg implements EELFResolvableErrorEnum { SNAPSHOTING_SERVER, /** + * {0} IAAS Adapter look for server requested + */ + LOOKING_SERVER_UP, + + /** * {0} IAAS Adapter cannot perform requested service, VM url '{1}' is invalid */ INVALID_SELF_LINK_URL, @@ -320,6 +325,11 @@ public enum Msg implements EELFResolvableErrorEnum { UNPAUSE_SERVER, /** + * Server {0} is being rebuilt... + */ + REBUILD_SERVER, + + /** * Connection to provider {0} at identity {1} using tenant name {2} (id {3}) failed, reason={4}, retrying in {5} * seconds, attempt {6} of {7}. */ @@ -336,6 +346,11 @@ public enum Msg implements EELFResolvableErrorEnum { STOPPING_SERVER, /** + * {0} IAAS Adapter start server requested + */ + STARTING_SERVER, + + /** * Server {0} (id {1}) failed to rebuild, reason {2} */ REBUILD_SERVER_FAILED, @@ -391,6 +406,11 @@ public enum Msg implements EELFResolvableErrorEnum { * Server {0} (id {1}) failed to evacuate, reason {2} */ EVACUATE_SERVER_FAILED, + + /** + * Server {0} evacuate from host {1} to host {2} failed during the rebuild on host {2}, reason {3} + */ + EVACUATE_SERVER_REBUILD_FAILED, /** * APP-C instance is too busy @@ -465,6 +485,11 @@ public enum Msg implements EELFResolvableErrorEnum { AAI_DELETE_FAILED, /** + * APP-C is unable to query AAI for VNF_ID {0} + */ + AAI_QUERY_FAILED, + + /** * VNF {0} is configured */ VNF_CONFIGURED, @@ -495,6 +520,21 @@ public enum Msg implements EELFResolvableErrorEnum { VNF_TEST_FAILED, /** + * VNF {0} test failed for reason {1} + */ + VNF_NOT_FOUND, + + /** + * VNF {0} Healthcheck operation failed for reason {1} + */ + VNF_HEALTHCECK_FAILED, + + /** + * VM {0} Healthcheck operation failed for reason {1} + */ + VM_HEALTHCECK_FAILED, + + /** * Server {0} (id {1}) failed to stop during {2} phase, reason {3} */ STOP_SERVER_FAILED, @@ -568,7 +608,7 @@ public enum Msg implements EELFResolvableErrorEnum { CLOSE_CONTEXT_FAILED, /** - * Stack {0} is being snapshoted... + * {0} IAAS Adapter snapshoting stack */ SNAPSHOTING_STACK, @@ -578,7 +618,7 @@ public enum Msg implements EELFResolvableErrorEnum { STACK_SNAPSHOTED, /** - * Stack {0} is being restored to snapshot {1}... + * {0} IAAS Adapter restoring stack */ RESTORING_STACK, @@ -588,6 +628,11 @@ public enum Msg implements EELFResolvableErrorEnum { STACK_RESTORED, /** + * {0} IAAS Adapter checking server + */ + CHECKING_SERVER, + + /** * Parameter {0} is missing in svc request of {1}. */ MISSING_PARAMETER_IN_REQUEST, @@ -601,8 +646,128 @@ public enum Msg implements EELFResolvableErrorEnum { * Operation '{0}' for VNF type '{1}' from Source '{2}' with RequestID '{3}' on '{4}' with action '{5}' * ended in {6}ms with result '{7}' */ - APPC_METRIC_MSG; + APPC_METRIC_MSG, + + /** + * Parsing failied for{0} + */ + INPUT_PAYLOAD_PARSING_FAILED, + + /** + * Error occurred for due to {0} + */ + APPC_EXCEPTION, + + /** + * SSH Data Exception occurred due to {0} + */ + SSH_DATA_EXCEPTION, + + /** + * Json processing exception occurred due to {0} + */ + JSON_PROCESSING_EXCEPTION, + + /** + * Operation {0} succeed for {1} + */ + SUCCESS_EVENT_MESSAGE, + + /** + * Dependency model not found for VNF type {0} due to {1} + */ + DEPENDENCY_MODEL_NOT_FOUND, + + /** + * Invalid Dependency model for VNF Type {0} due to {1} + */ + INVALID_DEPENDENCY_MODEL, + + /** + * Failed to retrieve VNFC DG + */ + FAILURE_RETRIEVE_VNFC_DG, + + /** + * Network check for Server {0} failed for Port {1} + * + */ + SERVER_NETWORK_ERROR, + + /** + * Hypervisor check for Server {0} failed. Status is DOWN or UNKNOWN + * + */ + HYPERVISOR_DOWN_ERROR, + + /** + * Hypervisor Network check for Server {0} failed. Not reachable by APPC + * + */ + HYPERVISOR_NETWORK_ERROR, + + /** + * Restart application operation failed on server : {0}, reason {1} + */ + APPLICATION_RESTART_FAILED, + + /** + * Start application operation failed on server : {0}, reason {1} + */ + APPLICATION_START_FAILED, + + /** + * Start application operation failed on server : {0}, reason {1} + */ + APPLICATION_STOP_FAILED, + + /** + * Application on server {0} is being restarted... + */ + RESTART_APPLICATION, + + /** + * Application on server {0} is being started... + */ + START_APPLICATION, + + /** + * Application on server {0} is being started... + */ + STOP_APPLICATION, + + /** + * APPC LCM operations are disabled + */ + LCM_OPERATIONS_DISABLED, + + /** + * Application {0} received exception {1} while attempting to execute oam operation {2}, exception message = {3}|\ + */ + OAM_OPERATION_EXCEPTION, + + /** + * Application {0} is stopping... Waiting for {1} LCM request to complete + */ + OAM_OPERATION_STOPPING, + + /** + * Application {0} is stopped + */ + OAM_OPERATION_STOPPED, + + + /** + * Application {0} is started + */ + OAM_OPERATION_STARTING, + + /** + * Application {0} is started + */ + OAM_OPERATION_STARTED, + ; /** * Static initializer to ensure the resource bundles for this class are loaded... */ diff --git a/appc-common/src/main/java/org/openecomp/appc/logging/LoggingConstants.java b/appc-common/src/main/java/org/openecomp/appc/logging/LoggingConstants.java index dcc797138..2a600978f 100644 --- a/appc-common/src/main/java/org/openecomp/appc/logging/LoggingConstants.java +++ b/appc-common/src/main/java/org/openecomp/appc/logging/LoggingConstants.java @@ -51,6 +51,7 @@ public class LoggingConstants { public static final String AAI = "A&AI"; public static final String DB = "DataBase"; public static final String APPC_PROVIDER = "APPC Provider"; + public static final String APPC_OAM_PROVIDER = "APPC OAM Provider"; public static final String STATE_MACHINE = "StateMachine"; public static final String WORKFLOW_MANAGER = "WorkflowManager"; public static final String REQUEST_VALIDATOR = "RequestValidator"; diff --git a/appc-common/src/main/java/org/openecomp/appc/logging/LoggingUtils.java b/appc-common/src/main/java/org/openecomp/appc/logging/LoggingUtils.java index c186a4afa..6ff192b20 100644 --- a/appc-common/src/main/java/org/openecomp/appc/logging/LoggingUtils.java +++ b/appc-common/src/main/java/org/openecomp/appc/logging/LoggingUtils.java @@ -21,6 +21,13 @@ package org.openecomp.appc.logging; +import org.openecomp.appc.i18n.Msg; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.att.eelf.i18n.EELFResolvableErrorEnum; +import com.att.eelf.i18n.EELFResourceManager; +import org.slf4j.MDC; + import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID; import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME; @@ -31,13 +38,6 @@ import java.time.temporal.ChronoUnit; import java.util.Date; import java.util.TimeZone; -import org.openecomp.appc.i18n.Msg; -import org.slf4j.MDC; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.att.eelf.i18n.EELFResourceManager; - public class LoggingUtils { @@ -77,6 +77,20 @@ public class LoggingUtils { cleanAuditErrorContext(); } + public static void auditInfo(Instant beginTimeStamp, Instant endTimeStamp, String code, String responseDescription, String className,EELFResolvableErrorEnum resourceId, String... arguments) { + populateAuditLogContext(beginTimeStamp, endTimeStamp, code, responseDescription, className); + auditLogger.info(resourceId,arguments); + cleanAuditErrorContext(); + } + + public static void auditWarn(Instant beginTimeStamp, Instant endTimeStamp, String code, String responseDescription, String className,EELFResolvableErrorEnum resourceId, String... arguments) { + populateAuditLogContext(beginTimeStamp, endTimeStamp, code, responseDescription, className); + auditLogger.warn(resourceId,arguments); + cleanAuditErrorContext(); + } + + + public static void logMetricsMessage(Instant beginTimeStamp, Instant endTimeStamp, String targetEntity, String targetServiceName, String statusCode, String responseCode, String responseDescription, String className) { populateMetricLogContext(beginTimeStamp, endTimeStamp, targetEntity, targetServiceName, statusCode, responseCode, responseDescription, className); metricLogger.info(EELFResourceManager.format(Msg.APPC_METRIC_MSG, diff --git a/appc-common/src/main/java/org/openecomp/appc/metadata/MetadataService.java b/appc-common/src/main/java/org/openecomp/appc/metadata/MetadataService.java new file mode 100644 index 000000000..f8b54c717 --- /dev/null +++ b/appc-common/src/main/java/org/openecomp/appc/metadata/MetadataService.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : APP-C + * ================================================================================ + * 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.appc.metadata; + +import org.openecomp.appc.metadata.objects.DependencyModelIdentifier; + + +public interface MetadataService { + String getVnfModel(DependencyModelIdentifier modelIdentifier); +} diff --git a/appc-common/src/main/java/org/openecomp/appc/metadata/impl/MetadataServiceImpl.java b/appc-common/src/main/java/org/openecomp/appc/metadata/impl/MetadataServiceImpl.java new file mode 100644 index 000000000..fb393aa74 --- /dev/null +++ b/appc-common/src/main/java/org/openecomp/appc/metadata/impl/MetadataServiceImpl.java @@ -0,0 +1,113 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : APP-C + * ================================================================================ + * 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.appc.metadata.impl; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.openecomp.sdnc.sli.resource.dblib.DbLibService; + +import javax.sql.rowset.CachedRowSet; + +import org.openecomp.appc.cache.MetadataCache; +import org.openecomp.appc.cache.impl.MetadataCacheFactory; +import org.openecomp.appc.metadata.MetadataService; +import org.openecomp.appc.metadata.objects.DependencyModelIdentifier; + +import java.sql.SQLException; +import java.util.ArrayList; + + +public class MetadataServiceImpl implements MetadataService { + + private DbLibService dbLibService; + + private static final EELFLogger logger = EELFManager.getInstance().getLogger(MetadataServiceImpl.class); + + private MetadataCache<DependencyModelIdentifier,String> cache; + + public MetadataServiceImpl(){ + initialize(); + } + + private void initialize(){ + cache = MetadataCacheFactory.getInstance().getMetadataCache(); + // TODO initialze dbLibService + } + + public void setDbLibService(DbLibService dbLibService) { + this.dbLibService = dbLibService; + } + + @Override + public String getVnfModel(DependencyModelIdentifier modelIdentifier) { + logger.debug("Reading Vnf Model data from cache for vnfType : "+ modelIdentifier.getVnfType() +" and catalog version : " +modelIdentifier.getCatalogVersion()); + String vnfModel = cache.getObject(modelIdentifier); + if(vnfModel ==null || vnfModel.length() ==0){ + logger.debug("Vnf Model not available in cache. Reading from database."); + vnfModel = readVnfModel(modelIdentifier); + if(vnfModel !=null && vnfModel.length()>0){ + logger.debug("Adding retrieved Vnf Model to cache."); + addVnfModel(modelIdentifier,vnfModel); + } + } + return vnfModel; + } + + private void addVnfModel(DependencyModelIdentifier modelIdentifier, String vnfModel) { + cache.putObject(modelIdentifier,vnfModel); + } + + private String readVnfModel(DependencyModelIdentifier modelIdentifier) { + + logger.debug("Reading Vnf Model data from database for RESOURCE_NAME : "+ modelIdentifier.getVnfType() +" and RESOURCE_VERSION : " +modelIdentifier.getCatalogVersion()); + StringBuilder query = new StringBuilder(); + String vnfModel =null; + query.append("SELECT ARTIFACT_CONTENT FROM sdnctl.ASDC_ARTIFACTS WHERE RESOURCE_NAME = ? ") ; + ArrayList<String> argList = new ArrayList<>(); + argList.add(modelIdentifier.getVnfType()); + + if (modelIdentifier.getCatalogVersion()==null){ + query.append(" ORDER BY SUBSTRING_INDEX(RESOURCE_VERSION, '.', 1)*1 DESC , " + + "SUBSTRING_INDEX(SUBSTRING_INDEX(RESOURCE_VERSION, '.', 2),'.', -1) *1 DESC , " + + "SUBSTRING_INDEX(RESOURCE_VERSION, '.', -1)*1 DESC ;"); + }else{ + query.append("AND RESOURCE_VERSION = ? ;"); + argList.add(modelIdentifier.getCatalogVersion()); + } + try { + final CachedRowSet data = dbLibService.getData(query.toString(), argList, "sdnctl"); + if (data.first()) { + vnfModel = data.getString("ARTIFACT_CONTENT"); + if (vnfModel == null || vnfModel.isEmpty()) { + logger.error("Invalid dependency model for vnf type : "+ modelIdentifier.getVnfType() +" and catalog version : " +modelIdentifier.getCatalogVersion()); + throw new RuntimeException("Invalid or Empty VNF Model"); + } + logger.debug("Retrieved Vnf Model : " + vnfModel); + }else { + logger.warn("VNF Model not found in datastore for RESOURCE_NAME : "+ modelIdentifier.getVnfType() +" AND RESOURCE_VERSION : " +modelIdentifier.getCatalogVersion()); + } + } catch (SQLException e) { + throw new RuntimeException("Database error occurred"); + } + return vnfModel; + } +} diff --git a/appc-common/src/main/java/org/openecomp/appc/metadata/objects/DependencyModelIdentifier.java b/appc-common/src/main/java/org/openecomp/appc/metadata/objects/DependencyModelIdentifier.java new file mode 100644 index 000000000..e3c82487e --- /dev/null +++ b/appc-common/src/main/java/org/openecomp/appc/metadata/objects/DependencyModelIdentifier.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : APP-C + * ================================================================================ + * 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.appc.metadata.objects; + + +public class DependencyModelIdentifier { + private String vnfType; + private String catalogVersion; + + public DependencyModelIdentifier(String vnfType, String catalogVersion){ + this.vnfType = vnfType; + this.catalogVersion = catalogVersion; + } + + public int hashCode(){ + final int prime = 31; + int result = 1; + result = result * prime + (this.vnfType == null ? 0 :this.vnfType.hashCode()); + result = result * prime + (this.catalogVersion == null ? 0 :this.catalogVersion.hashCode()); + return result; + } + + public boolean equals(Object obj){ + if(obj ==null) + return false; + if(!(obj instanceof DependencyModelIdentifier)) + return false; + + DependencyModelIdentifier modelIdentifier = (DependencyModelIdentifier)obj; + if(this.vnfType == null){ + if(modelIdentifier.vnfType !=null) + return false; + } + else if(!this.vnfType.equals(modelIdentifier.vnfType)) + return false; + + if(this.catalogVersion == null){ + if(modelIdentifier.catalogVersion !=null) + return false; + } + else if(!this.catalogVersion.equals(modelIdentifier.catalogVersion)) + return false; + + return true; + } + + @Override + public String toString() { + return "DependencyModelIdentifier : vnfType = "+vnfType + " , catalogVersion = " +catalogVersion; + } + + public String getVnfType() { + return vnfType; + } + + public String getCatalogVersion() { + return catalogVersion; + } + +} diff --git a/appc-common/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/appc-common/src/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 000000000..4d66c908c --- /dev/null +++ b/appc-common/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ============LICENSE_START======================================================= + openECOMP : APP-C + ================================================================================ + 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========================================================= + --> + +<!-- + Starter Blueprint Camel Definition appc-common +--> +<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"> + + <reference id="dbLibServiceRef" availability="mandatory" activation="eager" interface="org.openecomp.sdnc.sli.resource.dblib.DbLibService" /> + + <bean id="MetadataServiceImplBean" class="org.openecomp.appc.metadata.impl.MetadataServiceImpl" scope="singleton"> + <property name="dbLibService" ref="dbLibServiceRef" /> + </bean> + + <service id="MetadataService" interface="org.openecomp.appc.metadata.MetadataService" ref="MetadataServiceImplBean"/> + +</blueprint> diff --git a/appc-common/src/main/resources/org/openecomp/appc/i18n/MessageResources.properties b/appc-common/src/main/resources/org/openecomp/appc/i18n/MessageResources.properties index 0c571cbae..13e760f48 100644 --- a/appc-common/src/main/resources/org/openecomp/appc/i18n/MessageResources.properties +++ b/appc-common/src/main/resources/org/openecomp/appc/i18n/MessageResources.properties @@ -624,7 +624,7 @@ AAI_CONNECTION_FAILED=APPC0106E|\ APP-C is unable to communicate with A&AI|\ Connection to A&AI at service {0} failed after all retry attempts.|\ The connection to the A&AI at the indicated service URL cannot be opened. \ - All retries have been exhausted. APP-C is giving up on the connection and will?\ + All retries have been exhausted. APP-C is giving up on the connection and will \ reject the operation request.|\ . @@ -635,7 +635,7 @@ AAI_UPDATE_FAILED=APPC0107E|\ . AAI_GET_DATA_FAILED=APPC0108E|\ - APP-C is unable to retrieve VF/VFC {0} data for Transaction ID?{1}?as a \ + APP-C is unable to retrieve VF/VFC {0} data for Transaction ID {1} as a \ result of A&AI communication failure or its internal error.|\ Operation request will be rejected by APP-C|\ . @@ -643,8 +643,8 @@ AAI_GET_DATA_FAILED=APPC0108E|\ AAI_CONNECTION_FAILED_RETRY=APPC0105W|\ A&AI at identity {0} using VNF_ID {1} failed, reason={2}, retrying in {3} seconds, attempt {4} of {5}.|\ The connection to the A&AI could not be obtained for the indicated reason. APP-C will retry to connect \ - to the A&AI. The?message contains the retry delay, the current attempt and the maximum number of attempts.|\ - Correct the cause of the connection failure as indicated by the reason.? + to the A&AI. The message contains the retry delay, the current attempt and the maximum number of attempts.|\ + Correct the cause of the connection failure as indicated by the reason. AAI_DELETE_FAILED=APPC0114E|\ APP-C is unable to delete COMPONENT_ID {0} for reason {1}|\ @@ -652,6 +652,11 @@ AAI_DELETE_FAILED=APPC0114E|\ A&AI communication failure or its internal error.|\ . +AAI_QUERY_FAILED=APPC0115E|\ + Error Querying AAI with vnfID = {0}|\ + Querying AAI for the given vnf id returns failure to APPC|\ + . + VNF_CONFIGURED=APPC0118I|\ VNF {0} is configured|\ No resolution is required, this is an informational message|\ @@ -682,6 +687,21 @@ VNF_TEST_FAILED=APPC0122E|\ The test operation wasn't performed as a result of VNF communication failure or its internal error.|\ . +VNF_NOT_FOUND=APPC0123E|\ + VNF not found with vnf_id {0}|\ + The VNF wasn't found for the given vnf-id.|\ + . + +VNF_HEALTHCECK_FAILED=APPC0124E|\ + VNF {0} Healthcheck operation failed, reason {1}|\ + The health check operation wasn't performed as a result of VNF communication failure or its internal error.|\ + . + +VM_HEALTHCECK_FAILED=APPC0125E|\ + VM {0} Healthcheck operation failed, reason {1}|\ + The health check operation wasn't performed as a result of VNF communication failure or its internal error.|\ + . + STOP_SERVER_FAILED=APPC0112E|\ Server {0} (id {1}) failed to stop during {2} phase, reason {3}|\ The server stop failed for the indicated reason. Correct the cause of the failure and \ @@ -707,25 +727,25 @@ TERMINATE_STACK_FAILED=APPC0113E|\ included in the message. TERMINATING_SERVER=APPC0114I|\ - {0} IAAS Adapter?terminate server requested|\ + {0} IAAS Adapter terminate server requested|\ No resolution required|\ A graph has invoked the IAAS adapter and has requested the server to be terminated. The \ properties that govern the request are echoed immediately following this message. TERMINATING_STACK=APPC0115I|\ - {0} IAAS Adapter?terminate stack requested|\ + {0} IAAS Adapter terminate stack requested|\ No resolution required|\ A graph has invoked the IAAS adapter and has requested the server to be terminated. The \ properties that govern the request are echoed immediately following this message. TERMINATE_SERVER=APPC0116I|\ - Server {0} is being?terminated...|\ + Server {0} is being terminated...|\ No recovery required|\ The processing being performed by APPC requires that the indicated server be terminated. TERMINATE_STACK=APPC0117I|\ - Stack {0} is being?terminated...|\ + Stack {0} is being terminated...|\ No recovery required|\ The processing being performed by APPC requires that the indicated server be terminated. @@ -753,7 +773,7 @@ CLOSE_CONTEXT_FAILED=APPC0121E|\ message should be referred to support for assistance. SNAPSHOTING_STACK=APPC0122I|\ - Stack {0} is being?snapshoted...|\ + Stack {0} is being snapshoted...|\ No resolution is required|\ Stack snapshot. @@ -764,7 +784,7 @@ STACK_SNAPSHOTED==APPC0123I|\ RESTORING_STACK=APPC0124I|\ - Stack {0} is being?restored to snapshot {1}...|\ + Stack {0} is being restored to snapshot {1}...|\ No resolution is required|\ Stack restore. @@ -790,3 +810,162 @@ APPC_METRIC_MSG=APPC0128I|\ ended in {6} ms with result "{7}"|\ No resolution is required, this is an informational message|\ This message indicates that the APPC logged some operation to metric + + SNAPSHOTING_SERVER=APPC0129I|\ +{0} IAAS Adapter create snapshot of server requested|\ +No resolution is required, this is an informational message|\ +This message indicates that a IAAS Adapter create snapshot of server was requested. + +INPUT_PAYLOAD_PARSING_FAILED = APPC0130E|\ + Failed to parsing the input payload: {0}|\ + Please provide correct input string for parsing.|\ + . + +APPC_EXCEPTION = APPC0132E|\ + Error occurred for VNF type : {0}, reason {1}|\ + Runtime exception thrown by APPC.|\ + . + +SSH_DATA_EXCEPTION = APPC0133E|\ + SSH Data Exception occurred, reason {0}|\ + SSH Data exception occurred.|\ + . + +JSON_PROCESSING_EXCEPTION = APPC0134E|\ + Json processing exception occurred, reason {0}|\ + Json processing Exception|\ + . + +SUCCESS_EVENT_MESSAGE = APPC0136I|\ + Operation {0} succeed for {1}|\ + Success message.|\ + . +DEPENDENCY_MODEL_NOT_FOUND = APPC0137E|\ + Dependency model not found for VNF type {0}, reason {1}|\ + Please provide dependency model|\ + . + +INVALID_DEPENDENCY_MODEL = APPC0138E|\ + Invalid Dependency model for VNF Type {0}, reason {1}|\ + Invalid dependency model found |\ + . + + +FAILURE_RETRIEVE_VNFC_DG = APPC0139E|\ + Failed to retrieve DG for VNFC Type: {0}|\ + Failed to retrieve VNFC DG |\ + . + + +SERVER_NETWORK_ERROR=APPC0140E|\ + Server {0} either has a port {1} that is NOT online, or the status of the network to which the port is connected to is not ACTIVE|\ + Please ensure they are UP and running before requested operation|\ + It is critical that the VM Server is reachable by the Provider(ex: OpenStack) in order to be able to perform \ + the requested operation on it. + . + +REBUILD_SERVER=APPC0140I|\ + Server {0} is being rebuilt...|\ + No recovery required|\ + The processing being performed by APPC requires that the indicated server be rebuilt. + +HYPERVISOR_DOWN_ERROR=APPC0141E|\ + Hypervisor {0} for the Server {1} is either NOT ENABLED, or its status is DOWN or UNKNOWN|\ + Please ensure the Hypervisor is UP and running before proceeding with the requested operation|\ + It is critical that the Hypervisor that manages the Virtual Machine for the Server is reachable by the Provider(ex: OpenStack) in order to be able to perform \ + the requested operation on it. + . + + +HYPERVISOR_NETWORK_ERROR=APPC0142E|\ + Hypervisor {0} for the Server {1} is NOT Reachable by APPC for initiating the requested operation|\ + Please ensure the Hypervisor is connected to the network before proceeding with the requested operation|\ + It is critical that the Hypervisor that manages the Virtual Machine for the Server is reachable by the Provider(ex: OpenStack) in order to be able to perform \ + the requested operation on it. + +EVACUATE_SERVER_REBUILD_FAILED=APPC0143E|\ + Server {0} evacuate from host {1} to host {2} failed during the rebuild on host {2}, reason {3}|\ + The server rebuild after evacuation failed for the indicated reason. Correct the cause of the failure and \ + run a rebuild, if applicable.|\ + The adapter has attempted to rebuild after evacuating the indicated server but the rebuild request has \ + been failed by the provider for some reason. The reason returned by the provider is \ + included in the message. + +RESTART_APPLICATION=APPC0144I|\ + Application on server {0} is being restarted...|\ + No recovery required|\ + The processing being performed by APPC requires that the application on the indicated server be restarted. + +START_APPLICATION=APPC0145I|\ + Application on server {0} is being started...|\ + No recovery required|\ + The processing being performed by APPC requires that the application on the indicated server be started. + +APPLICATION_RESTART_FAILED=APPC0146E|\ + Restart application operation failed on server : {0}, reason {1}|\ + Restart application operation failure.|\ + Correct the cause of the failure as indicated by the reason. + +APPLICATION_START_FAILED=APPC0147E|\ + Start application operation failed on server : {0}, reason {1}|\ + Start application operation failure.|\ + Correct the cause of the failure as indicated by the reason. + +LOOKING_SERVER_UP=APPC0148I|\ +{0} IAAS Adapter looking up for the server requested|\ +No resolution is required, this is an informational message|\ +This message indicates that a IAAS Adapter lookup of server was requested. + +EVACUATE_SERVER_REBUILD_FAILED=APPC0149E|\ + Server {0} evacuate from host {1} to host {2} failed during the rebuild on host {2}, reason {3}|\ + The server rebuild after evacuation failed for the indicated reason. Correct the cause of the failure and \ + run a rebuild, if applicable.|\ + The adapter has attempted to rebuild after evacuating the indicated server but the rebuild request has \ + been failed by the provider for some reason. The reason returned by the provider is \ + included in the message. + +APPLICATION_STOP_FAILED=APPC0150E|\ + Stop application operation failed on server : {0}, reason {1}|\ + Stop application operation failure.|\ + Correct the cause of the failure as indicated by the reason. + +STOP_APPLICATION=APPC0151I|\ + Application on server {0} is being stopped...|\ + No recovery required|\ + The processing being performed by APPC requires that the application on the indicated server be stopped. + +LCM_OPERATIONS_DISABLED=APPC0152E|\ + APPC LCM operations have been administratively disabled|\ + No recovery required|\ + This is a indication that the APPC LCM operations are disabled. + +OAM_OPERATION_EXCEPTION=APPC0153E|\ + Application {0} received exception {1} while attempting to execute oam operation {2}, exception message = {3}|\ + The application controller attempted to perform an OAM operation \ + but an exception was caught. The class of the \ + exception is shown, as is the message associated with the exception. An \ + abbreviated stack trace is also displayed to provide information as to the \ + state of the thread at the time of the exception.|\ + Correct the cause of the exception and rerun. + +OAM_OPERATION_STOPPING=APPC0154W|\ + Application {0} is stopping... |\ + No recovery required|\ + The APPC will no longer accept new LCM requests. Previously accepted LCM requests will be allowed to complete. + +OAM_OPERATION_STOPPED=APPC0155W|\ + Application {0} is stopped|\ + No recovery required|\ + The APPC is not accepting new LCM requests and all previously accepted LCM requests have completed. + +OAM_OPERATION_STARTING=APPC0156I|\ + Application {0} is starting...|\ + No recovery required|\ + The APPC has initiated its startup procedure. Its internal components are coming online. Once completed it will start accepting LCM requests. \ + +OAM_OPERATION_STARTED=APPC0157I|\ + Application {0} is started|\ + No recovery required|\ + The APPC will now accept new LCM requests for processing. + + diff --git a/appc-common/src/test/java/org/openecomp/appc/metadata/TestMetadataService.java b/appc-common/src/test/java/org/openecomp/appc/metadata/TestMetadataService.java new file mode 100644 index 000000000..a6db669ca --- /dev/null +++ b/appc-common/src/test/java/org/openecomp/appc/metadata/TestMetadataService.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : APP-C + * ================================================================================ + * 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.appc.metadata; + +import org.openecomp.sdnc.sli.resource.dblib.DbLibService; +import com.sun.rowset.CachedRowSetImpl; +import org.mockito.Mockito; +import org.openecomp.appc.metadata.impl.MetadataServiceImpl; + +import javax.sql.rowset.CachedRowSet; +import java.sql.SQLException; +import java.util.ArrayList; + +import static org.mockito.Matchers.anyCollection; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.mock; + + + +public class TestMetadataService { + + MetadataServiceImpl metadataService = new MetadataServiceImpl(); + + TestMetadataService() throws SQLException { + DbLibService dbLibService = mock(DbLibService.class); + metadataService.setDbLibService(dbLibService); + CachedRowSet mockRS = new CachedRowSetImpl(); + Mockito.when(dbLibService.getData(anyString(), (ArrayList<String>)anyCollection(), anyString())).thenReturn(mockRS); + } + + +} |