diff options
Diffstat (limited to 'common/src')
9 files changed, 71 insertions, 9 deletions
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 9b5acc5bee..76413c2594 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 @@ import org.onap.so.client.graphinventory.entities.uri.SimpleUri; 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 091d0c9e97..329471243b 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 @@ import org.onap.so.client.aai.AAIResourcesClient; 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 3c9ca0ed7f..6ffc6ecd9b 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 @@ import org.onap.so.client.graphinventory.GraphInventoryObjectType; 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 00a213b264..324193dc84 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 @@ import org.onap.so.client.aai.AAIResourcesClient; 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 026f1c3929..874b06e192 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 java.util.Map; 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 @@ public class SimpleUri implements GraphInventoryResourceUri { this.values = childValues; } + protected void setInternalURI(UriBuilder builder) { + this.internalURI = builder; + } @Override public SimpleUri relationshipAPI() { this.internalURI = internalURI.path(relationshipAPI); @@ -236,4 +244,14 @@ public class SimpleUri implements GraphInventoryResourceUri { 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 be79c8b927..b11003ed1e 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 @@ import com.fasterxml.jackson.databind.ObjectMapper; 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 @@ public class SDNOValidatorImpl implements SDNOValidator { 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 fcf054f489..2a0e9df9ed 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 @@ public class AAISimpleUriTest { 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 1bcee07118..6383d0ea4c 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 @@ public class DefaultsTest { @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 cf386cb6fc..1a3e97c451 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 |