Bug fixes October 26th
Set non-custom health diagnostic check code to a default value.
created custom java serialization for SimpleUri
changed property value for cloud-owner in unit test
converted aai call to use the AAI Client
Correct a JUnit data file to include userParams values that are
expected to be set.
Set userParams on requestContext to parameters that need to be passed
to downstream systems.
Change-Id: I3974691875ef967f90a15f076ae27bc0cd76ee8e
Issue-ID: SO-1169
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java
index 9b5acc5..76413c2 100644
--- a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java
+++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java
@@ -34,6 +34,8 @@
public class AAISimpleUri extends SimpleUri implements AAIResourceUri {
+ private static final long serialVersionUID = -6397024057188453229L;
+
protected AAISimpleUri(AAIObjectType type, Object... values) {
super(type, values);
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/AllottedResourceLookupUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/AllottedResourceLookupUri.java
index 091d0c9..3294712 100644
--- a/common/src/main/java/org/onap/so/client/aai/entities/uri/AllottedResourceLookupUri.java
+++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/AllottedResourceLookupUri.java
@@ -30,6 +30,7 @@
public class AllottedResourceLookupUri extends HttpLookupUri {
+ private static final long serialVersionUID = -9212594383876793188L;
protected AllottedResourceLookupUri(Object... values) {
super(AAIObjectType.ALLOTTED_RESOURCE, values);
}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesUri.java
index 3c9ca0e..6ffc6ec 100644
--- a/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesUri.java
+++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesUri.java
@@ -29,6 +29,8 @@
public class NodesUri extends AAISimpleUri {
+ private static final long serialVersionUID = 8818689895730182042L;
+
protected NodesUri(AAIObjectType type, Object... values) {
super(type, values);
}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUri.java
index 00a213b..324193d 100644
--- a/common/src/main/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUri.java
+++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUri.java
@@ -30,6 +30,7 @@
public class ServiceInstanceUri extends HttpLookupUri {
+ private static final long serialVersionUID = 2248914170527514548L;
protected ServiceInstanceUri(Object... values) {
super(AAIObjectType.SERVICE_INSTANCE, values);
}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java
index 026f1c3..874b06e 100644
--- a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java
+++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java
@@ -20,6 +20,10 @@
package org.onap.so.client.graphinventory.entities.uri;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
@@ -29,18 +33,19 @@
import javax.ws.rs.core.UriBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.onap.so.client.graphinventory.Format;
import org.onap.so.client.aai.entities.uri.AAIUri;
-import org.onap.so.client.graphinventory.entities.uri.Depth;
-import org.onap.so.client.graphinventory.entities.uri.parsers.UriParser;
-import org.onap.so.client.graphinventory.entities.uri.parsers.UriParserSpringImpl;
+import org.onap.so.client.graphinventory.Format;
import org.onap.so.client.graphinventory.GraphInventoryObjectPlurals;
import org.onap.so.client.graphinventory.GraphInventoryObjectType;
+import org.onap.so.client.graphinventory.entities.uri.parsers.UriParser;
+import org.onap.so.client.graphinventory.entities.uri.parsers.UriParserSpringImpl;
import org.springframework.web.util.UriUtils;
-public class SimpleUri implements GraphInventoryResourceUri {
+public class SimpleUri implements GraphInventoryResourceUri, Serializable {
- protected UriBuilder internalURI;
+ private static final long serialVersionUID = -337701171277616439L;
+
+ protected transient UriBuilder internalURI;
protected final static String relationshipAPI = "/relationship-list/relationship";
protected final static String relatedTo = "/related-to";
protected final Object[] values;
@@ -89,6 +94,9 @@
this.values = childValues;
}
+ protected void setInternalURI(UriBuilder builder) {
+ this.internalURI = builder;
+ }
@Override
public SimpleUri relationshipAPI() {
this.internalURI = internalURI.path(relationshipAPI);
@@ -236,4 +244,14 @@
return type.uriTemplate();
}
+ private void writeObject(ObjectOutputStream oos) throws IOException {
+ oos.defaultWriteObject();
+ oos.writeUTF(this.internalURI.toTemplate());
+ }
+
+ private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
+ ois.defaultReadObject();
+ String uri = ois.readUTF();
+ this.setInternalURI(UriBuilder.fromUri(uri));
+ }
}
diff --git a/common/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java b/common/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java
index be79c8b..b11003e 100644
--- a/common/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java
+++ b/common/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java
@@ -47,6 +47,7 @@
public class SDNOValidatorImpl implements SDNOValidator {
private final static String clientName = "MSO";
+ private final static String HEALTH_DIAGNOSTIC_CODE_DEFAULT = "default";
@Override
public boolean healthDiagnostic(String vnfId, UUID uuid, String requestingUserId) throws IOException, Exception {
@@ -99,6 +100,7 @@
request.setRequestNodeIp(vnf.getIpv4OamAddress()); //generic-vnf oam ip
request.setRequestUserId(requestingUserId); //mech id?
request.setRequestId(uuid.toString()); //something to identify this request by for polling
+ request.setHealthDiagnosticCode(HEALTH_DIAGNOSTIC_CODE_DEFAULT);
input.setRequestHealthDiagnostic(request);
diff --git a/common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriTest.java b/common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriTest.java
index fcf054f..2a0e9df 100644
--- a/common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriTest.java
@@ -21,15 +21,24 @@
package org.onap.so.client.aai.entities.uri;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
import static org.hamcrest.collection.IsEmptyCollection.empty;
+import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
import static org.junit.Assert.assertEquals;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.util.Map;
import org.junit.Test;
import org.onap.so.client.aai.AAIObjectPlurals;
import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.graphinventory.entities.uri.Depth;
+import org.onap.so.client.graphinventory.entities.uri.SimpleUri;
public class AAISimpleUriTest {
@@ -83,4 +92,31 @@
assertEquals("my value", keys.get("service-type"));
}
+
+ @Test
+ public void serializeTest() throws IOException, ClassNotFoundException {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1");
+
+ uri.depth(Depth.ONE);
+ uri.limit(1);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+
+ ObjectOutputStream objectOutputStream
+ = new ObjectOutputStream(bos);
+ objectOutputStream.writeObject(uri);
+ objectOutputStream.flush();
+ objectOutputStream.close();
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+
+ ObjectInputStream objectInputStream
+ = new ObjectInputStream(bis);
+ AAIResourceUri e2 = (AAIResourceUri) objectInputStream.readObject();
+ objectInputStream.close();
+
+ uri.queryParam("test", "value");
+ e2.queryParam("test", "value");
+
+ assertEquals(e2.build().toString(), uri.build().toString());
+ }
}
diff --git a/common/src/test/java/org/onap/so/constants/DefaultsTest.java b/common/src/test/java/org/onap/so/constants/DefaultsTest.java
index 1bcee07..6383d0e 100644
--- a/common/src/test/java/org/onap/so/constants/DefaultsTest.java
+++ b/common/src/test/java/org/onap/so/constants/DefaultsTest.java
@@ -41,6 +41,6 @@
@Test
public void checkValue() {
- assertEquals("CloudOwner", Defaults.CLOUD_OWNER.toString());
+ assertEquals("my-custom-owner", Defaults.CLOUD_OWNER.toString());
}
}
diff --git a/common/src/test/resources/application-test.yaml b/common/src/test/resources/application-test.yaml
index cf386cb..1a3e97c 100644
--- a/common/src/test/resources/application-test.yaml
+++ b/common/src/test/resources/application-test.yaml
@@ -1,4 +1,4 @@
org:
onap:
so:
- cloud-owner: CloudOwner
\ No newline at end of file
+ cloud-owner: my-custom-owner
\ No newline at end of file