summaryrefslogtreecommitdiffstats
path: root/common/src
diff options
context:
space:
mode:
Diffstat (limited to 'common/src')
-rw-r--r--common/src/main/java/org/onap/so/client/HttpClient.java1
-rw-r--r--common/src/main/java/org/onap/so/client/RestClientSSL.java3
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIObjectType.java2
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java2
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java2
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIValidator.java4
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java6
-rw-r--r--common/src/main/java/org/onap/so/client/grm/GRMClient.java2
-rw-r--r--common/src/main/java/org/onap/so/client/grm/GRMDefaultPropertiesImpl.java63
-rw-r--r--common/src/main/java/org/onap/so/client/grm/GRMProperties.java4
-rw-r--r--common/src/main/java/org/onap/so/client/grm/GRMRestClient.java17
-rw-r--r--common/src/main/java/org/onap/so/client/grm/GRMRestInvoker.java15
-rw-r--r--common/src/main/java/org/onap/so/logger/MsoAlarmLogger.java187
-rw-r--r--common/src/main/java/org/onap/so/serviceinstancebeans/InstanceReferences.java17
-rw-r--r--common/src/main/java/org/onap/so/web/exceptions/RuntimeExceptionMapper.java6
-rw-r--r--common/src/test/java/org/onap/so/adapter_utils/tests/MsoAlarmLoggerTest.java134
-rw-r--r--common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java16
-rw-r--r--common/src/test/java/org/onap/so/client/dmaap/DmaapPublisherTest.java2
-rw-r--r--common/src/test/java/org/onap/so/client/grm/GRMClientTest.java176
-rw-r--r--common/src/test/java/org/onap/so/web/exceptions/RuntimeExceptionMapperTest.java9
20 files changed, 55 insertions, 613 deletions
diff --git a/common/src/main/java/org/onap/so/client/HttpClient.java b/common/src/main/java/org/onap/so/client/HttpClient.java
index 12f19ac607..66e970a154 100644
--- a/common/src/main/java/org/onap/so/client/HttpClient.java
+++ b/common/src/main/java/org/onap/so/client/HttpClient.java
@@ -47,7 +47,6 @@ public class HttpClient extends RestClient {
@Override
protected void initializeHeaderMap(Map<String, String> headerMap) {
-
}
@Override
diff --git a/common/src/main/java/org/onap/so/client/RestClientSSL.java b/common/src/main/java/org/onap/so/client/RestClientSSL.java
index ac4a8d1a7c..8369eba859 100644
--- a/common/src/main/java/org/onap/so/client/RestClientSSL.java
+++ b/common/src/main/java/org/onap/so/client/RestClientSSL.java
@@ -22,6 +22,7 @@ package org.onap.so.client;
import java.io.FileInputStream;
import java.net.URI;
+import java.nio.file.Paths;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.util.Optional;
@@ -72,7 +73,7 @@ public abstract class RestClientSSL extends RestClient {
private KeyStore getKeyStore() {
KeyStore ks = null;
char[] password = System.getProperty(RestClientSSL.SSL_KEY_STORE_PASSWORD_KEY).toCharArray();
- try(FileInputStream fis = new FileInputStream(System.getProperty(RestClientSSL.SSL_KEY_STORE_KEY))) {
+ try(FileInputStream fis = new FileInputStream(Paths.get(System.getProperty(RestClientSSL.SSL_KEY_STORE_KEY)).normalize().toString())) {
ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(fis, password);
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java b/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java
index 51d09006db..f003dc0628 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java
@@ -25,6 +25,7 @@ import java.util.Map;
import org.onap.aai.annotations.Metadata;
import org.onap.aai.domain.yang.AllottedResource;
+import org.onap.aai.domain.yang.AggregateRoute;
import org.onap.aai.domain.yang.CloudRegion;
import org.onap.aai.domain.yang.Collection;
import org.onap.aai.domain.yang.Complex;
@@ -113,6 +114,7 @@ public enum AAIObjectType implements GraphInventoryObjectType {
SP_PARTNER(AAINamespaceConstants.BUSINESS, SpPartner.class),
DEVICE(AAINamespaceConstants.NETWORK, Device.class),
EXT_AAI_NETWORK(AAINamespaceConstants.NETWORK, ExtAaiNetwork.class),
+ AGGREGATE_ROUTE(AAINamespaceConstants.NETWORK, AggregateRoute.class),
UNKNOWN("", "");
private final String uriTemplate;
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java b/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java
index 831e43841a..52f15c45c4 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java
@@ -33,7 +33,7 @@ public interface AAIRestClientI {
void updateMaintenceFlagVnfId(String vnfId, boolean inMaint, String transactionLoggingUuid) throws Exception;
- GenericVnf getVnfByName(String vnfId, String transactionLoggingUuid) throws Exception;
+ GenericVnf getVnfByName(String vnfId);
Optional<Pnf> getPnfByName(String pnfId, String transactionLoggingUuid) throws Exception;
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java b/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java
index bcc7d8ba16..813421ff80 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java
@@ -75,7 +75,7 @@ public class AAIRestClientImpl implements AAIRestClientI {
}
@Override
- public GenericVnf getVnfByName(String vnfId, String transactionLoggingUuid) {
+ public GenericVnf getVnfByName(String vnfId) {
return new AAIResourcesClient(ENDPOINT_VERSION)
.get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)).orElse(null);
}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIValidator.java b/common/src/main/java/org/onap/so/client/aai/AAIValidator.java
index bf6485a631..18252d548b 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAIValidator.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAIValidator.java
@@ -24,9 +24,9 @@ import java.io.IOException;
public interface AAIValidator {
- boolean isPhysicalServerLocked(String hostName, String transactionLoggingUuid) throws IOException;
+ boolean isPhysicalServerLocked(String hostName) throws IOException;
- boolean isVNFLocked(String vnfId, String transactionLoggingUuid) throws IOException, Exception;
+ boolean isVNFLocked(String vnfId);
} \ No newline at end of file
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java b/common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java
index e416da172c..6ece8a2620 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java
@@ -46,7 +46,7 @@ public class AAIValidatorImpl implements AAIValidator {
}
@Override
- public boolean isPhysicalServerLocked(String vnfId, String transactionLoggingUuid) throws IOException {
+ public boolean isPhysicalServerLocked(String vnfId) throws IOException {
List<Pserver> pservers;
boolean isLocked = false;
pservers = client.getPhysicalServerByVnfId(vnfId);
@@ -58,9 +58,9 @@ public class AAIValidatorImpl implements AAIValidator {
}
@Override
- public boolean isVNFLocked(String vnfId, String transactionLoggingUuid) throws Exception {
+ public boolean isVNFLocked(String vnfId) {
boolean isLocked = false;
- GenericVnf genericVnf = client.getVnfByName(vnfId, transactionLoggingUuid);
+ GenericVnf genericVnf = client.getVnfByName(vnfId);
if (genericVnf.isInMaint())
isLocked = true;
diff --git a/common/src/main/java/org/onap/so/client/grm/GRMClient.java b/common/src/main/java/org/onap/so/client/grm/GRMClient.java
index 84e25b9ce4..653e1cc7b3 100644
--- a/common/src/main/java/org/onap/so/client/grm/GRMClient.java
+++ b/common/src/main/java/org/onap/so/client/grm/GRMClient.java
@@ -53,7 +53,7 @@ public class GRMClient {
}
}
- protected ServiceEndPointLookupRequest buildServiceEndPointlookupRequest(String name, int majorVersion, String env) {
+ public ServiceEndPointLookupRequest buildServiceEndPointlookupRequest(String name, int majorVersion, String env) {
VersionLookup version = new VersionLookup();
version.setMajor(majorVersion);
diff --git a/common/src/main/java/org/onap/so/client/grm/GRMDefaultPropertiesImpl.java b/common/src/main/java/org/onap/so/client/grm/GRMDefaultPropertiesImpl.java
deleted file mode 100644
index b38072e769..0000000000
--- a/common/src/main/java/org/onap/so/client/grm/GRMDefaultPropertiesImpl.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.onap.so.client.grm;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import javax.ws.rs.core.MediaType;
-
-public class GRMDefaultPropertiesImpl implements GRMProperties {
-
- public GRMDefaultPropertiesImpl() {
- }
-
- @Override
- public URL getEndpoint() throws MalformedURLException {
- return new URL("http://localhost:47389");
- }
-
- @Override
- public String getSystemName() {
- return "MSO";
- }
-
- @Override
- public String getDefaultVersion() {
- return "v1";
- }
-
- @Override
- public String getUsername() {
- return "gmruser";
- }
-
- @Override
- public String getPassword() {
- return "cGFzc3dvcmQ=";
- }
-
- @Override
- public String getContentType() {
- return MediaType.APPLICATION_JSON;
- }
-
-}
diff --git a/common/src/main/java/org/onap/so/client/grm/GRMProperties.java b/common/src/main/java/org/onap/so/client/grm/GRMProperties.java
index da9f215aac..1206896bf9 100644
--- a/common/src/main/java/org/onap/so/client/grm/GRMProperties.java
+++ b/common/src/main/java/org/onap/so/client/grm/GRMProperties.java
@@ -24,7 +24,7 @@ import org.onap.so.client.RestProperties;
public interface GRMProperties extends RestProperties {
public String getDefaultVersion();
- public String getUsername();
- public String getPassword();
+ public String getAuth();
+ public String getKey();
public String getContentType();
}
diff --git a/common/src/main/java/org/onap/so/client/grm/GRMRestClient.java b/common/src/main/java/org/onap/so/client/grm/GRMRestClient.java
index ce16ccaaaa..0bb55e627a 100644
--- a/common/src/main/java/org/onap/so/client/grm/GRMRestClient.java
+++ b/common/src/main/java/org/onap/so/client/grm/GRMRestClient.java
@@ -32,13 +32,11 @@ import org.onap.so.utils.TargetEntity;
public class GRMRestClient extends RestClient {
- private final String username;
- private final String password;
+ private final GRMProperties properties;
- public GRMRestClient(RestProperties props, URI path, String username, String password) {
- super(props, Optional.of(path));
- this.username = username;
- this.password = password;
+ public GRMRestClient(GRMProperties props, URI path) {
+ super(props, Optional.of(path));
+ this.properties = props;
}
@Override
@@ -48,7 +46,12 @@ public class GRMRestClient extends RestClient {
@Override
protected void initializeHeaderMap(Map<String, String> headerMap) {
- headerMap.put("Authorization", "Basic " + Base64.getEncoder().encodeToString(new String(username + ":" + password).getBytes()));
+ String auth = properties.getAuth();
+ String key = properties.getKey();
+
+ if (auth != null && !auth.isEmpty() && key != null && !key.isEmpty()) {
+ addBasicAuthHeader(auth, key);
+ }
}
}
diff --git a/common/src/main/java/org/onap/so/client/grm/GRMRestInvoker.java b/common/src/main/java/org/onap/so/client/grm/GRMRestInvoker.java
index 3045cb35f4..0c95a66979 100644
--- a/common/src/main/java/org/onap/so/client/grm/GRMRestInvoker.java
+++ b/common/src/main/java/org/onap/so/client/grm/GRMRestInvoker.java
@@ -21,7 +21,6 @@
package org.onap.so.client.grm;
import java.net.URI;
-import java.util.Base64;
import javax.ws.rs.core.UriBuilder;
@@ -34,11 +33,8 @@ public class GRMRestInvoker {
public GRMRestInvoker(GRMAction action) {
GRMProperties props = GRMPropertiesLoader.getInstance().getImpl();
- if (props == null) {
- props = new GRMDefaultPropertiesImpl();
- }
this.properties = props;
- this.client = new GRMRestClient(this.properties, this.createURI(action), this.properties.getUsername(), this.decode(this.properties.getPassword()));
+ this.client = new GRMRestClient(properties, this.createURI(action));
}
private URI createURI(GRMAction action) {
@@ -49,15 +45,6 @@ public class GRMRestInvoker {
.build();
}
- private String decode(String cred) {
- try {
- return new String(Base64.getDecoder().decode(cred.getBytes()));
- }
- catch(IllegalArgumentException iae) {
- return cred;
- }
- }
-
private RestClient getClient() {
return this.client;
}
diff --git a/common/src/main/java/org/onap/so/logger/MsoAlarmLogger.java b/common/src/main/java/org/onap/so/logger/MsoAlarmLogger.java
deleted file mode 100644
index 890aac93c0..0000000000
--- a/common/src/main/java/org/onap/so/logger/MsoAlarmLogger.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.onap.so.logger;
-
-
-import java.io.File;
-
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-
-import org.slf4j.LoggerFactory;
-
-import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.Logger;
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
-import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.core.rolling.RollingFileAppender;
-import ch.qos.logback.core.rolling.TimeBasedRollingPolicy;
-
-/**
- * Wrapper around log4j and Nagios NRDP passive alarming for MSO.
- *
- * For local alarm logging, this class will look for an alarm log file name
- * in the servlet context parameter "mso.alarms.file". If none is found,
- * it will look for an MsoProperty of the same name. As a last resort,
- * it will use the default path "/var/log/ecomp/MSO/alarms/alarm.log".
- * It is expected that all alarms within an application will use the same
- * alarm file, so there is no way to dynamically add other alarm files.
- *
- * Alarms are logged as a simple pipe-delimited string of the format:
- * <dateTime>|<alarmType>|<state>|<detailMessage>
- *
- * This class also supports real-time Nagios NRDP alarming. If enabled via
- * MsoProperties, all alarms generated and logged to the local alarm file will
- * also be transmitted to a Nagios NRDP instance. NRDP requires 4 parameters
- * in service alarm events (all Mso Alarms will be Service Alarms):
- * hostname, servicename, state, detail
- *
- * The log file format is also intended to be compatible with Nagios NRDP for
- * non-real-time reporting. The command-line tool for sending alarms is
- * is "send_nrdp.php", which takes the same 4 parameters as input.
- * It will be easy enough to translate entries from an alarm.log file to
- * NRDP if real-time NRDP alarming is not enabled.
- *
- * For Nagios integration, the alarmTypes should all match "service names"
- * configured in the receiving Nagios server. Also, the alarm state will
- * be limited to the 4 values defined by Nagios:
- * 0 = OK, 1 = Warning, 2 = Critical, 3 = Unknown
- *
- *
- */
-public class MsoAlarmLogger implements ServletContextListener {
-
- private Logger alarmLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(MSO_ALARM_CONTEXT);
- private static RollingFileAppender<ILoggingEvent> fileAppender = null;
- public static final String DEFAULT_MSO_ALARM_FILE = "/var/log/ecomp/MSO/alarms/alarm.log";
- public static final String MSO_ALARM_CONTEXT = "mso.alarms";
-
- public static final int OK = 0;
- public static final int WARNING = 1;
- public static final int CRITICAL = 2;
- public static final int UNKNOWN = 3;
-
- /**
- * Get the default MSO Alarm Logger
- */
- public MsoAlarmLogger () {
-
- initializeAlarmLogger(null);
-
- }
-
- public MsoAlarmLogger (String alarmFile) {
- initializeAlarmLogger(alarmFile);
-
- }
-
- /**
- * Method to record an alarm.
- *
- * @param alarm - the alarm identifier (Nagios "service")
- * @param state - the alarm state/severity, based on Nagios service
- * state values: 0 = OK, 1 = Warning, 2 = Critical, 3 = Unknown
- * @param detail - detail message (may contain additional internal
- * structure per alarm type)
- */
- public void sendAlarm (String alarm, int state, String detail) {
- // Write the alarm to Log file
- if (alarmLogger != null) {
- String output = alarm + "|" + state + "|" + detail;
- alarmLogger.info (output);
- }
-
- }
-
- @Override
- public void contextDestroyed (ServletContextEvent event) {
- // Nothing to do...
- }
-
- @Override
- public void contextInitialized (ServletContextEvent event) {
- String msoAlarmFile = event.getServletContext ().getInitParameter ("mso.alarm.file");
- if (msoAlarmFile == null) {
- msoAlarmFile = DEFAULT_MSO_ALARM_FILE;
- }
-
- initializeAlarmLogger (msoAlarmFile);
- }
-
- private void initializeAlarmLogger (String alarmFile) {
- synchronized (MsoAlarmLogger.class) {
- if (fileAppender == null) {
- if (alarmFile != null) {
- fileAppender = MsoAlarmLogger.getAppender (alarmFile);
- } else {
- fileAppender = MsoAlarmLogger.getAppender (DEFAULT_MSO_ALARM_FILE);
- }
- }
- }
- // The alarmLogger was static originally.
- // The initialization of the alarmLogger was fine, but not sure why, it lost its appender info later
- // Due to that issue, the alarmLogger is not static any more.
- // Instead static attribute fileAppender is added and will be assigned to the alarmLogger every time new MsoAlarmLogger is created.
- alarmLogger.setLevel (Level.INFO);
- alarmLogger.addAppender (fileAppender);
- alarmLogger.setAdditive (false);
- }
-
- public void resetAppender() {
- synchronized (MsoAlarmLogger.class) {
- fileAppender = null;
- }
- }
-
- private static RollingFileAppender<ILoggingEvent> getAppender (String msoAlarmFile) {
- // Create a Logger for alarms. Just use a default Pattern that outputs
- // a message. MsoAlarmLogger will handle the formatting.
- File alarmFile = new File (msoAlarmFile);
- File alarmDir = alarmFile.getParentFile ();
- if (!alarmDir.exists ()) {
- alarmDir.mkdirs ();
- }
-
- String logPattern = "%d{yyyy-MM-dd HH:mm:ss}|%m%n";
-
- LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
- PatternLayoutEncoder encoder=new PatternLayoutEncoder();
- encoder.setPattern(logPattern);
- encoder.setContext(context);
- encoder.start();
- RollingFileAppender<ILoggingEvent> fileAppender= new RollingFileAppender<>();
- TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy= new TimeBasedRollingPolicy<>();
- rollingPolicy.setContext(context);
- rollingPolicy.setFileNamePattern(msoAlarmFile + ".%d");
- rollingPolicy.setParent(fileAppender);
- rollingPolicy.start();
- fileAppender.setFile(msoAlarmFile);
- fileAppender.setAppend(true);
- fileAppender.setEncoder(encoder);
- fileAppender.setRollingPolicy(rollingPolicy);
- fileAppender.setContext(context);
- fileAppender.start();
-
- return fileAppender;
- }
-
-}
diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/InstanceReferences.java b/common/src/main/java/org/onap/so/serviceinstancebeans/InstanceReferences.java
index 69d21c41ac..72374e0580 100644
--- a/common/src/main/java/org/onap/so/serviceinstancebeans/InstanceReferences.java
+++ b/common/src/main/java/org/onap/so/serviceinstancebeans/InstanceReferences.java
@@ -39,6 +39,8 @@ public class InstanceReferences {
protected String networkInstanceId;
protected String networkInstanceName;
protected String requestorId;
+ protected String instanceGroupId;
+ protected String instanceGroupName;
public String getServiceInstanceId() {
@@ -109,6 +111,18 @@ public class InstanceReferences {
public void setRequestorId(String requestorId) {
this.requestorId = requestorId;
}
+ public String getInstanceGroupId() {
+ return instanceGroupId;
+ }
+ public void setInstanceGroupId(String instanceGroupId) {
+ this.instanceGroupId = instanceGroupId;
+ }
+ public String getInstanceGroupName() {
+ return instanceGroupName;
+ }
+ public void setInstanceGroupName(String instanceGroupName) {
+ this.instanceGroupName = instanceGroupName;
+ }
@Override
public String toString() {
return new ToStringBuilder(this).append("serviceInstanceId", serviceInstanceId)
@@ -118,6 +132,7 @@ public class InstanceReferences {
.append("volumeGroupInstanceId", volumeGroupInstanceId)
.append("volumeGroupInstanceName", volumeGroupInstanceName)
.append("networkInstanceId", networkInstanceId).append("networkInstanceName", networkInstanceName)
- .append("requestorId", requestorId).toString();
+ .append("requestorId", requestorId).append("instanceGroupId", instanceGroupId)
+ .append("instanceGroupName", instanceGroupName).toString();
}
}
diff --git a/common/src/main/java/org/onap/so/web/exceptions/RuntimeExceptionMapper.java b/common/src/main/java/org/onap/so/web/exceptions/RuntimeExceptionMapper.java
index 72e609acbd..9ddfd0592c 100644
--- a/common/src/main/java/org/onap/so/web/exceptions/RuntimeExceptionMapper.java
+++ b/common/src/main/java/org/onap/so/web/exceptions/RuntimeExceptionMapper.java
@@ -25,20 +25,20 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.ext.ExceptionMapper;
-import org.onap.so.logger.MsoAlarmLogger;
+
import org.onap.so.logger.MsoLogger;
public class RuntimeExceptionMapper implements ExceptionMapper<RuntimeException> {
private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL, RuntimeExceptionMapper.class);
- private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger();
+
@Override
public Response toResponse(RuntimeException exception) {
if (exception instanceof NotFoundException) {
return Response.status(Status.NOT_FOUND).build();
} else {
- alarmLogger.sendAlarm("MsoApplicationError", MsoAlarmLogger.CRITICAL, exception.getMessage());
+
logger.error(exception);
return Response.status(Status.INTERNAL_SERVER_ERROR).entity(new ExceptionResponse("Unexpected Internal Exception")).build();
}
diff --git a/common/src/test/java/org/onap/so/adapter_utils/tests/MsoAlarmLoggerTest.java b/common/src/test/java/org/onap/so/adapter_utils/tests/MsoAlarmLoggerTest.java
deleted file mode 100644
index 6756bc98ad..0000000000
--- a/common/src/test/java/org/onap/so/adapter_utils/tests/MsoAlarmLoggerTest.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.onap.so.adapter_utils.tests;
-
-
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.so.logger.MsoAlarmLogger;
-
-
-/**
- * This junit test very roughly the alarm logger
- *
- */
-public class MsoAlarmLoggerTest {
-
- public static MsoAlarmLogger msoAlarmLogger;
-
- @BeforeClass
- public static final void createObjects() throws IOException
- {
-
- File outputFile = new File ("./target/alarm-test.log");
- if (outputFile.exists()) {
- outputFile.delete();
- } else {
- outputFile.createNewFile();
- }
- msoAlarmLogger = new MsoAlarmLogger("./target/alarm-test.log");
- }
-
- @AfterClass
- public static void tearDown() {
- msoAlarmLogger.resetAppender();
- }
- @Test
- public void testAlarmConfig() throws IOException {
-
- msoAlarmLogger.sendAlarm("test", 0, "detail message");
-
- FileInputStream inputStream = new FileInputStream("./target/alarm-test.log");
- BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
-
- String line = reader.readLine();
- String[] splitLine = line.split("\\|");
- assertTrue(splitLine.length==4);
- assertTrue("test".equals(splitLine[1]));
- assertTrue("0".equals(splitLine[2]));
- assertTrue("detail message".equals(splitLine[3]));
-
- line = reader.readLine();
- assertNull(line);
- reader.close();
- inputStream.close();
-
- // Reset the file for others tests
- PrintWriter writer = new PrintWriter(new File("./target/alarm-test.log"));
- writer.print("");
- writer.close();
-
- }
-
- @Test
- public void testAlarm() throws IOException {
-
- msoAlarmLogger.sendAlarm("test", 0, "detail message");
- msoAlarmLogger.sendAlarm("test2", 1, "detail message2");
- msoAlarmLogger.sendAlarm("test3", 2, "detail message3");
-
- FileInputStream inputStream = new FileInputStream("./target/alarm-test.log");
- BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
-
- String line = reader.readLine();
- String[] splitLine = line.split("\\|");
- assertTrue(splitLine.length==4);
- assertTrue("test".equals(splitLine[1]));
- assertTrue("0".equals(splitLine[2]));
- assertTrue("detail message".equals(splitLine[3]));
-
- line = reader.readLine();
- splitLine = line.split("\\|");
- assertTrue(splitLine.length==4);
- assertTrue("test2".equals(splitLine[1]));
- assertTrue("1".equals(splitLine[2]));
- assertTrue("detail message2".equals(splitLine[3]));
-
- line = reader.readLine();
- splitLine = line.split("\\|");
- assertTrue(splitLine.length==4);
- assertTrue("test3".equals(splitLine[1]));
- assertTrue("2".equals(splitLine[2]));
- assertTrue("detail message3".equals(splitLine[3]));
-
- line = reader.readLine();
- assertNull(line);
- reader.close();
- inputStream.close();
-
- // Reset the file for others tests
- PrintWriter writer = new PrintWriter(new File("./target/alarm-test.log"));
- writer.print("");
- writer.close();
-
- }
-}
diff --git a/common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java b/common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java
index 63c7290065..f32633122d 100644
--- a/common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java
@@ -66,28 +66,28 @@ public class AAIValidatorTest {
@Test
public void test_IsPhysicalServerLocked_True() throws IOException{
when(client.getPhysicalServerByVnfId(vnfName)).thenReturn(getPservers(true));
- boolean locked = validator.isPhysicalServerLocked(vnfName, uuid);
+ boolean locked = validator.isPhysicalServerLocked(vnfName);
assertEquals(true, locked);
}
@Test
public void test_IsPhysicalServerLocked_False() throws IOException {
when(client.getPhysicalServerByVnfId(vnfName)).thenReturn(getPservers(false));
- boolean locked = validator.isPhysicalServerLocked(vnfName, uuid);
+ boolean locked = validator.isPhysicalServerLocked(vnfName);
assertEquals(false, locked);
}
@Test
- public void test_IsVNFLocked_False() throws Exception{
- when(client.getVnfByName(vnfName,uuid)).thenReturn(createGenericVnfs(false));
- boolean locked = validator.isVNFLocked(vnfName, uuid);
+ public void test_IsVNFLocked_False() {
+ when(client.getVnfByName(vnfName)).thenReturn(createGenericVnfs(false));
+ boolean locked = validator.isVNFLocked(vnfName);
assertEquals(false, locked);
}
@Test
- public void test_IsVNFLocked_True() throws Exception{
- when(client.getVnfByName(vnfName,uuid)).thenReturn(createGenericVnfs(true));
- boolean locked = validator.isVNFLocked(vnfName, uuid);
+ public void test_IsVNFLocked_True() {
+ when(client.getVnfByName(vnfName)).thenReturn(createGenericVnfs(true));
+ boolean locked = validator.isVNFLocked(vnfName);
assertEquals(true,locked );
}
}
diff --git a/common/src/test/java/org/onap/so/client/dmaap/DmaapPublisherTest.java b/common/src/test/java/org/onap/so/client/dmaap/DmaapPublisherTest.java
index e1afa82e1e..c0633c1cca 100644
--- a/common/src/test/java/org/onap/so/client/dmaap/DmaapPublisherTest.java
+++ b/common/src/test/java/org/onap/so/client/dmaap/DmaapPublisherTest.java
@@ -45,7 +45,7 @@ public class DmaapPublisherTest {
@Override
public Optional<String> getHost() {
- return Optional.of("http://localhost:8080");
+ return Optional.of("http://test");
}
};
diff --git a/common/src/test/java/org/onap/so/client/grm/GRMClientTest.java b/common/src/test/java/org/onap/so/client/grm/GRMClientTest.java
deleted file mode 100644
index 388e89a438..0000000000
--- a/common/src/test/java/org/onap/so/client/grm/GRMClientTest.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.onap.so.client.grm;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
-import static com.github.tomakehurst.wiremock.client.WireMock.matching;
-import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static com.github.tomakehurst.wiremock.client.WireMock.verify;
-import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.nio.file.Files;
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.core.MediaType;
-
-
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.onap.logging.ref.slf4j.ONAPLogConstants;
-import org.onap.so.client.grm.beans.ServiceEndPoint;
-import org.onap.so.client.grm.beans.ServiceEndPointList;
-import org.onap.so.client.grm.beans.ServiceEndPointLookupRequest;
-import org.onap.so.client.grm.beans.ServiceEndPointRequest;
-import org.onap.so.client.grm.exceptions.GRMClientCallFailed;
-import org.onap.so.utils.TestAppender;
-import org.slf4j.MDC;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-
-import ch.qos.logback.classic.spi.ILoggingEvent;
-
-public class GRMClientTest {
-
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(47389));
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- private static final String uuidRegex = "(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-5][0-9a-f]{3}-?[089ab][0-9a-f]{3}-?[0-9a-f]{12}$";
-
- @BeforeClass
- public static void setUp() throws Exception {
- System.setProperty("mso.config.path", "src/test/resources");
- }
-
- @Test
- public void testFind() throws Exception {
- TestAppender.events.clear();
- String endpoints = getFileContentsAsString("__files/grm/endpoints.json");
- wireMockRule.stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/findRunning"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", MediaType.APPLICATION_JSON)
- .withBody(endpoints)));
-
- MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, "/test");
- GRMClient client = new GRMClient();
- ServiceEndPointList sel = client.findRunningServices("TEST.ECOMP_PSL.*", 1, "TEST");
- List<ServiceEndPoint> list = sel.getServiceEndPointList();
- assertEquals(3, list.size());
-
- boolean foundInvoke = false;
- boolean foundInvokeReturn = false;
- for(ILoggingEvent logEvent : TestAppender.events)
- if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.JaxRsClientLogging") &&
- logEvent.getMarker().getName().equals("INVOKE")
- ){
- Map<String,String> mdc = logEvent.getMDCPropertyMap();
- assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
- assertEquals("GRM",mdc.get("TargetEntity"));
- assertEquals("INPROGRESS",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
- foundInvoke=true;
- }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.JaxRsClientLogging") &&
- logEvent.getMarker()!= null && logEvent.getMarker().getName().equals("INVOKE_RETURN")){
- Map<String,String> mdc = logEvent.getMDCPropertyMap();
- assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
- assertEquals("200",mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE));
- assertEquals("COMPLETED",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
- foundInvokeReturn=true;
- }
-
- if(!foundInvoke)
- fail("INVOKE Marker not found");
-
- if(!foundInvokeReturn)
- fail("INVOKE RETURN Marker not found");
-
- verify(postRequestedFor(urlEqualTo("/GRMLWPService/v1/serviceEndPoint/findRunning"))
- .withHeader(ONAPLogConstants.Headers.INVOCATION_ID.toString(), matching(uuidRegex))
- .withHeader(ONAPLogConstants.Headers.REQUEST_ID.toString(), matching(uuidRegex))
- .withHeader(ONAPLogConstants.Headers.PARTNER_NAME.toString(), equalTo("SO")));
- TestAppender.events.clear();
- }
-
- @Test
- public void testFindFail() throws Exception {
-
- wireMockRule.stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/findRunning"))
- .willReturn(aResponse()
- .withStatus(400)
- .withHeader("Content-Type", MediaType.APPLICATION_JSON)
- .withBody("")));
-
- GRMClient client = new GRMClient();
- thrown.expect(GRMClientCallFailed.class);
- client.findRunningServices("TEST.ECOMP_PSL.*", 1, "TEST");
- }
-
- @Test
- public void testAddFail() throws Exception {
- wireMockRule.stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/add"))
- .willReturn(aResponse()
- .withStatus(404)
- .withHeader("Content-Type", MediaType.APPLICATION_JSON)
- .withBody("test")));
- ServiceEndPointRequest request = new ServiceEndPointRequest();
- GRMClient client = new GRMClient();
- thrown.expect(GRMClientCallFailed.class);
- client.addServiceEndPoint(request);
- }
-
- @Test
- public void testBuildServiceEndPointLookupRequest() {
- GRMClient client = new GRMClient();
- ServiceEndPointLookupRequest request = client.buildServiceEndPointlookupRequest("TEST.ECOMP_PSL.Inventory", 1, "DEV");
- assertEquals("TEST.ECOMP_PSL.Inventory", request.getServiceEndPoint().getName());
- assertEquals(Integer.valueOf(1), Integer.valueOf(request.getServiceEndPoint().getVersion().getMajor()));
- assertEquals("DEV", request.getEnv());
-
- }
-
- protected String getFileContentsAsString(String fileName) {
- String content = "";
- try {
- ClassLoader classLoader = this.getClass().getClassLoader();
- File file = new File(classLoader.getResource(fileName).getFile());
- content = new String(Files.readAllBytes(file.toPath()));
- }
- catch(Exception e) {
- e.printStackTrace();
- System.out.println("Exception encountered reading " + fileName + ". Error: " + e.getMessage());
- }
- return content;
- }
-}
diff --git a/common/src/test/java/org/onap/so/web/exceptions/RuntimeExceptionMapperTest.java b/common/src/test/java/org/onap/so/web/exceptions/RuntimeExceptionMapperTest.java
index 8bcc73515b..b49c5312e5 100644
--- a/common/src/test/java/org/onap/so/web/exceptions/RuntimeExceptionMapperTest.java
+++ b/common/src/test/java/org/onap/so/web/exceptions/RuntimeExceptionMapperTest.java
@@ -33,16 +33,11 @@ import javax.ws.rs.core.Response.Status;
import org.junit.AfterClass;
import org.junit.Test;
-import org.onap.so.logger.MsoAlarmLogger;
+
public class RuntimeExceptionMapperTest {
-
- @AfterClass
- public static void tearDown() {
- MsoAlarmLogger logger = new MsoAlarmLogger();
- logger.resetAppender();
- }
+
@Test
public void testResponse() {