summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/OperationalEnvironment.java80
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/PombaClientImpl.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/PombaRestInterface.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/CsvServiceImpl.java4
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java13
6 files changed, 89 insertions, 21 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
index 6a8439fee..1710d984f 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
@@ -195,6 +195,7 @@ public class AaiClient implements AaiClientInterface {
return new AaiResponse(e.getCause(), "AAI response parsing Error" , HttpStatus.SC_INTERNAL_SERVER_ERROR);
}
catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger,"Exception in aai response parsing", e);
return new AaiResponse(e.getCause(), "Got " + aaiResponse.getHttpCode() + " from a&ai" , aaiResponse.getHttpCode());
}
}
@@ -335,8 +336,8 @@ public class AaiClient implements AaiClientInterface {
encodedParam= URLEncoder.encode(param, "UTF-8");
} catch (UnsupportedEncodingException e) {
String methodName = "getUrlFromList";
- logger.error(EELFLoggerDelegate.errorLogger, methodName + e.toString());
- logger.debug(EELFLoggerDelegate.debugLogger, methodName + e.toString());
+ logger.error(EELFLoggerDelegate.errorLogger, methodName, e);
+ logger.debug(EELFLoggerDelegate.debugLogger, methodName, e);
}
url = url.concat(encodedParam);
if(i != params.size()){
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/OperationalEnvironment.java b/vid-app-common/src/main/java/org/onap/vid/aai/OperationalEnvironment.java
index fd4f6c7f5..be6c6e51f 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/OperationalEnvironment.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/OperationalEnvironment.java
@@ -20,9 +20,9 @@
package org.onap.vid.aai;
+import org.onap.vid.aai.model.RelationshipList;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
-import org.onap.vid.aai.model.RelationshipList;
@JsonIgnoreProperties(ignoreUnknown = true)
public class OperationalEnvironment {
@@ -39,15 +39,75 @@ public class OperationalEnvironment {
public OperationalEnvironment() {
}
- public OperationalEnvironment(String operationalEnvironmentId, String operationalEnvironmentName, String operationalEnvironmentType, String operationalEnvironmentStatus, String tenantContext, String workloadContext, String resourceVersion, RelationshipList relationshipList) {
- this.operationalEnvironmentId = operationalEnvironmentId;
- this.operationalEnvironmentName = operationalEnvironmentName;
- this.operationalEnvironmentType = operationalEnvironmentType;
- this.operationalEnvironmentStatus = operationalEnvironmentStatus;
- this.tenantContext = tenantContext;
- this.workloadContext = workloadContext;
- this.resourceVersion = resourceVersion;
- this.relationshipList = relationshipList;
+ public OperationalEnvironment(OperationalEnvironmentBuilder builder) {
+ this.operationalEnvironmentId = builder.operationalEnvironmentId;
+ this.operationalEnvironmentName = builder.operationalEnvironmentName;
+ this.operationalEnvironmentType = builder.operationalEnvironmentType;
+ this.operationalEnvironmentStatus = builder.operationalEnvironmentStatus;
+ this.tenantContext = builder.tenantContext;
+ this.workloadContext = builder.workloadContext;
+ this.resourceVersion = builder.resourceVersion;
+ this.relationshipList = builder.relationshipList;
+ }
+
+ public static class OperationalEnvironmentBuilder {
+ private String operationalEnvironmentId;
+ private String operationalEnvironmentName;
+ private String operationalEnvironmentType;
+ private String operationalEnvironmentStatus;
+ private String tenantContext;
+ private String workloadContext;
+ private String resourceVersion;
+ private RelationshipList relationshipList;
+
+ public OperationalEnvironmentBuilder setOperationalEnvironmentId(
+ String operationalEnvironmentId) {
+ this.operationalEnvironmentId = operationalEnvironmentId;
+ return this;
+ }
+
+ public OperationalEnvironmentBuilder setOperationalEnvironmentName(
+ String operationalEnvironmentName) {
+ this.operationalEnvironmentName = operationalEnvironmentName;
+ return this;
+ }
+
+ public OperationalEnvironmentBuilder setOperationalEnvironmentType(
+ String operationalEnvironmentType) {
+ this.operationalEnvironmentType = operationalEnvironmentType;
+ return this;
+ }
+
+ public OperationalEnvironmentBuilder setOperationalEnvironmentStatus(
+ String operationalEnvironmentStatus) {
+ this.operationalEnvironmentStatus = operationalEnvironmentStatus;
+ return this;
+ }
+
+ public OperationalEnvironmentBuilder setTenantContext(String tenantContext) {
+ this.tenantContext = tenantContext;
+ return this;
+ }
+
+ public OperationalEnvironmentBuilder setWorkloadContext(String workloadContext) {
+ this.workloadContext = workloadContext;
+ return this;
+ }
+
+ public OperationalEnvironmentBuilder setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ return this;
+ }
+
+ public OperationalEnvironmentBuilder setRelationshipList(
+ RelationshipList relationshipList) {
+ this.relationshipList = relationshipList;
+ return this;
+ }
+
+ public OperationalEnvironment createOperationalEnvironment() {
+ return new OperationalEnvironment(this);
+ }
}
public String getOperationalEnvironmentId() {
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/PombaClientImpl.java b/vid-app-common/src/main/java/org/onap/vid/aai/PombaClientImpl.java
index 1ee4da0b4..5641bc502 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/PombaClientImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/PombaClientImpl.java
@@ -51,8 +51,8 @@ public class PombaClientImpl implements PombaClientInterface {
try {
pombaRestInterface.RestPost(fromAppId, uri, new ObjectMapper().writeValueAsString(request));
} catch (Exception e) {
- logger.info(EELFLoggerDelegate.errorLogger, methodName + e.toString());
- logger.debug(EELFLoggerDelegate.debugLogger, methodName + e.toString());
+ logger.info(EELFLoggerDelegate.errorLogger, methodName, e);
+ logger.debug(EELFLoggerDelegate.debugLogger, methodName, e);
}
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/PombaRestInterface.java b/vid-app-common/src/main/java/org/onap/vid/aai/PombaRestInterface.java
index 129a61041..b118901a4 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/PombaRestInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/PombaRestInterface.java
@@ -50,8 +50,8 @@ public class PombaRestInterface extends AAIRestInterface {
client = httpsAuthClientFactory.getClient(HttpClientMode.WITH_KEYSTORE);
}
catch (Exception e) {
- logger.info(EELFLoggerDelegate.errorLogger, "Exception in REST call to DB in initRestClient" + e.toString());
- logger.debug(EELFLoggerDelegate.debugLogger, "Exception in REST call to DB : " + e.toString());
+ logger.info(EELFLoggerDelegate.errorLogger, "Exception in REST call to DB in initRestClient", e);
+ logger.debug(EELFLoggerDelegate.debugLogger, "Exception in REST call to DB : ", e);
}
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/CsvServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/CsvServiceImpl.java
index 4a5564e9c..4aabdae21 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/CsvServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/CsvServiceImpl.java
@@ -197,7 +197,9 @@ public class CsvServiceImpl implements CsvService{
currentJson.put(new JSONObject().put(key, values));
} else {
JSONObject lastItem = lastItemInArray(currentJson);
- lastItem.put(key, values);
+ if(lastItem != null) {
+ lastItem.put(key, values);
+ }
}
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java
index c331b3252..076c46284 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java
@@ -56,10 +56,15 @@ public class OperationalEnvironmentTest {
RelationshipList relationshipList = new RelationshipList();
relationshipList.relationship = new ArrayList<>();
- OperationalEnvironment operationalEnvironment = new OperationalEnvironment("testId",
- "testEnvName", "testEnvType",
- "testEnvStatus", "testTenant", "testWorkload",
- "testResource", relationshipList);
+ OperationalEnvironment operationalEnvironment =
+ new OperationalEnvironment.OperationalEnvironmentBuilder()
+ .setOperationalEnvironmentId("testId")
+ .setOperationalEnvironmentName("testEnvName")
+ .setOperationalEnvironmentType("testEnvType")
+ .setOperationalEnvironmentStatus("testEnvStatus")
+ .setTenantContext("testTenant").setWorkloadContext("testWorkload")
+ .setResourceVersion("testResource").setRelationshipList(relationshipList)
+ .createOperationalEnvironment();
assertThat(operationalEnvironment.getOperationalEnvironmentId()).isEqualTo("testId");
assertThat(operationalEnvironment.getWorkloadContext()).isEqualTo("testWorkload");