summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukasz Rajewski <lukasz.rajewski@t-mobile.pl>2023-08-16 12:36:00 +0000
committerGerrit Code Review <gerrit@onap.org>2023-08-16 12:36:00 +0000
commitd5a889f9661e89289344ed736600bc7222095379 (patch)
treee59f9627daf465ffb7efe4997080e326a0747210
parentf80d389842613bc961ae3f785580ab58f61b740a (diff)
parentbf21908f6aeac303c8e2e13cff090290e9f35886 (diff)
Merge "Refactor HttpEntryTest"
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/db/EdgeSerializer.java12
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java975
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/db/responses/ErrorResponse.java33
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/db/responses/Relationship.java69
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/db/responses/RelationshipData.java47
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/db/responses/RelationshipWrapper.java36
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/db/responses/RequestError.java33
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/db/responses/ServiceException.java53
8 files changed, 812 insertions, 446 deletions
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/db/EdgeSerializer.java b/aai-core/src/main/java/org/onap/aai/serialization/db/EdgeSerializer.java
index a5a08203..0c58717e 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/db/EdgeSerializer.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/db/EdgeSerializer.java
@@ -207,15 +207,9 @@ public class EdgeSerializer {
* @param rule the rule
*/
public void addProperties(Edge edge, EdgeRule rule) {
- Map<EdgeProperty, String> propMap = new EnumMap<>(EdgeProperty.class);
- propMap.put(EdgeProperty.CONTAINS, rule.getContains());
- propMap.put(EdgeProperty.DELETE_OTHER_V, rule.getDeleteOtherV());
- propMap.put(EdgeProperty.PREVENT_DELETE, rule.getPreventDelete());
-
- for (Entry<EdgeProperty, String> entry : propMap.entrySet()) {
- edge.property(entry.getKey().toString(), entry.getValue());
- }
-
+ edge.property(EdgeProperty.CONTAINS.toString(), rule.getContains());
+ edge.property(EdgeProperty.DELETE_OTHER_V.toString(), rule.getDeleteOtherV());
+ edge.property(EdgeProperty.PREVENT_DELETE.toString(), rule.getPreventDelete());
edge.property(EdgeField.PRIVATE.toString(), rule.isPrivateEdge());
edge.property(AAIProperties.AAI_UUID, UUID.randomUUID().toString());
}
diff --git a/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java b/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java
index 2499defc..371c07a5 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright © 2023 Deutsche Telekom.
+ * ================================================================================
* 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
@@ -20,14 +22,20 @@
package org.onap.aai.rest.db;
+import static org.onap.aai.edges.enums.AAIDirection.NONE;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.when;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
@@ -49,9 +57,14 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.javatuples.Pair;
import org.json.JSONArray;
import org.json.JSONObject;
+import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.FixMethodOrder;
@@ -62,16 +75,24 @@ import org.junit.runners.Parameterized;
import org.mockito.Mockito;
import org.onap.aai.AAISetup;
import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.edges.enums.EdgeField;
+import org.onap.aai.edges.enums.EdgeProperty;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.ModelType;
import org.onap.aai.parsers.query.QueryParser;
+import org.onap.aai.rest.db.responses.ErrorResponse;
+import org.onap.aai.rest.db.responses.Relationship;
+import org.onap.aai.rest.db.responses.RelationshipWrapper;
+import org.onap.aai.rest.db.responses.ServiceException;
import org.onap.aai.rest.ueb.UEBNotification;
import org.onap.aai.restcore.HttpMethod;
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.util.AAIConfig;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
@RunWith(value = Parameterized.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@@ -95,9 +116,13 @@ public class HttpEntryTest extends AAISetup {
*/
@Parameterized.Parameters(name = "QueryStyle.{0}")
public static Collection<Object[]> data() {
- return Arrays.asList(new Object[][] {{QueryStyle.TRAVERSAL}, {QueryStyle.TRAVERSAL_URI}});
+ return Arrays.asList(new Object[][] { { QueryStyle.TRAVERSAL }, { QueryStyle.TRAVERSAL_URI } });
}
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private GraphTraversalSource traversal;
+
private HttpHeaders httpHeaders;
private UriInfo uriInfo;
@@ -109,6 +134,8 @@ public class HttpEntryTest extends AAISetup {
private List<MediaType> outputMediaTypes;
+ ObjectMapper mapper = new ObjectMapper();
+
@Before
public void setup() {
@@ -130,6 +157,11 @@ public class HttpEntryTest extends AAISetup {
aaiRequestContextList = new ArrayList<>();
aaiRequestContextList.add("");
+ traversalHttpEntry.setHttpEntryProperties(schemaVersions.getDefaultVersion());
+ loader = traversalHttpEntry.getLoader();
+ dbEngine = traversalHttpEntry.getDbEngine();
+ traversal = dbEngine.tx().traversal();
+
when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
@@ -138,229 +170,529 @@ public class HttpEntryTest extends AAISetup {
when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
- // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
+ // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be
+ // very unreasonable
Mockito.doReturn(null).when(queryParameters).remove(any());
when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
}
- private Response doRequest(HttpEntry httpEntry, Loader loader, TransactionalGraphEngine dbEngine, HttpMethod method,
- String uri, String content) throws UnsupportedEncodingException, AAIException {
- URI uriObject = UriBuilder.fromPath(uri).build();
- QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(uriObject);
- String objType = uriQuery.getResultType();
- if (uri.endsWith("relationship")) {
- objType = "relationship";
- }
- Introspector obj;
- if (method.equals(HttpMethod.GET) || method.equals(HttpMethod.GET_RELATIONSHIP)) {
- obj = loader.introspectorFromName(objType);
- } else {
- obj = loader.unmarshal(objType, content, org.onap.aai.restcore.MediaType.getEnum("application/json"));
- }
-
- DBRequest dbRequest =
- new DBRequest.Builder(method, uriObject, uriQuery, obj, httpHeaders, uriInfo, "JUNIT-TRANSACTION")
- .rawRequestContent(content).build();
-
- List<DBRequest> dbRequestList = new ArrayList<>();
- dbRequestList.add(dbRequest);
-
- Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = httpEntry.process(dbRequestList, "JUNIT");
- return responsesTuple.getValue1().get(0).getValue1();
+ @After
+ public void rollback() {
+ dbEngine.rollback();
}
@Test
- public void test1PutOnPserver() throws UnsupportedEncodingException, AAIException {
+ public void thatObjectsCanBeRetrieved() throws UnsupportedEncodingException, AAIException {
+ String uri = "/cloud-infrastructure/pservers/pserver/theHostname";
+ traversal.addV()
+ .property("aai-node-type", "pserver")
+ .property("hostname", "theHostname")
+ .property("equip-type", "theEquipType")
+ .property(AAIProperties.AAI_URI, uri)
+ .next();
+ String requestBody = new JSONObject()
+ .put("hostname", "theHostname")
+ .put("equip-type", "theEquipType")
+ .toString();
+
+ Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET, uri, requestBody);
+ assertEquals("Expected the pserver to be returned", 200, response.getStatus());
+ }
- /*
- * TODO do the same with uri
- */
- traversalHttpEntry.setHttpEntryProperties(schemaVersions.getDefaultVersion());
- Loader loader = traversalHttpEntry.getLoader();
- TransactionalGraphEngine dbEngine = traversalHttpEntry.getDbEngine();
+ @Test
+ public void thatObjectsCanNotBeFound() throws UnsupportedEncodingException, AAIException {
+ String uri = "/cloud-infrastructure/pservers/pserver/junit-test2";
+ String requestBody = "";
- String uri = "/cloud-infrastructure/pservers/pserver/junit-test1";
- String content = "{\"hostname\":\"junit-test1\"}";
- Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
- dbEngine.commit();
- assertEquals("Expected the pserver to be created", 201, response.getStatus());
+ Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET, uri, requestBody);
+ assertEquals("The pserver is not found", 404, response.getStatus());
}
@Test
- public void test2PutOnPserverNoPInterface() throws UnsupportedEncodingException, AAIException {
+ public void thatObjectCanBeCreatedViaPUT() throws UnsupportedEncodingException, AAIException {
+ String uri = "/cloud-infrastructure/pservers/pserver/theHostname";
+ String requestBody = new JSONObject().put("hostname", "theHostname").toString();
- traversalHttpEntry.setHttpEntryProperties(schemaVersions.getDefaultVersion());
- Loader loader = traversalHttpEntry.getLoader();
- TransactionalGraphEngine dbEngine = traversalHttpEntry.getDbEngine();
-
- String uri = "/cloud-infrastructure/pservers/pserver/junit-test2";
- String content = "{\"hostname\":\"junit-test2\"}";
- Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
- dbEngine.commit();
- assertEquals("Expected the pserver to be created", 201, response.getStatus());
+ Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, requestBody);
+ assertEquals("Expecting the pserver to be created", 201, response.getStatus());
}
@Test
- public void test3PutOnPInterface() {
- try {
- traversalHttpEntry.setHttpEntryProperties(schemaVersions.getDefaultVersion());
- Loader loader = traversalHttpEntry.getLoader();
- TransactionalGraphEngine dbEngine = traversalHttpEntry.getDbEngine();
-
- String uri = "/cloud-infrastructure/pservers/pserver/junit-test1/p-interfaces/p-interface/p1";
- String content = "{\"interface-name\":\"p1\"}";
- Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
- dbEngine.commit();
- assertEquals("Expected the p-interface to be created", 201, response.getStatus());
- } catch (UnsupportedEncodingException | AAIException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ public void thatObjectCreationFailsWhenResourceVersionIsProvided()
+ throws UnsupportedEncodingException, AAIException, JsonMappingException, JsonProcessingException {
+ String uri = "/cloud-infrastructure/pservers/pserver/theHostname";
+ String requestBody = new JSONObject()
+ .put("hostname", "theHostname")
+ .put("resource-version", "123")
+ .toString();
+
+ Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, requestBody);
+ ErrorResponse errorResponseEntity = mapper.readValue(response.getEntity().toString(), ErrorResponse.class);
+ assertEquals("Expecting the pserver to be created", 412, response.getStatus());
+ assertEquals(
+ "Resource version specified on create:resource-version passed for create of /cloud-infrastructure/pservers/pserver/theHostname",
+ errorResponseEntity.getRequestError().getServiceException().getVariables().get(2));
}
@Test
- public void test4GetOnPserver() throws UnsupportedEncodingException, AAIException {
-
- traversalHttpEntry.setHttpEntryProperties(schemaVersions.getDefaultVersion());
-
- Loader loader = traversalHttpEntry.getLoader();
- TransactionalGraphEngine dbEngine = traversalHttpEntry.getDbEngine();
-
- String uri = "/cloud-infrastructure/pservers/pserver/junit-test1";
- String content = "{\"hostname\":\"junit-test1\", \"equip-type\":\"junit-equip-type\"}";
- Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET, uri, content);
- dbEngine.commit();
- assertEquals("Expected the pserver to be returned", 200, response.getStatus());
+ public void thatObjectCanBeUpdatedViaPUT() throws UnsupportedEncodingException, AAIException {
+ String uri = "/cloud-infrastructure/pservers/pserver/theHostname";
+ traversal.addV()
+ .property("aai-node-type", "pserver")
+ .property("hostname", "theHostname")
+ .property("number-of-cpus", "10")
+ .property(AAIProperties.AAI_URI, uri)
+ .property(AAIProperties.RESOURCE_VERSION, "123")
+ .next();
+ String requestBody = new JSONObject()
+ .put("hostname", "updatedHostname")
+ .put("resource-version", "123")
+ .toString();
+
+ Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, requestBody);
+ assertEquals("Expecting the pserver to be updated", 200, response.getStatus());
+ assertTrue("That old properties are removed",
+ traversal.V().has("hostname", "updatedHostname").hasNot("number-of-cpus").hasNext());
}
@Test
- public void test5MergePatchOnPserver() throws UnsupportedEncodingException, AAIException {
+ public void thatUpdateFailsWhenResourceVersionsMismatch()
+ throws UnsupportedEncodingException, AAIException, JsonMappingException, JsonProcessingException {
+ String uri = "/cloud-infrastructure/pservers/pserver/theHostname";
+ traversal.addV()
+ .property("aai-node-type", "pserver")
+ .property("hostname", "theHostname")
+ .property(AAIProperties.AAI_URI, uri)
+ .property(AAIProperties.RESOURCE_VERSION, "123")
+ .next();
+ String requestBody = new JSONObject()
+ .put("hostname", "updatedHostname")
+ .put("resource-version", "456")
+ .toString();
+
+ Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, requestBody);
+ ErrorResponse errorResponseEntity = mapper.readValue(response.getEntity().toString(), ErrorResponse.class);
+ assertEquals("Expecting the update to fail", 412, response.getStatus());
+ assertEquals(
+ "Precondition Failed:resource-version MISMATCH for update of /cloud-infrastructure/pservers/pserver/updatedHostname",
+ errorResponseEntity.getRequestError().getServiceException().getVariables().get(2));
+ }
- traversalHttpEntry.setHttpEntryProperties(schemaVersions.getDefaultVersion());
+ @Test
+ public void thatUpdateFailsWhenResourceVersionIsNotProvided()
+ throws UnsupportedEncodingException, AAIException, JsonMappingException, JsonProcessingException {
+ String uri = "/cloud-infrastructure/pservers/pserver/theHostname";
+ traversal.addV()
+ .property("aai-node-type", "pserver")
+ .property("hostname", "theHostname")
+ .property("in-maint", "false")
+ .property(AAIProperties.AAI_URI, uri)
+ .next();
+
+ String requestBody = new JSONObject()
+ .put("hostname", "theHostname")
+ .put("is-maint", "true")
+ .toString();
+
+ doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, requestBody);
+ Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, requestBody);
+ ErrorResponse errorResponseEntity = mapper.readValue(response.getEntity().toString(), ErrorResponse.class);
+ assertEquals("Request should fail when no resource-version is provided", 412, response.getStatus());
+ assertEquals(
+ "Precondition Required:resource-version not passed for update of /cloud-infrastructure/pservers/pserver/theHostname",
+ errorResponseEntity.getRequestError().getServiceException().getVariables().get(2));
+ }
- Loader loader = traversalHttpEntry.getLoader();
- TransactionalGraphEngine dbEngine = traversalHttpEntry.getDbEngine();
+ @Test
+ public void thatCreateViaPUTAddsRelationshipsToExistingObjects() throws UnsupportedEncodingException, AAIException {
+ traversal.addV()
+ .property("aai-node-type", "pserver")
+ .property("hostname", "hostname")
+ .property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/hostname")
+ .next();
+ String uri = "/cloud-infrastructure/pservers/pserver/hostname/p-interfaces/p-interface/p1";
+ String requestBody = new JSONObject().put("interface-name", "p1").toString();
+
+ Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, requestBody);
+ assertEquals("response is successful", 201, response.getStatus());
+ assertTrue("p-interface was created",
+ traversal.V().has("aai-node-type", "p-interface").has("interface-name", "p1").hasNext());
+ assertTrue("p-interface has outgoing edge to p-server",
+ traversal.V().has("aai-node-type", "p-interface").has("aai-uri", uri).has("interface-name", "p1")
+ .out("tosca.relationships.network.BindsTo").has("aai-node-type", "pserver")
+ .has("hostname", "hostname").hasNext());
+ }
- String uri = "/cloud-infrastructure/pservers/pserver/junit-test1";
- String content = "{\"hostname\":\"junit-test1\", \"equip-type\":\"junit-equip-type\"}";
- Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.MERGE_PATCH, uri, content);
- dbEngine.commit();
+ @Test
+ public void thatObjectsCanBePatched() throws UnsupportedEncodingException, AAIException {
+ String uri = "/cloud-infrastructure/pservers/pserver/the-hostname";
+ traversal.addV()
+ .property("aai-node-type", "pserver")
+ .property("hostname", "the-hostname")
+ .property("equip-type", "the-equip-type")
+ .property(AAIProperties.AAI_URI, uri)
+ .next();
+ String requestBody = new JSONObject()
+ .put("hostname", "new-hostname")
+ .toString();
+ Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.MERGE_PATCH, uri, requestBody);
assertEquals("Expected the pserver to be updated", 200, response.getStatus());
+ assertTrue("object should be updated while keeping old properties",
+ traversal.V().has("aai-node-type", "pserver").has("hostname", "new-hostname")
+ .has("equip-type", "the-equip-type").hasNext());
}
- private int doDelete(String resourceVersion, String uri, String nodeType)
- throws UnsupportedEncodingException, AAIException {
- queryParameters.add("resource-version", resourceVersion);
- traversalHttpEntry.setHttpEntryProperties(schemaVersions.getDefaultVersion());
- Loader loader = traversalHttpEntry.getLoader();
- TransactionalGraphEngine dbEngine = traversalHttpEntry.getDbEngine();
-
- URI uriObject = UriBuilder.fromPath(uri).build();
-
- QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(uriObject);
-
- String content = "";
-
- Introspector obj = loader.introspectorFromName(nodeType);
+ @Test
+ public void thatObjectsCanBeDeleted() throws UnsupportedEncodingException, AAIException {
+ String uri = "/cloud-infrastructure/pservers/pserver/the-hostname";
+ String resourceVersion = "123";
+ traversal.addV()
+ .property("aai-node-type", "pserver")
+ .property("hostname", "the-hostname")
+ .property(AAIProperties.AAI_URI, uri)
+ .property(AAIProperties.RESOURCE_VERSION, resourceVersion)
+ .next();
+ assertEquals("Expecting a No Content response", 204,
+ doDelete(resourceVersion, uri, "pserver").getStatus());
+ assertTrue("Expecting the pserver to be deleted",
+ !traversal.V().has("aai-node-type", "pserver").has("hostname", "the-hostname").hasNext());
+ }
- DBRequest dbRequest = new DBRequest.Builder(HttpMethod.DELETE, uriObject, uriQuery, obj, httpHeaders, uriInfo,
- "JUNIT-TRANSACTION").rawRequestContent(content).build();
+ @Test
+ public void thatRelationshipCanBeCreated() throws UnsupportedEncodingException, AAIException {
+ String uri = "/cloud-infrastructure/pservers/pserver/edge-test-pserver";
+ traversal.addV()
+ .property("aai-node-type", "pserver")
+ .property("hostname", "edge-test-pserver")
+ .property(AAIProperties.AAI_URI, uri)
+ .property(AAIProperties.RESOURCE_VERSION, "123")
+ .next();
+ uri = "/cloud-infrastructure/complexes/complex/edge-test-complex";
+ traversal.addV()
+ .property("aai-node-type", "complex")
+ .property("physical-location-id", "edge-test-complex")
+ .property("physical-location-type", "AAIDefault")
+ .property("street1", "AAIDefault")
+ .property("city", "AAIDefault")
+ .property("postal-code", "07748")
+ .property("country", "USA")
+ .property("region", "US")
+ .property(AAIProperties.AAI_URI, uri)
+ .property(AAIProperties.RESOURCE_VERSION, "234")
+ .next();
+
+ uri = "/cloud-infrastructure/complexes/complex/edge-test-complex/relationship-list/relationship";
+ String requestBody = new JSONObject()
+ .put("related-to", "pserver")
+ .put("related-link",
+ String.format("/aai/%s/cloud-infrastructure/pservers/pserver/edge-test-pserver",
+ schemaVersions.getDefaultVersion().toString()))
+ .put("relationship-label", "org.onap.relationships.inventory.LocatedIn")
+ .toString();
+
+ Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT_EDGE, uri, requestBody);
+ assertEquals("Expected the pserver relationship to be created", 200, response.getStatus());
+ GraphTraversal<Vertex, Vertex> vertexQuery = traversal.V()
+ .has("aai-node-type", "complex")
+ .has("physical-location-id", "edge-test-complex")
+ .in("org.onap.relationships.inventory.LocatedIn")
+ .has("aai-node-type", "pserver")
+ .has("hostname", "edge-test-pserver");
+ GraphTraversal<Edge, Edge> edgeQuery = traversal.E()
+ .has(EdgeField.PRIVATE.toString(), "false")
+ .has(EdgeProperty.CONTAINS.toString(), NONE.toString())
+ .has(EdgeProperty.DELETE_OTHER_V.toString(), NONE.toString())
+ .has(EdgeProperty.PREVENT_DELETE.toString(), "IN");
+ assertTrue("p-server has incoming edge from complex", vertexQuery.hasNext());
+ assertTrue("Created Edge has expected properties", edgeQuery.hasNext());
+ }
- List<DBRequest> dbRequestList = new ArrayList<>();
- dbRequestList.add(dbRequest);
+ @Test
+ public void thatRelationshipCanNotBeCreatedEdgeMultiplicity()
+ throws UnsupportedEncodingException, AAIException, JsonMappingException, JsonProcessingException {
+ String uri = "/cloud-infrastructure/pservers/pserver/httpEntryTest-pserver-01";
+ traversal
+ .addV() // pserver
+ .property("aai-node-type", "pserver")
+ .property("hostname", "httpEntryTest-pserver-01")
+ .property(AAIProperties.AAI_URI, uri)
+ .property(AAIProperties.RESOURCE_VERSION, "123")
+ .as("v1")
+ .addV() // complex
+ .property("aai-node-type", "complex")
+ .property("physical-location-id", "httpEntryTest-complex-01")
+ .property("physical-location-type", "AAIDefault")
+ .property("street1", "AAIDefault")
+ .property("city", "AAIDefault")
+ .property("postal-code", "07748")
+ .property("country", "USA")
+ .property("region", "US")
+ .property(AAIProperties.AAI_URI, "/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01")
+ .property(AAIProperties.RESOURCE_VERSION, "234")
+ .as("v2")
+ // edge between pserver and complex
+ .addE("org.onap.relationships.inventory.LocatedIn").from("v1").to("v2")
+ .next();
- Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = traversalHttpEntry.process(dbRequestList, "JUNIT");
- Response response = responsesTuple.getValue1().get(0).getValue1();
- dbEngine.commit();
- return response.getStatus();
+ // Put Relationship
+ uri = "/cloud-infrastructure/pservers/pserver/httpEntryTest-pserver-01/relationship-list/relationship";
+ String requestBody = new JSONObject()
+ .put("related-to", "complex")
+ .put("related-link",
+ String.format("/aai/%s/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01",
+ schemaVersions.getDefaultVersion().toString()))
+ .put("relationship-label", "org.onap.relationships.inventory.LocatedIn")
+ .toString();
+ Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT_EDGE, uri, requestBody);
+ ServiceException serviceException = mapper.readValue(response.getEntity().toString(), ErrorResponse.class)
+ .getRequestError().getServiceException();
+
+ assertEquals("Expected the response code to be Bad Request", 400, response.getStatus());
+ assertEquals("ERR.5.4.6140", serviceException.getVariables().get(3));
+ assertEquals(
+ "Edge multiplicity violated:multiplicity rule violated: only one edge can exist with label: org.onap.relationships.inventory.LocatedIn between pserver and complex",
+ serviceException.getVariables().get(2));
}
@Test
- public void test6DeleteOnPserver() throws UnsupportedEncodingException, AAIException {
+ public void putEdgeWrongLabelTest()
+ throws UnsupportedEncodingException, AAIException, JsonMappingException, JsonProcessingException {
+ String uri = "/cloud-infrastructure/pservers/pserver/edge-test-pserver";
+ traversal.addV()
+ .property("aai-node-type", "pserver")
+ .property("hostname", "edge-test-pserver")
+ .property(AAIProperties.AAI_URI, uri)
+ .property(AAIProperties.RESOURCE_VERSION, "123")
+ .next();
+ uri = "/cloud-infrastructure/complexes/complex/edge-test-complex";
+ traversal.addV()
+ .property("aai-node-type", "complex")
+ .property("physical-location-id", "edge-test-complex")
+ .property("physical-location-type", "AAIDefault")
+ .property("street1", "AAIDefault")
+ .property("city", "AAIDefault")
+ .property("postal-code", "07748")
+ .property("country", "USA")
+ .property("region", "US")
+ .property(AAIProperties.AAI_URI, uri)
+ .property(AAIProperties.RESOURCE_VERSION, "234")
+ .next();
+
+ uri = "/cloud-infrastructure/complexes/complex/edge-test-complex/relationship-list/relationship";
+ String requestBody = new JSONObject()
+ .put("related-to", "pserver")
+ .put("related-link",
+ String.format("/aai/%s/cloud-infrastructure/pservers/pserver/edge-test-pserver",
+ schemaVersions.getDefaultVersion().toString()))
+ .put("relationship-label", "does.not.exist")
+ .toString();
+
+ Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT_EDGE, uri, requestBody);
+ ServiceException serviceException = mapper.readValue(response.getEntity().toString(), ErrorResponse.class)
+ .getRequestError().getServiceException();
- traversalHttpEntry.setHttpEntryProperties(schemaVersions.getDefaultVersion());
- Loader loader = traversalHttpEntry.getLoader();
- TransactionalGraphEngine dbEngine = traversalHttpEntry.getDbEngine();
-
- String uri = "/cloud-infrastructure/pservers/pserver/junit-test1";
- String content = "";
- Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET, uri, content);
- dbEngine.commit();
- String msg = response.getEntity().toString();
- JsonObject jsonObj = JsonParser.parseString(msg).getAsJsonObject();
- String resourceVersion = "";
- if (jsonObj.isJsonObject()) {
- resourceVersion = jsonObj.get("resource-version").getAsString();
- }
- assertEquals("Expected the pserver to be deleted", 204,
- doDelete(resourceVersion, "/cloud-infrastructure/pservers/pserver/junit-test1", "pserver"));
+ assertEquals("Expected the pserver to be created", 400, response.getStatus());
+ assertEquals("ERR.5.4.6107", serviceException.getVariables().get(3));
+ assertEquals(
+ "Required Edge-property not found in input data:org.onap.aai.edges.exceptions.EdgeRuleNotFoundException: No rule found for EdgeRuleQuery with filter params node type: complex, node type: pserver, label: does.not.exist, type: COUSIN, isPrivate: false.",
+ serviceException.getVariables().get(2));
}
@Test
- public void test7DeleteOnPserverNoPinterface() throws UnsupportedEncodingException, AAIException {
+ public void thatObjectsCanBeRetrievedInPathedResponseFormat() throws UnsupportedEncodingException, AAIException {
+ traversal
+ .addV() // pserver
+ .property("aai-node-type", "pserver")
+ .property("hostname", "pserver-1")
+ .property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/pserver-1")
+ .property(AAIProperties.RESOURCE_VERSION, "123")
+ .addV() // pserver
+ .property("aai-node-type", "pserver")
+ .property("hostname", "pserver-2")
+ .property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/pserver-2")
+ .property(AAIProperties.RESOURCE_VERSION, "234")
+ .next();
- traversalHttpEntry.setHttpEntryProperties(schemaVersions.getDefaultVersion());
- // HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, queryStyle, type);
- Loader loader = traversalHttpEntry.getLoader();
- TransactionalGraphEngine dbEngine = traversalHttpEntry.getDbEngine();
+ queryParameters.add("format", "pathed");
+ String requestBody = "";
+ Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET,
+ "/cloud-infrastructure/pservers", requestBody);
+ queryParameters.remove("format");
- String uri = "/cloud-infrastructure/pservers/pserver/junit-test2";
- String content = "";
- Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET, uri, content);
- dbEngine.commit();
- String msg = response.getEntity().toString();
- JsonObject jsonObj = JsonParser.parseString(msg).getAsJsonObject();
- String resourceVersion = "";
- if (jsonObj.isJsonObject()) {
- resourceVersion = jsonObj.get("resource-version").getAsString();
- }
- assertEquals("Expected the pserver to be deleted", 204,
- doDelete(resourceVersion, "/cloud-infrastructure/pservers/pserver/junit-test2", "pserver"));
+ String responseEntity = response.getEntity().toString();
+ assertEquals("Expected get to succeed", 200, response.getStatus());
+ assertThat(responseEntity, containsString("/cloud-infrastructure/pservers/pserver/pserver-1"));
+ assertThat(responseEntity, containsString("/cloud-infrastructure/pservers/pserver/pserver-2"));
}
@Test
- public void test8FailedGetOnPserver() throws UnsupportedEncodingException, AAIException {
-
- traversalHttpEntry.setHttpEntryProperties(schemaVersions.getDefaultVersion());
- // HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, queryStyle, type);
- Loader loader = traversalHttpEntry.getLoader();
- TransactionalGraphEngine dbEngine = traversalHttpEntry.getDbEngine();
-
- String uri = "/cloud-infrastructure/pservers/pserver/junit-test2";
- String content = "";
- Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET, uri, content);
- dbEngine.commit();
+ public void thatRelatedObjectsCanBeRetrieved() throws UnsupportedEncodingException, AAIException {
+ String uri = "/cloud-infrastructure/pservers/pserver/related-to-pserver";
+ traversal
+ .addV() // pserver
+ .property("aai-node-type", "pserver")
+ .property("hostname", "related-to-pserver")
+ .property(AAIProperties.AAI_URI, uri)
+ .property(AAIProperties.RESOURCE_VERSION, "123")
+ .as("v1")
+ .addV() // complex
+ .property("aai-node-type", "complex")
+ .property("physical-location-id", "related-to-complex")
+ .property("physical-location-type", "AAIDefault")
+ .property("street1", "AAIDefault")
+ .property("city", "AAIDefault")
+ .property("postal-code", "07748")
+ .property("country", "USA")
+ .property("region", "US")
+ .property(AAIProperties.AAI_URI, "/cloud-infrastructure/complexes/complex/related-to-complex")
+ .property(AAIProperties.RESOURCE_VERSION, "234")
+ .as("v2")
+ // edge between pserver and complex
+ .addE("org.onap.relationships.inventory.LocatedIn").from("v1").to("v2")
+ .next();
+
+ uri = "/cloud-infrastructure/complexes/complex/related-to-complex/related-to/pservers";
+ String responseBody = "";
+ Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET, uri, responseBody);
+
+ assertEquals("Expected the response to be successful", 200, response.getStatus());
+ assertThat("Related pserver is returned", response.getEntity().toString(),
+ containsString("\"hostname\":\"related-to-pserver\""));
- assertEquals("Expected the pserver to be deleted", 404, response.getStatus());
}
@Test
- public void putEdgeTest() throws UnsupportedEncodingException, AAIException {
+ public void getAbstractTest() throws UnsupportedEncodingException, AAIException {
+ String uri = "/cloud-infrastructure/pservers/pserver/abstract-pserver";
+ traversal
+ .addV() // pserver
+ .property("aai-node-type", "pserver")
+ .property("hostname", "abstract-pserver")
+ .property(AAIProperties.AAI_URI, uri)
+ .property(AAIProperties.RESOURCE_VERSION, "123")
+ .as("v1")
+ .addV() // generic-vnf
+ .property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "abstract-generic-vnf")
+ .property("vnf-name", "the-vnf-name")
+ .property(AAIProperties.AAI_URI, "/network/generic-vnfs/generic-vnf/abstract-generic-vnf")
+ .property(AAIProperties.RESOURCE_VERSION, "234")
+ .as("v2")
+ // edge between pserver and generic-vnf
+ .addE("tosca.relationships.HostedOn").from("v2").to("v1")
+ .next();
+
+ String requestBody = "";
+ uri = "/network/generic-vnfs/generic-vnf/abstract-generic-vnf/related-to/pservers";
+ Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET, uri, requestBody);
+ assertThat("Related to pserver is returned.", response.getEntity().toString(),
+ containsString("\"hostname\":\"abstract-pserver\""));
+ }
- traversalHttpEntry.setHttpEntryProperties(schemaVersions.getDefaultVersion());
- // HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, queryStyle, type);
- Loader loader = traversalHttpEntry.getLoader();
- TransactionalGraphEngine dbEngine = traversalHttpEntry.getDbEngine();
+ @Test
+ public void getRelationshipListTest()
+ throws UnsupportedEncodingException, AAIException, JsonMappingException, JsonProcessingException {
+ String uri = "/cloud-infrastructure/pservers/pserver/related-to-pserver";
+ traversal
+ .addV() // pserver
+ .property("aai-node-type", "pserver")
+ .property("hostname", "related-to-pserver")
+ .property(AAIProperties.AAI_URI, uri)
+ .property(AAIProperties.RESOURCE_VERSION, "123")
+ .as("v1")
+ .addV() // complex
+ .property("aai-node-type", "complex")
+ .property("physical-location-id", "related-to-complex")
+ .property("physical-location-type", "AAIDefault")
+ .property("street1", "AAIDefault")
+ .property("city", "AAIDefault")
+ .property("postal-code", "07748")
+ .property("country", "USA")
+ .property("region", "US")
+ .property(AAIProperties.AAI_URI, "/cloud-infrastructure/complexes/complex/related-to-complex")
+ .property(AAIProperties.RESOURCE_VERSION, "234")
+ .as("v2")
+ // edge between pserver and complex
+ .addE("org.onap.relationships.inventory.LocatedIn").from("v1").to("v2")
+ // these properties are required when finding related edges
+ .property(EdgeProperty.CONTAINS.toString(), NONE.toString())
+ .property(EdgeField.PRIVATE.toString(), "false")
+ .next();
- // Put pserver
- String uri = "/cloud-infrastructure/pservers/pserver/junit-edge-test-pserver";
- String content = "{\"hostname\":\"junit-edge-test-pserver\"}";
- doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
- // Put complex
- uri = "/cloud-infrastructure/complexes/complex/junit-edge-test-complex";
- content =
- "{\"physical-location-id\":\"junit-edge-test-complex\",\"physical-location-type\":\"AAIDefault\",\"street1\":\"AAIDefault\",\"city\":\"AAIDefault\",\"state\":\"NJ\",\"postal-code\":\"07748\",\"country\":\"USA\",\"region\":\"US\"}";
- doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
+ // Get Relationship
+ uri = "/cloud-infrastructure/pservers/pserver/related-to-pserver";
+ String requestBody = "";
+ Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET_RELATIONSHIP, uri,
+ requestBody);
+ Relationship[] relationships = mapper.readValue(response.getEntity().toString(), RelationshipWrapper.class)
+ .getRelationships();
+
+ assertEquals("complex", relationships[0].getRelatedTo());
+ assertEquals("org.onap.relationships.inventory.LocatedIn", relationships[0].getRelationshipLabel());
+ assertEquals("/aai/v14/cloud-infrastructure/complexes/complex/related-to-complex",
+ relationships[0].getRelatedLink());
+ assertEquals("complex.physical-location-id", relationships[0].getRelationshipData()[0].getRelationshipKey());
+ assertEquals("related-to-complex", relationships[0].getRelationshipData()[0].getRelationshipValue());
+ }
- // PutEdge
- uri = "/cloud-infrastructure/complexes/complex/junit-edge-test-complex/relationship-list/relationship";
- content = "{\"related-to\":\"pserver\",\"related-link\":\"/aai/" + schemaVersions.getDefaultVersion().toString()
- + "/cloud-infrastructure/pservers/pserver/junit-edge-test-pserver\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\"}";
- Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT_EDGE, uri, content);
+ @Test
+ public void getRelationshipListTestWithFormatSimple() throws UnsupportedEncodingException, AAIException {
+ String uri = "/cloud-infrastructure/pservers/pserver/related-to-pserver";
+ traversal
+ .addV() // pserver
+ .property("aai-node-type", "pserver")
+ .property("hostname", "related-to-pserver")
+ .property(AAIProperties.AAI_URI, uri)
+ .property(AAIProperties.RESOURCE_VERSION, "123")
+ .as("v1")
+ .addV() // complex
+ .property("aai-node-type", "complex")
+ .property("physical-location-id", "related-to-complex")
+ .property("physical-location-type", "AAIDefault")
+ .property("street1", "AAIDefault")
+ .property("city", "AAIDefault")
+ .property("postal-code", "07748")
+ .property("country", "USA")
+ .property("region", "US")
+ .property(AAIProperties.AAI_URI, "/cloud-infrastructure/complexes/complex/related-to-complex")
+ .property(AAIProperties.RESOURCE_VERSION, "234")
+ .as("v2")
+ // edge between pserver and complex
+ .addE("org.onap.relationships.inventory.LocatedIn").from("v1").to("v2")
+ // these properties are required when finding related edges
+ .property(EdgeProperty.CONTAINS.toString(), NONE.toString())
+ .property(EdgeField.PRIVATE.toString(), "false")
+ .next();
- dbEngine.rollback();
- assertEquals("Expected the pserver relationship to be created", 200, response.getStatus());
+ // Get Relationship
+ uri = "/cloud-infrastructure/pservers/pserver/related-to-pserver";
+ queryParameters.add("format", "resource");
+ String requestBody = "";
+ Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET_RELATIONSHIP, uri,
+ requestBody);
+
+ JSONObject actualResponseBody = new JSONObject(response.getEntity().toString());
+
+ // Define the expected response
+ JSONObject relationshipData = new JSONObject().put("relationship-key", "complex.physical-location-id")
+ .put("relationship-value", "related-to-complex");
+ JSONObject relationship = new JSONObject()
+ .put("related-to", "complex")
+ .put("relationship-label", "org.onap.relationships.inventory.LocatedIn")
+ .put("related-link",
+ String.format("/aai/%s/cloud-infrastructure/complexes/complex/related-to-complex",
+ schemaVersions.getDefaultVersion()))
+ .put("relationship-data", new JSONArray().put(relationshipData));
+ JSONObject pserver = new JSONObject()
+ .put("hostname", "related-to-pserver")
+ .put("resource-version", "123")
+ .put("relationship-list", new JSONObject().put("relationship", new JSONArray().put(relationship)));
+ JSONObject expectedResponseBody = new JSONObject()
+ .put("results", new JSONArray().put(new JSONObject().put("pserver", pserver)));
+
+ JSONAssert.assertEquals(expectedResponseBody, actualResponseBody, JSONCompareMode.NON_EXTENSIBLE);
+ queryParameters.remove("format");
}
@Test
@@ -378,8 +710,7 @@ public class HttpEntryTest extends AAISetup {
doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
// Put complex
uri = "/cloud-infrastructure/complexes/complex/junit-edge-test-complex";
- content =
- "{\"physical-location-id\":\"junit-edge-test-complex\",\"physical-location-type\":\"AAIDefault\",\"street1\":\"AAIDefault\",\"city\":\"AAIDefault\",\"state\":\"NJ\",\"postal-code\":\"07748\",\"country\":\"USA\",\"region\":\"US\"}";
+ content = "{\"physical-location-id\":\"junit-edge-test-complex\",\"physical-location-type\":\"AAIDefault\",\"street1\":\"AAIDefault\",\"city\":\"AAIDefault\",\"state\":\"NJ\",\"postal-code\":\"07748\",\"country\":\"USA\",\"region\":\"US\"}";
doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
// PutEdge
@@ -410,120 +741,50 @@ public class HttpEntryTest extends AAISetup {
}
- @Test
- public void putEdgeWrongLabelTest() throws UnsupportedEncodingException, AAIException {
-
- traversalHttpEntry.setHttpEntryProperties(schemaVersions.getDefaultVersion());
- // HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, queryStyle, type);
- Loader loader = traversalHttpEntry.getLoader();
- TransactionalGraphEngine dbEngine = traversalHttpEntry.getDbEngine();
-
- // Put pserver
- String uri = "/cloud-infrastructure/pservers/pserver/junit-edge-test-pserver";
- String content = "{\"hostname\":\"junit-edge-test-pserver\"}";
- doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
- // Put complex
- uri = "/cloud-infrastructure/complexes/complex/junit-edge-test-complex";
- content =
- "{\"physical-location-id\":\"junit-edge-test-complex\",\"physical-location-type\":\"AAIDefault\",\"street1\":\"AAIDefault\",\"city\":\"AAIDefault\",\"state\":\"NJ\",\"postal-code\":\"07748\",\"country\":\"USA\",\"region\":\"US\"}";
- doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
-
- // PutEdge
- uri = "/cloud-infrastructure/complexes/complex/junit-edge-test-complex/relationship-list/relationship";
- content = "{\"related-to\":\"pserver\",\"related-link\":\"/aai/" + schemaVersions.getDefaultVersion().toString()
- + "/cloud-infrastructure/pservers/pserver/junit-edge-test-pserver\",\"relationship-label\":\"junk\"}";
- Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT_EDGE, uri, content);
-
- dbEngine.rollback();
- String msg = response.getEntity().toString();
- assertEquals("Expected the pserver to be created", 400, response.getStatus());
- assertThat(msg, containsString("ERR.5.4.6107"));
- assertThat(msg, containsString(
- "Required Edge-property not found in input data:org.onap.aai.edges.exceptions.EdgeRuleNotFoundException: No rule found for EdgeRuleQuery with filter params node type: complex, node type: pserver, label: junk, type: COUSIN, isPrivate: false"));
-
- }
-
- @Test
- public void pathedFormatOnGetTest() throws UnsupportedEncodingException, AAIException {
-
- final String testName = new Object() {}.getClass().getEnclosingMethod().getName();
-
- traversalHttpEntry.setHttpEntryProperties(schemaVersions.getDefaultVersion());
- // HttpEntry httpEntry = new HttpEntry(schemaVersions.getDefaultVersion(), ModelType.MOXY, QueryStyle.TRAVERSAL,
- // type);
- Loader loader = traversalHttpEntry.getLoader();
- TransactionalGraphEngine dbEngine = traversalHttpEntry.getDbEngine();
-
- // Put pserver
- String pserverKey = "pserver-" + testName;
- String pserverUri = "/cloud-infrastructure/pservers/pserver/" + pserverKey;
- String content = "{\"hostname\":\"" + pserverKey + "\"}";
- doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, pserverUri, content);
-
- // Put complex
- String complexKey = "complex-" + testName;
- String complexUri = "/cloud-infrastructure/complexes/complex/" + complexKey;
- content = "{\"physical-location-id\":\"" + complexKey
- + "\",\"physical-location-type\":\"AAIDefault\",\"street1\":\"AAIDefault\",\"city\":\"AAIDefault\",\"state\":\"NJ\",\"postal-code\":\"07748\",\"country\":\"USA\",\"region\":\"US\"}";
- doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, complexUri, content);
-
- // PutEdge
- String relationshipUri =
- "/cloud-infrastructure/complexes/complex/" + complexKey + "/relationship-list/relationship";
- content = "{\"related-to\":\"pserver\",\"related-link\":\"/aai/" + schemaVersions.getDefaultVersion().toString()
- + "/cloud-infrastructure/pservers/pserver/" + pserverKey
- + "\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\"}";
- doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT_EDGE, relationshipUri, content);
-
- // Get pserver with pathed
- queryParameters.add("format", "pathed");
- content = "";
- Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET, pserverUri, content);
- queryParameters.remove("format");
+ private Response doRequest(HttpEntry httpEntry, Loader loader, TransactionalGraphEngine dbEngine, HttpMethod method,
+ String uri, String requestBody) throws UnsupportedEncodingException, AAIException {
+ URI uriObject = UriBuilder.fromPath(uri).build();
+ QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(uriObject);
+ String objType = uriQuery.getResultType();
+ if (uri.endsWith("relationship")) {
+ objType = "relationship";
+ }
+ Introspector obj;
+ if (method.equals(HttpMethod.GET) || method.equals(HttpMethod.GET_RELATIONSHIP)) {
+ obj = loader.introspectorFromName(objType);
+ } else {
+ obj = loader.unmarshal(objType, requestBody, org.onap.aai.restcore.MediaType.getEnum("application/json"));
+ }
- String msg = response.getEntity().toString();
- assertEquals("Expected get to succeed", 200, response.getStatus());
- assertThat(msg, containsString(pserverUri));
+ DBRequest dbRequest = new DBRequest.Builder(method, uriObject, uriQuery, obj, httpHeaders, uriInfo,
+ "JUNIT-TRANSACTION")
+ .rawRequestContent(requestBody).build();
- dbEngine.rollback();
+ List<DBRequest> dbRequestList = new ArrayList<>();
+ dbRequestList.add(dbRequest);
+ Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = httpEntry.process(dbRequestList, "JUNIT");
+ return responsesTuple.getValue1().get(0).getValue1();
}
- @Test
- public void getAllPserversTest() throws UnsupportedEncodingException, AAIException {
-
- final String testName = new Object() {}.getClass().getEnclosingMethod().getName();
-
- traversalHttpEntry.setHttpEntryProperties(schemaVersions.getDefaultVersion());
- Loader loader = traversalHttpEntry.getLoader();
- TransactionalGraphEngine dbEngine = traversalHttpEntry.getDbEngine();
+ private Response doDelete(String resourceVersion, String uri, String nodeType)
+ throws UnsupportedEncodingException, AAIException {
+ queryParameters.add("resource-version", resourceVersion);
- // Put pserver
- String pserver1Key = "pserver-1-" + testName;
- String pserver1Uri = "/cloud-infrastructure/pservers/pserver/" + pserver1Key;
- String content = "{\"hostname\":\"" + pserver1Key + "\"}";
- doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, pserver1Uri, content);
+ URI uriObject = UriBuilder.fromPath(uri).build();
- // Put complex
- String pserver2Key = "pserver-2-" + testName;
- String pserver2Uri = "/cloud-infrastructure/pservers/pserver/" + pserver2Key;
- content = "{\"hostname\":\"" + pserver2Key + "\"}";
- doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, pserver2Uri, content);
+ QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(uriObject);
- // Get pserver with pathed
- queryParameters.add("format", "pathed");
- content = "";
- Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET,
- "/cloud-infrastructure/pservers", content);
- queryParameters.remove("format");
+ String content = "";
- String msg = response.getEntity().toString();
- assertEquals("Expected get to succeed", 200, response.getStatus());
- assertThat(msg, containsString(pserver1Uri));
- assertThat(msg, containsString(pserver2Uri));
+ Introspector obj = loader.introspectorFromName(nodeType);
- dbEngine.rollback();
+ DBRequest dbRequest = new DBRequest.Builder(HttpMethod.DELETE, uriObject, uriQuery, obj, httpHeaders, uriInfo,
+ "JUNIT-TRANSACTION").rawRequestContent(content).build();
+ Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = traversalHttpEntry.process(Arrays.asList(dbRequest),
+ "JUNIT");
+ return responsesTuple.getValue1().get(0).getValue1();
}
@Test
@@ -540,42 +801,6 @@ public class HttpEntryTest extends AAISetup {
}
@Test
- public void relatedToTest() throws UnsupportedEncodingException, AAIException {
-
- traversalHttpEntry.setHttpEntryProperties(schemaVersions.getDefaultVersion());
- Loader loader = traversalHttpEntry.getLoader();
- TransactionalGraphEngine dbEngine = traversalHttpEntry.getDbEngine();
-
- // Put pserver
- String uri = "/cloud-infrastructure/pservers/pserver/junit-edge-test-pserver";
- String content = "{\"hostname\":\"junit-edge-test-pserver\"}";
- doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
- // Put complex
- uri = "/cloud-infrastructure/complexes/complex/junit-edge-test-complex";
- content =
- "{\"physical-location-id\":\"junit-edge-test-complex\",\"physical-location-type\":\"AAIDefault\",\"street1\":\"AAIDefault\",\"city\":\"AAIDefault\",\"state\":\"NJ\",\"postal-code\":\"07748\",\"country\":\"USA\",\"region\":\"US\"}";
- doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
-
- // PutEdge
- uri = "/cloud-infrastructure/complexes/complex/junit-edge-test-complex/relationship-list/relationship";
- content = "{\"related-to\":\"pserver\",\"related-link\":\"/aai/" + schemaVersions.getDefaultVersion().toString()
- + "/cloud-infrastructure/pservers/pserver/junit-edge-test-pserver\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\"}";
- doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT_EDGE, uri, content);
-
- // getRelatedTo
- uri = "/cloud-infrastructure/complexes/complex/junit-edge-test-complex/related-to/pservers";
- content = "";
- Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET, uri, content);
- String respBody = response.getEntity().toString();
-
- dbEngine.rollback();
- assertEquals("Expected the pserver to be created", 200, response.getStatus());
- assertThat("Related to pserver is returned.", respBody,
- containsString("\"hostname\":\"junit-edge-test-pserver\""));
-
- }
-
- @Test
public void setDepthTest() throws AAIException {
System.setProperty("AJSC_HOME", ".");
System.setProperty("BUNDLECONFIG_DIR", "src/main/test/resources");
@@ -585,128 +810,4 @@ public class HttpEntryTest extends AAISetup {
int depth = traversalHttpEntry.setDepth(null, depthParam);
assertEquals(AAIProperties.MAXIMUM_DEPTH.intValue(), depth);
}
-
- @Test
- public void getAbstractTest() throws UnsupportedEncodingException, AAIException {
-
- traversalHttpEntry.setHttpEntryProperties(schemaVersions.getDefaultVersion());
- Loader loader = traversalHttpEntry.getLoader();
- TransactionalGraphEngine dbEngine = traversalHttpEntry.getDbEngine();
-
- // Put generic-vnf
- String uri = "/network/generic-vnfs/generic-vnf/junit-abstract-test-generic-vnf";
- String content = "{\"vnf-id\":\"junit-abstract-test-generic-vnf\",\"vnf-name\":\"junit-generic-vnf-name\"}";
- doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
-
- // Put pserver
- uri = "/cloud-infrastructure/pservers/pserver/junit-abstract-test-pserver";
- content = "{\"hostname\":\"junit-abstract-test-pserver\"}";
- doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
-
- // PutEdge
- uri = "/cloud-infrastructure/pservers/pserver/junit-abstract-test-pserver/relationship-list/relationship";
- content =
- "{\"related-to\":\"vnf\",\"relationship-data\":[{\"relationship-key\":\"vnf.vnf-id\",\"relationship-value\":\"junit-abstract-test-generic-vnf\"}]}";
- doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT_EDGE, uri, content);
-
- // getRelatedTo
- uri = "/network/generic-vnfs/generic-vnf/junit-abstract-test-generic-vnf/related-to/pservers";
- content = "";
- Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET, uri, content);
- String respBody = response.getEntity().toString();
-
- dbEngine.rollback();
- assertThat("Related to pserver is returned.", respBody,
- containsString("\"hostname\":\"junit-abstract-test-pserver\""));
- }
-
- @Test
- public void getRelationshipListTest() throws UnsupportedEncodingException, AAIException {
- traversalHttpEntry.setHttpEntryProperties(schemaVersions.getDefaultVersion());
- Loader loader = traversalHttpEntry.getLoader();
- TransactionalGraphEngine dbEngine = traversalHttpEntry.getDbEngine();
-
- // Put pserver
- String uri = "/cloud-infrastructure/pservers/pserver/httpEntryTest-pserver-01";
- String content = "{\"hostname\":\"httpEntryTest-pserver-01\"}";
- doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
- // Put complex
- uri = "/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01";
- content =
- "{\"physical-location-id\":\"httpEntryTest-complex-01\",\"physical-location-type\":\"AAIDefault\",\"street1\":\"AAIDefault\",\"city\":\"AAIDefault\",\"state\":\"NJ\",\"postal-code\":\"07748\",\"country\":\"USA\",\"region\":\"US\"}";
- doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
-
- // Put Relationship
- uri = "/cloud-infrastructure/pservers/pserver/httpEntryTest-pserver-01/relationship-list/relationship";
- content = "{\"related-to\":\"complex\",\"related-link\":\"/aai/" + schemaVersions.getDefaultVersion().toString()
- + "/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\"}"
- + "\"relationship-daasSta\":[{" + "\"relationship-key\":\"complex.physical-location-id\","
- + "\"relationship-value\":\"httpEntryTest-complex-01\"" + "}]";
- Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT_EDGE, uri, content);
- assertEquals("Expected the pserver relationship to be created", 200, response.getStatus());
-
- // Get Relationship
- uri = "/cloud-infrastructure/pservers/pserver/httpEntryTest-pserver-01";
- content = "";
- response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET_RELATIONSHIP, uri, content);
- String expected =
- "{\"relationship\":[{\"related-to\":\"complex\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\",\"related-link\":\"/aai/v14/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01\",\"relationship-data\":[{\"relationship-key\":\"complex.physical-location-id\",\"relationship-value\":\"httpEntryTest-complex-01\"}]}]}";
- Assert.assertEquals(expected, response.getEntity().toString());
-
- dbEngine.rollback();
- }
-
- @Test
- public void getRelationshipListTestWithFormatSimple() throws UnsupportedEncodingException, AAIException {
- traversalHttpEntry.setHttpEntryProperties(schemaVersions.getDefaultVersion());
- Loader loader = traversalHttpEntry.getLoader();
- TransactionalGraphEngine dbEngine = traversalHttpEntry.getDbEngine();
-
- // Put pserver
- String uri = "/cloud-infrastructure/pservers/pserver/httpEntryTest-pserver-01";
- String content = "{\"hostname\":\"httpEntryTest-pserver-01\"}";
- doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
- // Put complex
- uri = "/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01";
- content =
- "{\"physical-location-id\":\"httpEntryTest-complex-01\",\"physical-location-type\":\"AAIDefault\",\"street1\":\"AAIDefault\",\"city\":\"AAIDefault\",\"state\":\"NJ\",\"postal-code\":\"07748\",\"country\":\"USA\",\"region\":\"US\"}";
- doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
-
- // Put Relationship
- uri = "/cloud-infrastructure/pservers/pserver/httpEntryTest-pserver-01/relationship-list/relationship";
- content = "{\"related-to\":\"complex\",\"related-link\":\"/aai/" + schemaVersions.getDefaultVersion().toString()
- + "/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\"}"
- + "\"relationship-daasSta\":[{" + "\"relationship-key\":\"complex.physical-location-id\","
- + "\"relationship-value\":\"httpEntryTest-complex-01\"" + "}]";
- Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT_EDGE, uri, content);
- assertEquals("Expected the pserver relationship to be created", 200, response.getStatus());
-
- // GET complex
- uri = "/cloud-infrastructure/pservers/pserver/httpEntryTest-pserver-01";
- content = "";
- response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET, uri, content);
-
- // Get Relationship
- uri = "/cloud-infrastructure/pservers/pserver/httpEntryTest-pserver-01";
- queryParameters.add("format", "resource");
- content = "";
- response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET_RELATIONSHIP, uri, content);
- String responsePayload = response.getEntity().toString();
- JSONObject responseJsonObject = new JSONObject(responsePayload);
- JSONArray responseResultsArray = responseJsonObject.getJSONArray("results");
- String responseResults = responseResultsArray.get(0).toString();
- JSONObject pserverResponseObject = new JSONObject(responseResults);
- String pserverResponse = pserverResponseObject.get("pserver").toString();
- JSONObject pserverResponseFields = new JSONObject(pserverResponse);
- String pserverResponseRelationshipList = pserverResponseFields.get("relationship-list").toString();
-
- String expected =
- "{\"relationship\":[{\"related-to\":\"complex\",\"relationship-data\":[{\"relationship-value\":\"httpEntryTest-complex-01\",\"relationship-key\":\"complex.physical-location-id\"}],\"related-link\":\"/aai/v14/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\"}]}";
- assertEquals(expected, pserverResponseRelationshipList);
- // Assert.assertEquals(expected, response.getEntity().toString());
- queryParameters.remove("format");
-
- dbEngine.rollback();
- }
-
}
diff --git a/aai-core/src/test/java/org/onap/aai/rest/db/responses/ErrorResponse.java b/aai-core/src/test/java/org/onap/aai/rest/db/responses/ErrorResponse.java
new file mode 100644
index 00000000..1e80df64
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/rest/db/responses/ErrorResponse.java
@@ -0,0 +1,33 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2023 Deutsche Telekom. 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.aai.rest.db.responses;
+
+public class ErrorResponse {
+ private RequestError requestError;
+
+ public RequestError getRequestError() {
+ return requestError;
+ }
+
+ public void setRequestError(RequestError requestError) {
+ this.requestError = requestError;
+ }
+}
diff --git a/aai-core/src/test/java/org/onap/aai/rest/db/responses/Relationship.java b/aai-core/src/test/java/org/onap/aai/rest/db/responses/Relationship.java
new file mode 100644
index 00000000..be146e50
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/rest/db/responses/Relationship.java
@@ -0,0 +1,69 @@
+package org.onap.aai.rest.db.responses;
+
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2023 Deutsche Telekom. 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=========================================================
+ */
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class Relationship {
+ @JsonProperty("related-to")
+ private String relatedTo;
+
+ @JsonProperty("relationship-label")
+ private String relationshipLabel;
+
+ @JsonProperty("related-link")
+ private String relatedLink;
+
+ @JsonProperty("relationship-data")
+ private RelationshipData[] relationshipData;
+
+ public String getRelatedTo() {
+ return relatedTo;
+ }
+
+ public void setRelatedTo(String relatedTo) {
+ this.relatedTo = relatedTo;
+ }
+
+ public String getRelationshipLabel() {
+ return relationshipLabel;
+ }
+
+ public void setRelationshipLabel(String relationshipLabel) {
+ this.relationshipLabel = relationshipLabel;
+ }
+
+ public String getRelatedLink() {
+ return relatedLink;
+ }
+
+ public void setRelatedLink(String relatedLink) {
+ this.relatedLink = relatedLink;
+ }
+
+ public RelationshipData[] getRelationshipData() {
+ return relationshipData;
+ }
+
+ public void setRelationshipData(RelationshipData[] relationshipData) {
+ this.relationshipData = relationshipData;
+ }
+}
diff --git a/aai-core/src/test/java/org/onap/aai/rest/db/responses/RelationshipData.java b/aai-core/src/test/java/org/onap/aai/rest/db/responses/RelationshipData.java
new file mode 100644
index 00000000..8a46a8c9
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/rest/db/responses/RelationshipData.java
@@ -0,0 +1,47 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2023 Deutsche Telekom. 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.aai.rest.db.responses;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class RelationshipData {
+ @JsonProperty("relationship-key")
+ private String relationshipKey;
+
+ @JsonProperty("relationship-value")
+ private String relationshipValue;
+
+ public String getRelationshipKey() {
+ return relationshipKey;
+ }
+
+ public void setRelationshipKey(String relationshipKey) {
+ this.relationshipKey = relationshipKey;
+ }
+
+ public String getRelationshipValue() {
+ return relationshipValue;
+ }
+
+ public void setRelationshipValue(String relationshipValue) {
+ this.relationshipValue = relationshipValue;
+ }
+}
diff --git a/aai-core/src/test/java/org/onap/aai/rest/db/responses/RelationshipWrapper.java b/aai-core/src/test/java/org/onap/aai/rest/db/responses/RelationshipWrapper.java
new file mode 100644
index 00000000..2dbd5ade
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/rest/db/responses/RelationshipWrapper.java
@@ -0,0 +1,36 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2023 Deutsche Telekom. 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.aai.rest.db.responses;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class RelationshipWrapper {
+ @JsonProperty("relationship")
+ private Relationship[] relationships;
+
+ public Relationship[] getRelationships() {
+ return relationships;
+ }
+
+ public void setRelationships(Relationship[] relationships) {
+ this.relationships = relationships;
+ }
+}
diff --git a/aai-core/src/test/java/org/onap/aai/rest/db/responses/RequestError.java b/aai-core/src/test/java/org/onap/aai/rest/db/responses/RequestError.java
new file mode 100644
index 00000000..7ee7ae27
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/rest/db/responses/RequestError.java
@@ -0,0 +1,33 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2023 Deutsche Telekom. 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.aai.rest.db.responses;
+
+public class RequestError {
+ private ServiceException serviceException;
+
+ public ServiceException getServiceException() {
+ return serviceException;
+ }
+
+ public void setServiceException(ServiceException serviceException) {
+ this.serviceException = serviceException;
+ }
+}
diff --git a/aai-core/src/test/java/org/onap/aai/rest/db/responses/ServiceException.java b/aai-core/src/test/java/org/onap/aai/rest/db/responses/ServiceException.java
new file mode 100644
index 00000000..5a495fe0
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/rest/db/responses/ServiceException.java
@@ -0,0 +1,53 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2023 Deutsche Telekom. 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.aai.rest.db.responses;
+
+import java.util.List;
+
+public class ServiceException {
+ private String messageId;
+ private String text;
+ private List<String> variables;
+
+ public String getMessageId() {
+ return messageId;
+ }
+
+ public void setMessageId(String messageId) {
+ this.messageId = messageId;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public List<String> getVariables() {
+ return variables;
+ }
+
+ public void setVariables(List<String> variables) {
+ this.variables = variables;
+ }
+}