diff options
author | Venkata Harish K Kajur <vk250x@att.com> | 2017-08-16 08:49:04 -0400 |
---|---|---|
committer | Venkata Harish K Kajur <vk250x@att.com> | 2017-08-16 08:49:08 -0400 |
commit | 8336d5e1b0c466ea5f1ca8aa01fc9d01ed91a059 (patch) | |
tree | a056f790417f08e472d97782dc529e38fcacd440 /aai-core/src/test/java | |
parent | a8803870e44eb900e70586773e891e08a063d11f (diff) |
[AAI-176 Amsterdam] Check in related link changes
Change-Id: Ie72ccd9aa2fb3b214f6b8b1ca6280d5dd08b10a7
Signed-off-by: Venkata Harish K Kajur <vk250x@att.com>
Diffstat (limited to 'aai-core/src/test/java')
-rw-r--r-- | aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/utils/UrlBuilderTest.java | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/utils/UrlBuilderTest.java b/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/utils/UrlBuilderTest.java new file mode 100644 index 00000000..481e3bba --- /dev/null +++ b/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/utils/UrlBuilderTest.java @@ -0,0 +1,85 @@ +package org.openecomp.aai.serialization.queryformats.utils; +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.when; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.net.URISyntaxException; + +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.openecomp.aai.introspection.Version; +import org.openecomp.aai.serialization.db.DBSerializer; +import org.openecomp.aai.serialization.queryformats.exceptions.AAIFormatVertexException; +import org.openecomp.aai.util.AAIConstants; + +public class UrlBuilderTest { + + @Mock private DBSerializer serializer; + @Mock private Vertex v; + private static final String uri = "/test/uri"; + private static final Object vId = new Long(123); + private static final String protocolAndHost = "http://localhost/aai/"; + @BeforeClass + public static void setUp() { + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local"); + + } + + @Before + public void before() throws UnsupportedEncodingException, URISyntaxException { + MockitoAnnotations.initMocks(this); + when(serializer.getURIForVertex(any(Vertex.class))).thenReturn(new URI(uri)); + when(v.id()).thenReturn(vId); + } + + @Ignore + @Test + public void v11Pathed() throws UnsupportedEncodingException, URISyntaxException, AAIFormatVertexException { + Version version = Version.v11; + UrlBuilder builder = new UrlBuilder(version, serializer, protocolAndHost); + String result = builder.pathed(v); + + assertEquals("has no protocol and host", AAIConstants.AAI_APP_ROOT + version + uri, result); + + } + + @Ignore + @Test + public void v11Id() throws UnsupportedEncodingException, URISyntaxException, AAIFormatVertexException { + Version version = Version.v11; + UrlBuilder builder = new UrlBuilder(version, serializer, protocolAndHost); + String result = builder.id(v); + + assertEquals("has no protocol and host", AAIConstants.AAI_APP_ROOT + version + "/resources/id/" + vId, result); + + } + + @Test + public void beforeV11Pathed() throws UnsupportedEncodingException, URISyntaxException, AAIFormatVertexException { + Version version = Version.v10; + UrlBuilder builder = new UrlBuilder(version, serializer, protocolAndHost); + String result = builder.pathed(v); + + assertEquals("has protocol and host", protocolAndHost + version + uri, result); + + } + + @Test + public void beforeV11Id() throws UnsupportedEncodingException, URISyntaxException, AAIFormatVertexException { + Version version = Version.v10; + UrlBuilder builder = new UrlBuilder(version, serializer, protocolAndHost); + String result = builder.id(v); + + assertEquals("has protocol and host", protocolAndHost + version + "/resources/id/" + vId, result); + + } + +} |