From 8336d5e1b0c466ea5f1ca8aa01fc9d01ed91a059 Mon Sep 17 00:00:00 2001 From: Venkata Harish K Kajur Date: Wed, 16 Aug 2017 08:49:04 -0400 Subject: [AAI-176 Amsterdam] Check in related link changes Change-Id: Ie72ccd9aa2fb3b214f6b8b1ca6280d5dd08b10a7 Signed-off-by: Venkata Harish K Kajur --- .../queryformats/utils/UrlBuilderTest.java | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/utils/UrlBuilderTest.java (limited to 'aai-core/src/test') 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); + + } + +} -- cgit 1.2.3-korg