aboutsummaryrefslogtreecommitdiffstats
path: root/aai-resources/src/test/java/org
diff options
context:
space:
mode:
authorKajur, Harish (vk250x) <vk250x@att.com>2019-01-13 12:18:00 -0500
committerKajur, Harish (vk250x) <vk250x@att.com>2019-01-13 12:18:07 -0500
commit3289e79a0f0343cbd380a385d61e21f59ceff85c (patch)
treea74957c74fb41275aede412e5c43307fd3e0c859 /aai-resources/src/test/java/org
parent92ac3a80c822340c07b9d09189b85c34ac797122 (diff)
Sync up the changes for v15
Issue-ID: AAI-1811 Change-Id: I5c397d5907bb0711977f62ba84abe454f410a3b7 Signed-off-by: Kajur, Harish (vk250x) <vk250x@att.com>
Diffstat (limited to 'aai-resources/src/test/java/org')
-rw-r--r--aai-resources/src/test/java/org/onap/aai/IncreaseNodesToolTest.java5
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/DepthTest.java64
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/LegacyMoxyConsumerTest.java199
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java7
4 files changed, 205 insertions, 70 deletions
diff --git a/aai-resources/src/test/java/org/onap/aai/IncreaseNodesToolTest.java b/aai-resources/src/test/java/org/onap/aai/IncreaseNodesToolTest.java
index 5d91fb3..53b162f 100644
--- a/aai-resources/src/test/java/org/onap/aai/IncreaseNodesToolTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/IncreaseNodesToolTest.java
@@ -48,11 +48,8 @@ public class IncreaseNodesToolTest extends AAISetup {
@Mock
GraphTraversal<org.apache.tinkerpop.gremlin.structure.Vertex, org.apache.tinkerpop.gremlin.structure.Vertex> graphTraversalVertex;
-
private IncreaseNodesTool increaseNodesTool;
-
-
- String [] args = {"-numberOfNodes", "5" ,"-nodeType", "pserver", "-uri", "/cloud-infrastructure/pservers/pserver/"};
+ String [] args = {"-numberOfNodes", "5" ,"-nodeType", "pserver", "-uri", "/cloud-infrastructure/pservers/pserver/", "-child", "false"};
@Before
public void setup(){
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/DepthTest.java b/aai-resources/src/test/java/org/onap/aai/rest/DepthTest.java
deleted file mode 100644
index c664c22..0000000
--- a/aai-resources/src/test/java/org/onap/aai/rest/DepthTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.rest;
-
-import org.hamcrest.MatcherAssert;
-import org.junit.Test;
-import org.onap.aai.PayloadUtil;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-
-import java.io.IOException;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.not;
-
-public class DepthTest extends AbstractSpringRestTest {
-
- @Test
- public void testOldVersionReturnAllChildrenAndNewVersionReturnDepthZero() throws IOException {
-
- String id = "customer-987654321-91";
- String endpoint = "/aai/v9/business/customers/customer/"+ id;
-
- String body = PayloadUtil.getResourcePayload("customer.json");
-
- httpEntity = new HttpEntity(body, headers);
-
- ResponseEntity responseEntity;
- responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- assertThat(responseEntity.getStatusCode(), is(HttpStatus.CREATED));
-
- responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class);
- assertThat(responseEntity.getStatusCode(), is(HttpStatus.OK));
- String responseBody = responseEntity.getBody().toString();
- assertThat(responseBody, not(containsString("service-instance-id")));
- endpoint = "/aai/v8/business/customers/customer/"+ id;
-
- responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class);
- assertThat(responseEntity.getStatusCode(), is(HttpStatus.OK));
- responseBody = responseEntity.getBody().toString();
- assertThat(responseBody, containsString("service-instance-id"));
- }
-}
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/LegacyMoxyConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/LegacyMoxyConsumerTest.java
index 3845fb0..028f596 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/LegacyMoxyConsumerTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/LegacyMoxyConsumerTest.java
@@ -21,6 +21,9 @@ package org.onap.aai.rest;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+import org.json.JSONArray;
+import org.json.simple.parser.JSONParser;
+import org.json.simple.parser.ParseException;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Before;
@@ -121,6 +124,8 @@ public class LegacyMoxyConsumerTest extends AAISetup {
Mockito.doReturn(null).when(queryParameters).remove(anyObject());
when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
+
+
}
@Test
@@ -731,6 +736,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
int timeout = legacyMoxyConsumer.getTimeoutLimit("JUNITTESTAPP2", AAIConfig.get(AAIConstants.AAI_CRUD_TIMEOUT_APP), AAIConfig.get(AAIConstants.AAI_CRUD_TIMEOUT_LIMIT));
assertEquals(-1, timeout);
}
+ @Ignore("Time sensitive test only times out if the response takes longer than 1 second")
@Test
public void testTimeoutGetCall() throws Exception{
String uri = getUri();
@@ -789,4 +795,197 @@ public class LegacyMoxyConsumerTest extends AAISetup {
assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
}
+
+ @Test
+ public void testGetRelationshipWithoutFormat() throws IOException, JSONException {
+ String payload = getRelationshipPayload("pserver-complex-relationship-list2");
+ String pserverData = getRelationshipPayload("pserver2");
+ String complexData = getRelationshipPayload("complex2");
+
+ String hostname = "590a8943-1200-43b3-825b-75dde6b8f44b";
+ String physicalLocationId ="e13d4587-19ad-4bf5-80f5-c021efb5b61d";
+
+ String pserverUri = String.format("cloud-infrastructure/pservers/pserver/%s", hostname);
+ String cloudRegionUri = String.format("cloud-infrastructure/complexes/complex/%s", physicalLocationId);
+
+ doSetupResource(pserverUri, pserverData);
+ doSetupResource(cloudRegionUri, complexData);
+
+ String cloudToPserverRelationshipData = getRelationshipPayload("pserver-complex-relationship2");
+ String cloudToPserverRelationshipUri = String.format(
+ "cloud-infrastructure/pservers/pserver/%s/relationship-list/relationship", hostname);
+ MockHttpServletRequest mockReq = new MockHttpServletRequest("PUT", cloudToPserverRelationshipUri);
+ Response response = legacyMoxyConsumer.updateRelationship(
+ cloudToPserverRelationshipData,
+ schemaVersions.getDefaultVersion().toString(),
+ cloudToPserverRelationshipUri,
+ httpHeaders,
+ uriInfo,
+ mockReq
+ );
+
+ assertNotNull("Response from the legacy moxy consumer returned null", response);
+ int code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+
+ assertEquals("Expected to return status created from the response",
+ Response.Status.OK.getStatusCode(), response.getStatus());
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
+
+ String getRelationshipMockRequestUri = String.format(
+ "cloud-infrastructure/pservers/pserver/%s/relationship-list", hostname);
+ String getRelationshipUri = String.format(
+ "cloud-infrastructure/pservers/pserver/%s", hostname);
+ response = legacyMoxyConsumer.getRelationshipList(
+ "1",
+ "1",
+ schemaVersions.getDefaultVersion().toString(),
+ getRelationshipUri,
+ "false",
+ httpHeaders,
+ uriInfo
+ );
+
+ String s = response.getEntity().toString();
+
+ code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
+ JSONAssert.assertEquals(payload, response.getEntity().toString(), false);
+ }
+
+ @Test
+ public void testGetRelationshipWithFormat() throws IOException, JSONException, ParseException {
+ String payload = getRelationshipPayload("pserver-complex-relationship-list3");
+ String pserverData = getRelationshipPayload("pserver3");
+ String complexData = getRelationshipPayload("complex3");
+
+ String hostname = "590a8943-1200-43b3-825b-75dde6b8f44c";
+ String physicalLocationId ="e13d4587-19ad-4bf5-80f5-c021efb5b61e";
+
+ String pserverUri = String.format("cloud-infrastructure/pservers/pserver/%s", hostname);
+ String cloudRegionUri = String.format("cloud-infrastructure/complexes/complex/%s", physicalLocationId);
+
+ doSetupResource(pserverUri, pserverData);
+ doSetupResource(cloudRegionUri, complexData);
+
+ String cloudToPserverRelationshipData = getRelationshipPayload("pserver-complex-relationship3");
+ String cloudToPserverRelationshipUri = String.format(
+ "cloud-infrastructure/pservers/pserver/%s/relationship-list/relationship", hostname);
+ MockHttpServletRequest mockReq = new MockHttpServletRequest("PUT", cloudToPserverRelationshipUri);
+ Response response = legacyMoxyConsumer.updateRelationship(
+ cloudToPserverRelationshipData,
+ schemaVersions.getDefaultVersion().toString(),
+ cloudToPserverRelationshipUri,
+ httpHeaders,
+ uriInfo,
+ mockReq
+ );
+
+ assertNotNull("Response from the legacy moxy consumer returned null", response);
+ int code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+
+ assertEquals("Expected to return status created from the response",
+ Response.Status.OK.getStatusCode(), response.getStatus());
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
+
+ String getRelationshipMockRequestUri = String.format(
+ "cloud-infrastructure/pservers/pserver/%s/relationship-list", hostname);
+ String getRelationshipUri = String.format(
+ "cloud-infrastructure/pservers/pserver/%s", hostname);
+ queryParameters.add("format", "resource");
+ response = legacyMoxyConsumer.getRelationshipList(
+ "1",
+ "1",
+ schemaVersions.getDefaultVersion().toString(),
+ getRelationshipUri,
+ "false",
+ httpHeaders,
+ uriInfo
+ );
+ queryParameters.remove("format");
+
+ code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
+
+ String responsePayload = response.getEntity().toString();
+ JSONObject payloadJsonObject = new JSONObject(payload);
+ JSONObject responseJsonObject = new JSONObject(responsePayload);
+
+ JSONArray payloadResultsArray = payloadJsonObject.getJSONArray("results");
+ JSONArray responseResultsArray = responseJsonObject.getJSONArray("results");
+ assertEquals(payloadResultsArray.length(), responseResultsArray.length());
+
+ for (int i = 0; i < payloadResultsArray.length(); i++) {
+ String payloadResults = payloadResultsArray.get(i).toString();
+ String responseResults = responseResultsArray.get(i).toString();
+
+ JSONObject pserverPayloadObject = new JSONObject(payloadResults);
+ JSONObject pserverResponseObject = new JSONObject(responseResults);
+ String pserverPayload = pserverPayloadObject.get("pserver").toString();
+ String pserverResponse = pserverResponseObject.get("pserver").toString();
+
+ JSONObject pserverPayloadFields = new JSONObject(pserverPayload);
+ JSONObject pserverResponseFields = new JSONObject(pserverResponse);
+ String pserverPayloadHostname = pserverPayloadFields.get("hostname").toString();
+ String pserverResponseHostname = pserverResponseFields.get("hostname").toString();
+ String pserverPayloadInmaint = pserverPayloadFields.get("in-maint").toString();
+ String pserverResponseInmaint = pserverResponseFields.get("in-maint").toString();
+ String pserverPayloadRelationshipList = pserverPayloadFields.get("relationship-list").toString();
+ String pserverResponseRelationshipList = pserverResponseFields.get("relationship-list").toString();
+
+ assertEquals(pserverPayloadHostname, pserverResponseHostname);
+ assertEquals(pserverPayloadInmaint, pserverResponseInmaint);
+ assertEquals(pserverPayloadRelationshipList, pserverResponseRelationshipList);
+ }
+ }
+
+ @Test
+ public void testGetRelationshipWithoutSuppliedRelationship() throws IOException, JSONException {
+ String pserverData = getRelationshipPayload("pserver4");
+ String complexData = getRelationshipPayload("complex4");
+
+ String hostname = "590a8943-1200-43b3-825b-75dde6b8f44d";
+ String physicalLocationId ="e13d4587-19ad-4bf5-80f5-c021efb5b61f";
+
+ String pserverUri = String.format("cloud-infrastructure/pservers/pserver/%s", hostname);
+ String cloudRegionUri = String.format("cloud-infrastructure/complexes/complex/%s", physicalLocationId);
+
+ doSetupResource(pserverUri, pserverData);
+ doSetupResource(cloudRegionUri, complexData);
+
+ String getRelationshipMockRequestUri = String.format(
+ "cloud-infrastructure/pservers/pserver/%s/relationship-list", hostname);
+ String getRelationshipUri = String.format(
+ "cloud-infrastructure/pservers/pserver/%s", hostname);
+ MockHttpServletRequest mockReq = new MockHttpServletRequest("GET_RELATIONSHIP", getRelationshipMockRequestUri);
+ Response response = legacyMoxyConsumer.getRelationshipList(
+ "1",
+ "1",
+ schemaVersions.getDefaultVersion().toString(),
+ getRelationshipUri,
+ "false",
+ httpHeaders,
+ uriInfo
+ );
+
+ int code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
+ }
}
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java b/aai-resources/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java
index 1fae4a7..c629ca7 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java
@@ -108,7 +108,7 @@ public class RetiredConsumerSpringTest extends AbstractSpringRestTest {
private void setupNamedQueriesRetired() {
httpStatusMap = new HashMap<>();
- httpStatusMap.put("/aai/v8/cloud-infrastructure/pservers/pserver/samomaisdjfajsfoas", HttpStatus.NOT_FOUND);
+ httpStatusMap.put("/aai/v13/cloud-infrastructure/pservers/pserver/samomaisdjfajsfoas", HttpStatus.NOT_FOUND);
httpStatusMap.put("/aai/v8/service-design-and-creation/named-queries/named-query/samomaisdjfajsfoas", HttpStatus.GONE);
}
@@ -130,13 +130,16 @@ public class RetiredConsumerSpringTest extends AbstractSpringRestTest {
httpStatusMap.put("/aai/v4/cloud-infrastructure/pservers/pserver/test-pserver1", HttpStatus.GONE);
httpStatusMap.put("/aai/v5/cloud-infrastructure/pservers/pserver/test-pserver1", HttpStatus.GONE);
httpStatusMap.put("/aai/v6/cloud-infrastructure/pservers/pserver/test-pserver1", HttpStatus.GONE);
+ httpStatusMap.put("/aai/v7/cloud-infrastructure/pservers/pserver/test-pserver1", HttpStatus.GONE);
+ httpStatusMap.put("/aai/v8/cloud-infrastructure/pservers/pserver/test-pserver1", HttpStatus.GONE);
+ httpStatusMap.put("/aai/v9/cloud-infrastructure/pservers/pserver/test-pserver1", HttpStatus.GONE);
}
private void setupModelsRetired() {
httpStatusMap = new HashMap<>();
- httpStatusMap.put("/aai/v8/cloud-infrastructure/pservers/pserver/samomaisdjfajsfoas", HttpStatus.NOT_FOUND);
+ httpStatusMap.put("/aai/v8/cloud-infrastructure/pservers/pserver/samomaisdjfajsfoas", HttpStatus.GONE);
httpStatusMap.put("/aai/v8/service-design-and-creation/models/model/samomaisdjfajsfoas", HttpStatus.GONE);
}