diff options
author | LaMont, William(wl2432) <wl2432@att.com> | 2020-04-17 16:46:13 -0400 |
---|---|---|
committer | LaMont, William(wl2432) <wl2432@att.com> | 2020-04-20 09:10:49 -0400 |
commit | 87f84fdb2df41aa7c00de94018fe606939d4d6f7 (patch) | |
tree | 0badd3a0d4bde6c899b3ea51286d0799dda05487 /aai-traversal/src/test/java/org/onap/aai/rest/RecentApiTest.java | |
parent | 5cf32ed7941231f55819a6f5e39e7f674d174009 (diff) |
update traversal processing for v19
Issue-ID: AAI-2866
Change-Id: I344e095e6f1d3b117971c1c78e50ae58bebf27e4
Signed-off-by: LaMont, William(wl2432) <wl2432@att.com>
Diffstat (limited to 'aai-traversal/src/test/java/org/onap/aai/rest/RecentApiTest.java')
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/RecentApiTest.java | 65 |
1 files changed, 53 insertions, 12 deletions
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/RecentApiTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/RecentApiTest.java index 43ac7c2..10ff7b9 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/RecentApiTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/RecentApiTest.java @@ -19,22 +19,45 @@ */ package org.onap.aai.rest; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.janusgraph.core.JanusGraphTransaction; import org.junit.Test; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; +import org.onap.aai.dbmap.AAIGraph; +import org.springframework.http.*; import org.springframework.web.util.UriComponentsBuilder; -import com.att.eelf.configuration.EELFLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.att.eelf.configuration.EELFManager; +import java.util.Collections; + +import static org.junit.Assert.*; + public class RecentApiTest extends AbstractSpringRestTest { - private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(RecentApiTest.class); + private static final Logger LOGGER = LoggerFactory.getLogger(RecentApiTest.class); + + @Override + public void createTestGraph() { + JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction(); + boolean success = true; + try { + GraphTraversalSource g = transaction.traversal(); + g.addV().property("aai-node-type", "pserver").property("hostname", "test-pserver-recents") + .property("in-maint", false).property("source-of-truth", "JUNIT") + .property("aai-uri", "/cloud-infrastructure/pservers/pserver/test-pserver-recents").next(); + } catch (Exception ex) { + success = false; + } finally { + if (success) { + transaction.commit(); + } else { + transaction.rollback(); + fail("Unable to setup the graph"); + } + } + } @Test public void testRecentsQuery() { @@ -44,10 +67,28 @@ public class RecentApiTest extends AbstractSpringRestTest { UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseUrl + endpoint).queryParam("hours", "190"); ResponseEntity responseEntity = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, httpEntity, String.class); - LOGGER.debug("Response for PUT request with uri {} : {}", builder.toUriString(), responseEntity.getBody()); - assertNotNull("Response from /aai/recents/v14/pserver is null", responseEntity); - assertEquals("Expected the response to be 400", HttpStatus.OK, responseEntity.getStatusCode()); + LOGGER.debug("Response for GET request with uri {} : {}", builder.toUriString(), responseEntity.getBody()); + assertNotNull("Response from /aai/recents/v14/pserver is not null", responseEntity); + assertEquals("Expected the response to be 200", HttpStatus.OK, responseEntity.getStatusCode()); + + // Check different application xml headers for accept + headers.set("Accept", "application/xml"); + httpEntity = new HttpEntity(headers); + + responseEntity = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, httpEntity, + String.class); + LOGGER.debug("Response for GET request with uri {} : {}", builder.toUriString(), responseEntity.getBody()); + assertNotNull("Response from /aai/recents/v14/pserver is not null", responseEntity); + assertEquals("Expected the response to be 200", HttpStatus.OK, responseEntity.getStatusCode()); + + headers.set("Accept", "application/xml; charset=UTF-8"); + httpEntity = new HttpEntity(headers); + responseEntity = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, httpEntity, + String.class); + LOGGER.debug("Response for GET request with uri {} : {}", builder.toUriString(), responseEntity.getBody()); + assertNotNull("Response from /aai/recents/v14/pserver is not null", responseEntity); + assertEquals("Expected the response to be 200", HttpStatus.OK, responseEntity.getStatusCode()); } @Test |