aboutsummaryrefslogtreecommitdiffstats
path: root/aai-resources/src/test/java/org/openecomp/aai/rest
diff options
context:
space:
mode:
Diffstat (limited to 'aai-resources/src/test/java/org/openecomp/aai/rest')
-rw-r--r--aai-resources/src/test/java/org/openecomp/aai/rest/BulkAddConsumerTest.java168
-rw-r--r--aai-resources/src/test/java/org/openecomp/aai/rest/BulkProcessConsumerTest.java54
-rw-r--r--aai-resources/src/test/java/org/openecomp/aai/rest/ExampleConsumerTest.java131
-rw-r--r--aai-resources/src/test/java/org/openecomp/aai/rest/ExceptionHandlerTest.java138
-rw-r--r--aai-resources/src/test/java/org/openecomp/aai/rest/LegacyMoxyConsumerTest.java617
-rw-r--r--aai-resources/src/test/java/org/openecomp/aai/rest/URLFromVertexIdConsumerTest.java179
-rw-r--r--aai-resources/src/test/java/org/openecomp/aai/rest/VertexIdConsumerTest.java158
-rw-r--r--aai-resources/src/test/java/org/openecomp/aai/rest/retired/RetiredConsumerTest.java107
-rw-r--r--aai-resources/src/test/java/org/openecomp/aai/rest/retired/V3ThroughV7ConsumerTest.java9
-rw-r--r--aai-resources/src/test/java/org/openecomp/aai/rest/retired/V7V8ModelsTest.java9
-rw-r--r--aai-resources/src/test/java/org/openecomp/aai/rest/retired/V7V8NamedQueriesTest.java9
-rw-r--r--aai-resources/src/test/java/org/openecomp/aai/rest/tools/ModelVersionTransformerTest.java116
-rw-r--r--aai-resources/src/test/java/org/openecomp/aai/rest/util/EchoResponseTest.java116
-rw-r--r--aai-resources/src/test/java/org/openecomp/aai/rest/util/LogFormatToolsTest.java15
-rw-r--r--aai-resources/src/test/java/org/openecomp/aai/rest/util/ValidateEncodingTest.java9
15 files changed, 1830 insertions, 5 deletions
diff --git a/aai-resources/src/test/java/org/openecomp/aai/rest/BulkAddConsumerTest.java b/aai-resources/src/test/java/org/openecomp/aai/rest/BulkAddConsumerTest.java
new file mode 100644
index 0000000..2804566
--- /dev/null
+++ b/aai-resources/src/test/java/org/openecomp/aai/rest/BulkAddConsumerTest.java
@@ -0,0 +1,168 @@
+package org.openecomp.aai.rest;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.apache.commons.io.IOUtils;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.aai.AAISetup;
+import org.openecomp.aai.dbmap.AAIGraph;
+import org.openecomp.aai.introspection.ModelInjestor;
+import org.openecomp.aai.introspection.Version;
+
+import javax.ws.rs.core.*;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.*;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.when;
+
+public class BulkAddConsumerTest extends AAISetup {
+
+ protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
+
+ protected static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
+
+ static {
+ VALID_HTTP_STATUS_CODES.add(200);
+ VALID_HTTP_STATUS_CODES.add(201);
+ VALID_HTTP_STATUS_CODES.add(204);
+ }
+
+ protected BulkConsumer bulkConsumer;
+
+ protected HttpHeaders httpHeaders;
+
+ protected UriInfo uriInfo;
+
+ protected MultivaluedMap<String, String> headersMultiMap;
+ protected MultivaluedMap<String, String> queryParameters;
+
+ protected List<String> aaiRequestContextList;
+
+ protected List<MediaType> outputMediaTypes;
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(BulkAddConsumerTest.class.getName());
+
+ @BeforeClass
+ public static void setupRest(){
+ AAIGraph.getInstance();
+ ModelInjestor.getInstance();
+ }
+
+ @Before
+ public void setup(){
+ logger.info("Starting the setup for the integration tests of Rest Endpoints");
+
+ bulkConsumer = getConsumer();
+ httpHeaders = Mockito.mock(HttpHeaders.class);
+ uriInfo = Mockito.mock(UriInfo.class);
+
+ headersMultiMap = new MultivaluedHashMap<>();
+ queryParameters = Mockito.spy(new MultivaluedHashMap<>());
+
+ headersMultiMap.add("X-FromAppId", "JUNIT");
+ headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString());
+ headersMultiMap.add("Real-Time", "true");
+ headersMultiMap.add("Accept", "application/json");
+ headersMultiMap.add("aai-request-context", "");
+
+ outputMediaTypes = new ArrayList<>();
+ outputMediaTypes.add(APPLICATION_JSON);
+
+ aaiRequestContextList = new ArrayList<>();
+ aaiRequestContextList.add("");
+
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+
+ when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList);
+
+
+ when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
+ when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
+
+ // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
+ Mockito.doReturn(null).when(queryParameters).remove(anyObject());
+
+ when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
+ }
+
+ @Test
+ public void testBulkAdd() throws IOException {
+
+ String uri = "/aai/v11/bulkadd";
+
+ when(uriInfo.getPath()).thenReturn(uri);
+ when(uriInfo.getPath(false)).thenReturn(uri);
+
+ String payload = getBulkPayload("pserver-transactions");
+ Response response = bulkConsumer.bulkAdd(
+ payload,
+ Version.getLatest().toString(),
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ System.out.println("Code: " + response.getStatus() + "\tResponse: " + response.getEntity());
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testBulkAddThrowExceptionWhenPayloadContainsNoTransactions(){
+
+ String uri = "/aai/v11/bulkadd";
+
+ when(uriInfo.getPath()).thenReturn(uri);
+ when(uriInfo.getPath(false)).thenReturn(uri);
+
+ String payload = "{\"transactions\":[]}";
+ Response response = bulkConsumer.bulkAdd(
+ payload,
+ Version.getLatest().toString(),
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ System.out.println("Code: " + response.getStatus() + "\tResponse: " + response.getEntity());
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testBulkAddThrowExceptionWhenInvalidJson() throws IOException {
+
+ String uri = "/aai/v11/bulkadd";
+
+ when(uriInfo.getPath()).thenReturn(uri);
+ when(uriInfo.getPath(false)).thenReturn(uri);
+
+ String payload = "{";
+ Response response = bulkConsumer.bulkAdd(
+ payload,
+ Version.getLatest().toString(),
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ System.out.println("Code: " + response.getStatus() + "\tResponse: " + response.getEntity());
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+
+ // TODO - Verify the result output and check if it contains an 400 in the list
+ }
+
+ public String getBulkPayload(String bulkName) throws IOException {
+ return getPayload("payloads/bulk/" + bulkName + ".json");
+ }
+
+ public BulkConsumer getConsumer(){
+ return new BulkAddConsumer();
+ }
+} \ No newline at end of file
diff --git a/aai-resources/src/test/java/org/openecomp/aai/rest/BulkProcessConsumerTest.java b/aai-resources/src/test/java/org/openecomp/aai/rest/BulkProcessConsumerTest.java
new file mode 100644
index 0000000..64639d4
--- /dev/null
+++ b/aai-resources/src/test/java/org/openecomp/aai/rest/BulkProcessConsumerTest.java
@@ -0,0 +1,54 @@
+package org.openecomp.aai.rest;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.apache.commons.io.IOUtils;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.aai.AAISetup;
+import org.openecomp.aai.dbmap.AAIGraph;
+import org.openecomp.aai.introspection.ModelInjestor;
+import org.openecomp.aai.introspection.Version;
+
+import javax.ws.rs.core.*;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.*;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.when;
+
+public class BulkProcessConsumerTest extends BulkAddConsumerTest {
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(BulkProcessConsumerTest.class.getName());
+
+ @Test
+ public void testBulkAddCreatedWhenOneTransactionInPayloadContainsNotAllowedVerb() throws IOException {
+
+ String uri = "/aai/v11/bulkadd";
+
+ when(uriInfo.getPath()).thenReturn(uri);
+ when(uriInfo.getPath(false)).thenReturn(uri);
+
+ String payload = getBulkPayload("pserver-transactions-invalid");
+ Response response = bulkConsumer.bulkAdd(
+ payload,
+ Version.getLatest().toString(),
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ System.out.println("Code: " + response.getStatus() + "\tResponse: " + response.getEntity());
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
+ }
+
+ @Override
+ public BulkConsumer getConsumer(){
+ return new BulkProcessConsumer();
+ }
+} \ No newline at end of file
diff --git a/aai-resources/src/test/java/org/openecomp/aai/rest/ExampleConsumerTest.java b/aai-resources/src/test/java/org/openecomp/aai/rest/ExampleConsumerTest.java
new file mode 100644
index 0000000..28d5527
--- /dev/null
+++ b/aai-resources/src/test/java/org/openecomp/aai/rest/ExampleConsumerTest.java
@@ -0,0 +1,131 @@
+package org.openecomp.aai.rest;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.aai.AAISetup;
+import org.openecomp.aai.dbmap.AAIGraph;
+import org.openecomp.aai.introspection.ModelInjestor;
+import org.openecomp.aai.introspection.Version;
+
+import javax.ws.rs.core.*;
+
+import java.util.*;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.when;
+
+public class ExampleConsumerTest extends AAISetup {
+
+ protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
+
+ private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
+
+ static {
+ VALID_HTTP_STATUS_CODES.add(200);
+ VALID_HTTP_STATUS_CODES.add(201);
+ VALID_HTTP_STATUS_CODES.add(204);
+ }
+
+ private ExampleConsumer exampleConsumer;
+
+ private HttpHeaders httpHeaders;
+
+ private UriInfo uriInfo;
+
+ private MultivaluedMap<String, String> headersMultiMap;
+ private MultivaluedMap<String, String> queryParameters;
+
+ private List<String> aaiRequestContextList;
+
+ private List<MediaType> outputMediaTypes;
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(LegacyMoxyConsumerTest.class.getName());
+
+ @BeforeClass
+ public static void setupRest(){
+ AAIGraph.getInstance();
+ ModelInjestor.getInstance();
+ }
+
+ @Before
+ public void setup(){
+ logger.info("Starting the setup for the integration tests of Rest Endpoints");
+
+ exampleConsumer = new ExampleConsumer();
+ httpHeaders = Mockito.mock(HttpHeaders.class);
+ uriInfo = Mockito.mock(UriInfo.class);
+
+ headersMultiMap = new MultivaluedHashMap<>();
+ queryParameters = Mockito.spy(new MultivaluedHashMap<>());
+
+ headersMultiMap.add("X-FromAppId", "JUNIT");
+ headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString());
+ headersMultiMap.add("Real-Time", "true");
+ headersMultiMap.add("Accept", "application/json");
+ headersMultiMap.add("aai-request-context", "");
+
+ outputMediaTypes = new ArrayList<>();
+ outputMediaTypes.add(APPLICATION_JSON);
+
+ aaiRequestContextList = new ArrayList<>();
+ aaiRequestContextList.add("");
+
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+
+ when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList);
+
+
+ when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
+ when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
+
+ // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
+ Mockito.doReturn(null).when(queryParameters).remove(anyObject());
+
+ when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
+ }
+
+ @Test
+ public void testGetExampleRespondsWithOkStatusForValidObject(){
+
+ Response response = exampleConsumer.getExample(
+ Version.getLatest().toString(),
+ "pserver",
+ httpHeaders,
+ uriInfo,
+ null);
+
+ assertNotNull("Response from the example consumer returned null", response);
+
+ int code = Response.Status.OK.getStatusCode();
+
+ assertEquals(response.getStatus(), code);
+ }
+
+ @Test
+ public void testGetExampleFailureForInvalidObject(){
+
+ when(uriInfo.getPath()).thenReturn("examples/fakeObject");
+ when(uriInfo.getPath(false)).thenReturn("examples/fakeObject");
+
+ Response response = exampleConsumer.getExample(
+ Version.getLatest().toString(),
+ "testRandomCrazyObject",
+ httpHeaders,
+ uriInfo,
+ null);
+
+ assertNotNull("Response from the example consumer returned null", response);
+
+ int code = Response.Status.BAD_REQUEST.getStatusCode();
+
+ assertEquals(response.getStatus(), code);
+ }
+
+} \ No newline at end of file
diff --git a/aai-resources/src/test/java/org/openecomp/aai/rest/ExceptionHandlerTest.java b/aai-resources/src/test/java/org/openecomp/aai/rest/ExceptionHandlerTest.java
new file mode 100644
index 0000000..2c47a2e
--- /dev/null
+++ b/aai-resources/src/test/java/org/openecomp/aai/rest/ExceptionHandlerTest.java
@@ -0,0 +1,138 @@
+package org.openecomp.aai.rest;
+
+import com.fasterxml.jackson.core.JsonLocation;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.sun.istack.SAXParseException2;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.aai.AAISetup;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.Response;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class ExceptionHandlerTest extends AAISetup {
+
+ protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
+
+ @Mock
+ private HttpHeaders httpHeaders;
+
+ @Mock
+ private HttpServletRequest request;
+
+ @InjectMocks
+ private ExceptionHandler handler = new ExceptionHandler();
+
+ @Before
+ public void setup(){
+ MockitoAnnotations.initMocks(this);
+
+ MultivaluedHashMap headersMultiMap = new MultivaluedHashMap<>();
+
+ headersMultiMap.add("X-FromAppId", "JUNIT");
+ headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString());
+ headersMultiMap.add("Real-Time", "true");
+ headersMultiMap.add("Accept", "application/json");
+ headersMultiMap.add("aai-request-context", "");
+
+ List<MediaType> outputMediaTypes = new ArrayList<>();
+ outputMediaTypes.add(APPLICATION_JSON);
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+ }
+
+ @Test
+ public void testConversionOfWebApplicationResponse() throws Exception {
+
+ Exception exception = new WebApplicationException();
+ Response response = handler.toResponse(exception);
+
+ assertNotNull(response);
+ assertNull(response.getEntity());
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testConversionOfWebApplicationResponseWhenUmarshalExceptionResultBadRequest() throws Exception {
+
+ SAXParseException2 mockSaxParseException = mock(SAXParseException2.class);
+ Exception exception = new WebApplicationException(mockSaxParseException);
+ Response response = handler.toResponse(exception);
+
+ assertNotNull(response);
+ assertNotNull(response.getEntity());
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testConversionWhenJsonParseExceptionResultBadRequest() throws Exception {
+
+ JsonLocation jsonLocation = mock(JsonLocation.class);
+ Exception exception = new JsonParseException("", jsonLocation);
+ Response response = handler.toResponse(exception);
+
+ assertNotNull(response);
+ assertNotNull(response.getEntity());
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testConversionWhenJsonMappingExceptionResultBadRequest() throws Exception {
+
+ JsonLocation jsonLocation = mock(JsonLocation.class);
+ Exception exception = new JsonMappingException("", jsonLocation);
+ Response response = handler.toResponse(exception);
+
+ assertNotNull(response);
+ assertNotNull(response.getEntity());
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testConversionWhenUnknownExceptionResultBadRequest() throws Exception {
+
+ Exception exception = mock(Exception.class);
+ Response response = handler.toResponse(exception);
+
+ when(request.getMethod()).thenReturn("GET");
+
+ assertNotNull(response);
+ assertNotNull(response.getEntity());
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+
+
+ }
+
+ @Test
+ public void testConversionWhenUnknownExceptionResultBadRequestForXmlResponseType() throws Exception {
+
+ List<MediaType> outputMediaTypes = new ArrayList<>();
+ outputMediaTypes.add(MediaType.valueOf("application/xml"));
+ when(request.getMethod()).thenReturn("GET");
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+
+ Exception exception = mock(Exception.class);
+ Response response = handler.toResponse(exception);
+
+ assertNotNull(response);
+ assertNotNull(response.getEntity());
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ }
+} \ No newline at end of file
diff --git a/aai-resources/src/test/java/org/openecomp/aai/rest/LegacyMoxyConsumerTest.java b/aai-resources/src/test/java/org/openecomp/aai/rest/LegacyMoxyConsumerTest.java
new file mode 100644
index 0000000..1620f3e
--- /dev/null
+++ b/aai-resources/src/test/java/org/openecomp/aai/rest/LegacyMoxyConsumerTest.java
@@ -0,0 +1,617 @@
+package org.openecomp.aai.rest;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.aai.AAISetup;
+import org.openecomp.aai.dbmap.AAIGraph;
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.introspection.ModelInjestor;
+import org.openecomp.aai.introspection.Version;
+import org.skyscreamer.jsonassert.JSONAssert;
+
+import javax.ws.rs.core.*;
+import java.io.IOException;
+import java.util.*;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.when;
+
+public class LegacyMoxyConsumerTest extends AAISetup {
+
+ protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
+
+ private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
+
+ static {
+ VALID_HTTP_STATUS_CODES.add(200);
+ VALID_HTTP_STATUS_CODES.add(201);
+ VALID_HTTP_STATUS_CODES.add(204);
+ }
+
+ private LegacyMoxyConsumer legacyMoxyConsumer;
+
+ private HttpHeaders httpHeaders;
+
+ private UriInfo uriInfo;
+
+ private MultivaluedMap<String, String> headersMultiMap;
+ private MultivaluedMap<String, String> queryParameters;
+
+ private List<String> aaiRequestContextList;
+
+ private List<MediaType> outputMediaTypes;
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(LegacyMoxyConsumerTest.class.getName());
+
+ @BeforeClass
+ public static void setupRest(){
+ AAIGraph.getInstance();
+ ModelInjestor.getInstance();
+ }
+
+ @Before
+ public void setup(){
+ logger.info("Starting the setup for the integration tests of Rest Endpoints");
+
+ legacyMoxyConsumer = new LegacyMoxyConsumer();
+ httpHeaders = Mockito.mock(HttpHeaders.class);
+ uriInfo = Mockito.mock(UriInfo.class);
+
+ headersMultiMap = new MultivaluedHashMap<>();
+ queryParameters = Mockito.spy(new MultivaluedHashMap<>());
+
+ headersMultiMap.add("X-FromAppId", "JUNIT");
+ headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString());
+ headersMultiMap.add("Real-Time", "true");
+ headersMultiMap.add("Accept", "application/json");
+ headersMultiMap.add("aai-request-context", "");
+
+ outputMediaTypes = new ArrayList<>();
+ outputMediaTypes.add(APPLICATION_JSON);
+
+ aaiRequestContextList = new ArrayList<>();
+ aaiRequestContextList.add("");
+
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+
+ when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList);
+
+
+ when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
+ when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
+
+ // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
+ Mockito.doReturn(null).when(queryParameters).remove(anyObject());
+
+ when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
+ }
+
+ @Test
+ public void testResponsePutGetDeleteOnResource() throws JSONException, IOException, AAIException {
+
+ String uri = getUri();
+ String payload = getResourcePayload(getObjectName());
+
+ assertNotNull("Introspector returned invalid string when marshalling the object", payload);
+ assertNotNull("Introspector failed to return a valid uri", uri);
+
+ if(uri.length() != 0 && uri.charAt(0) == '/'){
+ uri = uri.substring(1);
+ }
+
+ when(uriInfo.getPath()).thenReturn(uri);
+ when(uriInfo.getPath(false)).thenReturn(uri);
+
+ Response response = legacyMoxyConsumer.getLegacy(
+ "",
+ Version.getLatest().toString(),
+ uri,
+ "all",
+ "false",
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
+
+ response = legacyMoxyConsumer.update(
+ payload,
+ Version.getLatest().toString(),
+ uri,
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ int code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
+
+ queryParameters.add("depth", "10000");
+
+ response = legacyMoxyConsumer.getLegacy(
+ "",
+ Version.getLatest().toString(),
+ uri,
+ "10000",
+ "false",
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+
+ String pserverEntity = response.getEntity().toString();
+ JSONObject pserverJsonbject = new JSONObject(pserverEntity);
+
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
+
+ JSONAssert.assertEquals(payload, pserverEntity, false);
+
+ String resourceVersion = pserverJsonbject.getString("resource-version");
+
+ queryParameters.add("resource-version", resourceVersion);
+
+ response = legacyMoxyConsumer.delete(
+ "v11",
+ uri,
+ httpHeaders,
+ uriInfo,
+ "",
+ null
+ );
+
+ code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+
+ assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
+
+ response = legacyMoxyConsumer.getLegacy(
+ "",
+ Version.getLatest().toString(),
+ uri,
+ "all",
+ "false",
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testPutPserverAndCloudRegionRelationship() throws IOException, JSONException {
+
+ String pserverData = getRelationshipPayload("pserver");
+ String complexData = getRelationshipPayload("complex");
+
+ String hostname = "590a8943-1200-43b3-825b-75dde6b8f44a";
+ String physicalLocationId ="e13d4587-19ad-4bf5-80f5-c021efb5b61c";
+
+ 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-relationship");
+ String cloudToPserverRelationshipUri = String.format(
+ "cloud-infrastructure/pservers/pserver/%s/relationship-list/relationship", hostname);
+
+ Response response = legacyMoxyConsumer.updateRelationship(
+ cloudToPserverRelationshipData,
+ Version.getLatest().toString(),
+ cloudToPserverRelationshipUri,
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ 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());
+
+ // TODO - Need to actually verify the relationship between pserver and cloud-region
+
+ response = legacyMoxyConsumer.deleteRelationship(
+ cloudToPserverRelationshipData,
+ Version.getLatest().toString(),
+ cloudToPserverRelationshipUri,
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+
+ assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testPutPassWithEmptyData() throws JSONException {
+
+ String payload = "{}";
+ String pserverUri = String.format("cloud-infrastructure/pservers/pserver/%s", UUID.randomUUID().toString());
+
+ doSetupResource(pserverUri, payload);
+
+ payload = "";
+ pserverUri = String.format("cloud-infrastructure/pservers/pserver/%s", UUID.randomUUID().toString());
+ doSetupResource(pserverUri, payload);
+ }
+
+ @Test
+ public void testFailureWithInvalidUri() throws JSONException {
+
+ String payload = "{}";
+ String uri = "fake-infrastructure/pservers/pserver/fajsidj";
+
+ when(uriInfo.getPath()).thenReturn(uri);
+ when(uriInfo.getPath(false)).thenReturn(uri);
+
+ Response response = legacyMoxyConsumer.update(
+ payload,
+ Version.getLatest().toString(),
+ uri,
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ int code = response.getStatus();
+ System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), code);
+ }
+
+ @Test
+ public void testInvalidUriThrowRandomException() throws JSONException {
+
+ String payload = "{}";
+ String uri = "fake-infrastructure/pservers/pserver/fajsidj";
+
+ when(uriInfo.getPath()).thenReturn(uri);
+ when(uriInfo.getPath(false)).thenThrow(new IllegalArgumentException());
+
+ Response response = legacyMoxyConsumer.update(
+ payload,
+ Version.getLatest().toString(),
+ uri,
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ int code = response.getStatus();
+ assertNotNull("Response from the legacy moxy consumer returned null", response);
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), code);
+ System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+
+ response = legacyMoxyConsumer.updateRelationship(
+ payload,
+ Version.getLatest().toString(),
+ uri,
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ code = response.getStatus();
+ assertNotNull("Response from the legacy moxy consumer returned null", response);
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), code);
+ System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+
+ response = legacyMoxyConsumer.getLegacy(
+ "",
+ Version.getLatest().toString(),
+ uri,
+ "all",
+ "false",
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ assertNotNull("Response from the legacy moxy consumer returned null", response);
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), code);
+
+ response = legacyMoxyConsumer.delete(
+ Version.getLatest().toString(),
+ uri,
+ httpHeaders,
+ uriInfo,
+ "",
+ null
+ );
+
+ code = response.getStatus();
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), code);
+
+ response = legacyMoxyConsumer.deleteRelationship(
+ payload,
+ Version.getLatest().toString(),
+ uri,
+ httpHeaders,
+ uriInfo,
+ null
+ );
+ code = response.getStatus();
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), code);
+ }
+
+ @Test
+ public void testInvalidUriContainingRelatedToShouldThrowAAIException() throws JSONException {
+
+ String payload = "{}";
+ String uri = "cloud-infrastructure/related-to/fsdf";
+
+ when(uriInfo.getPath()).thenReturn(uri);
+ when(uriInfo.getPath(false)).thenReturn(uri);
+
+ Response response = legacyMoxyConsumer.update(
+ payload,
+ Version.getLatest().toString(),
+ uri,
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ int code = response.getStatus();
+ System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), code);
+
+ response = legacyMoxyConsumer.updateRelationship(
+ payload,
+ Version.getLatest().toString(),
+ uri,
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ code = response.getStatus();
+ System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), code);
+
+ response = legacyMoxyConsumer.getLegacy(
+ "",
+ Version.getLatest().toString(),
+ uri,
+ "all",
+ "false",
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ assertNotNull("Response from the legacy moxy consumer returned null", response);
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), code);
+
+ queryParameters.add("resource-version", "3434394839483");
+ response = legacyMoxyConsumer.delete(
+ Version.getLatest().toString(),
+ uri,
+ httpHeaders,
+ uriInfo,
+ "",
+ null
+ );
+
+ code = response.getStatus();
+ System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), code);
+
+ response = legacyMoxyConsumer.deleteRelationship(
+ payload,
+ Version.getLatest().toString(),
+ uri,
+ httpHeaders,
+ uriInfo,
+ null
+ );
+ code = response.getStatus();
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), code);
+ }
+
+ @Test
+ @Ignore("Unable to test this method due to WRITE_BIGDECIMAL_AS_PLAIN error")
+ public void testPatchWithValidData() throws IOException {
+
+ String payload = getResourcePayload("pserver-patch-test");
+ String uri = getUri("pserver-patch-test");
+
+ if(uri.length() != 0 && uri.charAt(0) == '/'){
+ uri = uri.substring(1);
+ }
+
+ when(uriInfo.getPath()).thenReturn(uri);
+ when(uriInfo.getPath(false)).thenReturn(uri);
+
+ Response response = legacyMoxyConsumer.getLegacy(
+ "",
+ Version.getLatest().toString(),
+ uri,
+ "all",
+ "false",
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
+
+ response = legacyMoxyConsumer.update(
+ payload,
+ Version.getLatest().toString(),
+ uri,
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ int code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
+
+ String patchData = "{\"in-maint\": false}";
+
+ headersMultiMap.add("Content-Type", "application/json");
+
+ outputMediaTypes.remove(APPLICATION_JSON);
+ outputMediaTypes.add(MediaType.valueOf("application/merge-patch+json"));
+
+ response = legacyMoxyConsumer.patch(
+ patchData,
+ Version.getLatest().toString(),
+ uri,
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ code = response.getStatus();
+ assertNotNull("Response from the patch returned null", response);
+ System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ assertEquals(Response.Status.OK.getStatusCode(), code);
+
+ }
+
+ protected void doSetupResource(String uri, String payload) throws JSONException {
+
+ when(uriInfo.getPath()).thenReturn(uri);
+ when(uriInfo.getPath(false)).thenReturn(uri);
+
+ Response response = legacyMoxyConsumer.getLegacy(
+ "",
+ Version.getLatest().toString(),
+ uri,
+ "all",
+ "false",
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ assertNotNull("Response from the legacy moxy consumer returned null", response);
+ assertEquals("Expected to not have the data already in memory",
+ Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
+
+ response = legacyMoxyConsumer.update(
+ payload,
+ Version.getLatest().toString(),
+ uri,
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ 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.CREATED.getStatusCode(), response.getStatus());
+
+ queryParameters.add("depth", "10000");
+ response = legacyMoxyConsumer.getLegacy(
+ "",
+ Version.getLatest().toString(),
+ uri,
+ "all",
+ "false",
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ assertNotNull("Response from the legacy moxy consumer returned null", response);
+ assertEquals("Expected to return the pserver data that was just put in memory",
+ Response.Status.OK.getStatusCode(), response.getStatus());
+
+ if("".equalsIgnoreCase(payload)){
+ payload = "{}";
+ }
+
+ JSONAssert.assertEquals(payload, response.getEntity().toString(), false);
+ }
+
+ @Test
+ public void testDeleteRelationshipThrowsException(){
+
+ String payload = "";
+ String hostname = "testData";
+ String uri = String.format("cloud-infrastructure/pservers/pserver/%s/relationship-list/relationship", hostname);
+
+ when(uriInfo.getPath()).thenReturn(uri);
+ when(uriInfo.getPath(false)).thenReturn(uri);
+
+ Response response = legacyMoxyConsumer.deleteRelationship(
+ payload,
+ Version.getLatest().toString(),
+ uri,
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ int code = response.getStatus();
+ System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), code);
+ }
+
+ // TODO - Change this to be abstract and inheritable
+ public String getObjectName(){
+ return "pserver";
+ }
+
+ public String getResourcePayload(String resourceName) throws IOException {
+ return getPayload("payloads/resource/" + resourceName + ".json");
+ }
+
+ public String getRelationshipPayload(String relationshipName) throws IOException {
+ return getPayload("payloads/relationship/" + relationshipName + ".json");
+ }
+
+ public String getUri(String hostname){
+ return String.format("cloud-infrastructure/pservers/pserver/%s", hostname);
+ }
+
+ public String getUri(){
+ return getUri("pserver-hostname-test");
+ }
+}
diff --git a/aai-resources/src/test/java/org/openecomp/aai/rest/URLFromVertexIdConsumerTest.java b/aai-resources/src/test/java/org/openecomp/aai/rest/URLFromVertexIdConsumerTest.java
new file mode 100644
index 0000000..5ba9ea6
--- /dev/null
+++ b/aai-resources/src/test/java/org/openecomp/aai/rest/URLFromVertexIdConsumerTest.java
@@ -0,0 +1,179 @@
+package org.openecomp.aai.rest;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.json.JSONException;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.aai.AAISetup;
+import org.openecomp.aai.dbmap.AAIGraph;
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.introspection.ModelInjestor;
+import org.openecomp.aai.introspection.Version;
+
+import javax.ws.rs.core.*;
+import java.io.IOException;
+import java.util.*;
+
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.when;
+
+public class URLFromVertexIdConsumerTest extends AAISetup {
+
+ protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
+
+ private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
+
+ static {
+ VALID_HTTP_STATUS_CODES.add(200);
+ VALID_HTTP_STATUS_CODES.add(201);
+ VALID_HTTP_STATUS_CODES.add(204);
+ }
+
+ private URLFromVertexIdConsumer urlFromVertexIdConsumer;
+ private LegacyMoxyConsumer legacyMoxyConsumer;
+
+ private HttpHeaders httpHeaders;
+
+ private UriInfo uriInfo;
+
+ private MultivaluedMap<String, String> headersMultiMap;
+ private MultivaluedMap<String, String> queryParameters;
+
+ private List<String> aaiRequestContextList;
+
+ private List<MediaType> outputMediaTypes;
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(LegacyMoxyConsumerTest.class.getName());
+
+ @BeforeClass
+ public static void setupRest(){
+ AAIGraph.getInstance();
+ ModelInjestor.getInstance();
+ }
+
+ @Before
+ public void setup(){
+ logger.info("Starting the setup for the integration tests of Rest Endpoints");
+
+ urlFromVertexIdConsumer = new URLFromVertexIdConsumer();
+ legacyMoxyConsumer = new LegacyMoxyConsumer();
+
+ httpHeaders = Mockito.mock(HttpHeaders.class);
+ uriInfo = Mockito.mock(UriInfo.class);
+
+ headersMultiMap = new MultivaluedHashMap<>();
+ queryParameters = Mockito.spy(new MultivaluedHashMap<>());
+
+ headersMultiMap.add("X-FromAppId", "JUNIT");
+ headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString());
+ headersMultiMap.add("Real-Time", "true");
+ headersMultiMap.add("Accept", "application/json");
+ headersMultiMap.add("aai-request-context", "");
+
+ outputMediaTypes = new ArrayList<>();
+ outputMediaTypes.add(APPLICATION_JSON);
+
+ aaiRequestContextList = new ArrayList<>();
+ aaiRequestContextList.add("");
+
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+
+ when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList);
+
+
+ when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
+ when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
+
+ // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
+ Mockito.doReturn(null).when(queryParameters).remove(anyObject());
+
+ when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
+ }
+
+ @Test
+ public void testResponsePutGetDeleteOnResource() throws JSONException, IOException, AAIException {
+
+ String uri = "cloud-infrastructure/pservers/pserver/" + UUID.randomUUID().toString();
+ String payload = "{}";
+
+ when(uriInfo.getPath()).thenReturn(uri);
+ when(uriInfo.getPath(false)).thenReturn(uri);
+
+ Response response = legacyMoxyConsumer.getLegacy(
+ "",
+ Version.getLatest().toString(),
+ uri,
+ "all",
+ "false",
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
+
+ response = legacyMoxyConsumer.update(
+ payload,
+ Version.getLatest().toString(),
+ uri,
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ int code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
+
+ MultivaluedMap<String, Object> responseHeaders = response.getMetadata();
+
+ assertNotNull("Unable to retrieve the response headers from response object", responseHeaders);
+ assertTrue("Response doesn't contain the key vertexId", responseHeaders.containsKey("vertex-id"));
+
+ String vertexId = responseHeaders.get("vertex-id").get(0).toString();
+
+ response = urlFromVertexIdConsumer.generateUrlFromVertexId(
+ "",
+ Version.getLatest().toString(),
+ Long.valueOf(vertexId).longValue(),
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ assertNotNull(response);
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testObjectNotFoundInDBReturnsNotFoundStatus() throws JSONException, IOException, AAIException {
+
+ String uri = "cloud-infrastructure/pservers/pserver/testRandom";
+
+ when(uriInfo.getPath()).thenReturn(uri);
+ when(uriInfo.getPath(false)).thenReturn(uri);
+
+ String vertexId = "384584";
+
+ Response response = urlFromVertexIdConsumer.generateUrlFromVertexId(
+ "",
+ Version.getLatest().toString(),
+ Long.valueOf(vertexId).longValue(),
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ assertNotNull("Check if the response is not null", response);
+
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
+ }
+} \ No newline at end of file
diff --git a/aai-resources/src/test/java/org/openecomp/aai/rest/VertexIdConsumerTest.java b/aai-resources/src/test/java/org/openecomp/aai/rest/VertexIdConsumerTest.java
new file mode 100644
index 0000000..12e2411
--- /dev/null
+++ b/aai-resources/src/test/java/org/openecomp/aai/rest/VertexIdConsumerTest.java
@@ -0,0 +1,158 @@
+package org.openecomp.aai.rest;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.json.JSONException;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.aai.AAISetup;
+import org.openecomp.aai.dbmap.AAIGraph;
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.introspection.ModelInjestor;
+import org.openecomp.aai.introspection.Version;
+
+import javax.ws.rs.core.*;
+import java.io.IOException;
+import java.util.*;
+
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.when;
+
+public class VertexIdConsumerTest extends AAISetup {
+
+ protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
+
+ private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
+
+ static {
+ VALID_HTTP_STATUS_CODES.add(200);
+ VALID_HTTP_STATUS_CODES.add(201);
+ VALID_HTTP_STATUS_CODES.add(204);
+ }
+
+ private VertexIdConsumer vertexIdConsumer;
+ private LegacyMoxyConsumer legacyMoxyConsumer;
+
+ private HttpHeaders httpHeaders;
+
+ private UriInfo uriInfo;
+
+ private MultivaluedMap<String, String> headersMultiMap;
+ private MultivaluedMap<String, String> queryParameters;
+
+ private List<String> aaiRequestContextList;
+
+ private List<MediaType> outputMediaTypes;
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(LegacyMoxyConsumerTest.class.getName());
+
+ @BeforeClass
+ public static void setupRest(){
+ AAIGraph.getInstance();
+ ModelInjestor.getInstance();
+ }
+
+ @Before
+ public void setup(){
+ logger.info("Starting the setup for the integration tests of Rest Endpoints");
+
+ vertexIdConsumer = new VertexIdConsumer();
+ legacyMoxyConsumer = new LegacyMoxyConsumer();
+
+ httpHeaders = Mockito.mock(HttpHeaders.class);
+ uriInfo = Mockito.mock(UriInfo.class);
+
+ headersMultiMap = new MultivaluedHashMap<>();
+ queryParameters = Mockito.spy(new MultivaluedHashMap<>());
+
+ headersMultiMap.add("X-FromAppId", "JUNIT");
+ headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString());
+ headersMultiMap.add("Real-Time", "true");
+ headersMultiMap.add("Accept", "application/json");
+ headersMultiMap.add("aai-request-context", "");
+
+ outputMediaTypes = new ArrayList<>();
+ outputMediaTypes.add(APPLICATION_JSON);
+
+ aaiRequestContextList = new ArrayList<>();
+ aaiRequestContextList.add("");
+
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+
+ when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList);
+
+
+ when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
+ when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
+
+ // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
+ Mockito.doReturn(null).when(queryParameters).remove(anyObject());
+
+ when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
+ }
+
+ @Test
+ public void testResponsePutGetDeleteOnResource() throws JSONException, IOException, AAIException {
+
+ String uri = "cloud-infrastructure/pservers/pserver/" + UUID.randomUUID().toString();
+ String payload = "{}";
+
+ when(uriInfo.getPath()).thenReturn(uri);
+ when(uriInfo.getPath(false)).thenReturn(uri);
+
+ Response response = legacyMoxyConsumer.getLegacy(
+ "",
+ Version.getLatest().toString(),
+ uri,
+ "all",
+ "false",
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
+
+ response = legacyMoxyConsumer.update(
+ payload,
+ Version.getLatest().toString(),
+ uri,
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ int code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
+
+ MultivaluedMap<String, Object> responseHeaders = response.getMetadata();
+
+ assertNotNull("Unable to retrieve the response headers from response object", responseHeaders);
+ assertTrue("Response doesn't contain the key vertexId", responseHeaders.containsKey("vertex-id"));
+
+ String vertexId = responseHeaders.get("vertex-id").get(0).toString();
+
+ response = vertexIdConsumer.getByVertexId(
+ "",
+ Version.getLatest().toString(),
+ Long.valueOf(vertexId).longValue(),
+ "10000",
+ httpHeaders,
+ uriInfo,
+ null
+ );
+
+ assertNotNull(response);
+ String pserverObject = response.getEntity().toString();
+
+ System.out.println(pserverObject);
+ }
+} \ No newline at end of file
diff --git a/aai-resources/src/test/java/org/openecomp/aai/rest/retired/RetiredConsumerTest.java b/aai-resources/src/test/java/org/openecomp/aai/rest/retired/RetiredConsumerTest.java
new file mode 100644
index 0000000..1f204f5
--- /dev/null
+++ b/aai-resources/src/test/java/org/openecomp/aai/rest/retired/RetiredConsumerTest.java
@@ -0,0 +1,107 @@
+package org.openecomp.aai.rest.retired;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.aai.introspection.Version;
+
+import javax.ws.rs.core.*;
+import java.util.*;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.when;
+
+public abstract class RetiredConsumerTest {
+
+ protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
+
+ private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
+
+ static {
+ VALID_HTTP_STATUS_CODES.add(200);
+ VALID_HTTP_STATUS_CODES.add(201);
+ VALID_HTTP_STATUS_CODES.add(204);
+ }
+
+ protected RetiredConsumer retiredConsumer;
+ protected HttpHeaders httpHeaders;
+ protected UriInfo uriInfo;
+
+ private MultivaluedMap<String, String> headersMultiMap;
+ private MultivaluedMap<String, String> queryParameters;
+
+ private List<String> aaiRequestContextList;
+
+ private List<MediaType> outputMediaTypes;
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(RetiredConsumer.class.getName());
+
+ @Before
+ public void setup(){
+ logger.info("Starting the setup for the integration tests of Rest Endpoints");
+
+ retiredConsumer = getRetiredConsumer();
+ httpHeaders = Mockito.mock(HttpHeaders.class);
+ uriInfo = Mockito.mock(UriInfo.class);
+
+ headersMultiMap = new MultivaluedHashMap<>();
+ queryParameters = Mockito.spy(new MultivaluedHashMap<>());
+
+ headersMultiMap.add("X-FromAppId", "JUNIT");
+ headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString());
+ headersMultiMap.add("Real-Time", "true");
+ headersMultiMap.add("Accept", "application/json");
+ headersMultiMap.add("aai-request-context", "");
+
+ outputMediaTypes = new ArrayList<>();
+ outputMediaTypes.add(APPLICATION_JSON);
+
+ aaiRequestContextList = new ArrayList<>();
+ aaiRequestContextList.add("");
+
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+
+ when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList);
+
+
+ when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
+ when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
+
+ // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
+ Mockito.doReturn(null).when(queryParameters).remove(anyObject());
+
+ when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
+ }
+
+ @Test
+ public void testRetiredForAllEndPoints(){
+ when(uriInfo.getPath()).thenReturn("/aai/v3/cloud-infrastructure/pservers/pserver/test-pserver1");
+
+ Response response = retiredConsumer.createMessageGet(Version.getLatest().toString(), httpHeaders, uriInfo, null);
+ assertNotNull(response);
+ assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus());
+
+ response = retiredConsumer.createMessagePost(Version.getLatest().toString(), httpHeaders, uriInfo, null);
+ assertNotNull(response);
+ assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus());
+
+ response = retiredConsumer.createMessagePatch(Version.getLatest().toString(), httpHeaders, uriInfo, null);
+ assertNotNull(response);
+ assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus());
+
+ response = retiredConsumer.createMessagePut(Version.getLatest().toString(), httpHeaders, uriInfo, null);
+ assertNotNull(response);
+ assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus());
+
+ response = retiredConsumer.createMessageDelete(Version.getLatest().toString(), httpHeaders, uriInfo, null);
+ assertNotNull(response);
+ assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus());
+ }
+
+ public abstract RetiredConsumer getRetiredConsumer();
+}
diff --git a/aai-resources/src/test/java/org/openecomp/aai/rest/retired/V3ThroughV7ConsumerTest.java b/aai-resources/src/test/java/org/openecomp/aai/rest/retired/V3ThroughV7ConsumerTest.java
new file mode 100644
index 0000000..8dc1c10
--- /dev/null
+++ b/aai-resources/src/test/java/org/openecomp/aai/rest/retired/V3ThroughV7ConsumerTest.java
@@ -0,0 +1,9 @@
+package org.openecomp.aai.rest.retired;
+
+public class V3ThroughV7ConsumerTest extends RetiredConsumerTest {
+
+ @Override
+ public RetiredConsumer getRetiredConsumer() {
+ return new V3ThroughV7Consumer();
+ }
+} \ No newline at end of file
diff --git a/aai-resources/src/test/java/org/openecomp/aai/rest/retired/V7V8ModelsTest.java b/aai-resources/src/test/java/org/openecomp/aai/rest/retired/V7V8ModelsTest.java
new file mode 100644
index 0000000..b6c340e
--- /dev/null
+++ b/aai-resources/src/test/java/org/openecomp/aai/rest/retired/V7V8ModelsTest.java
@@ -0,0 +1,9 @@
+package org.openecomp.aai.rest.retired;
+
+public class V7V8ModelsTest extends RetiredConsumerTest {
+
+ @Override
+ public RetiredConsumer getRetiredConsumer() {
+ return new V7V8Models();
+ }
+} \ No newline at end of file
diff --git a/aai-resources/src/test/java/org/openecomp/aai/rest/retired/V7V8NamedQueriesTest.java b/aai-resources/src/test/java/org/openecomp/aai/rest/retired/V7V8NamedQueriesTest.java
new file mode 100644
index 0000000..db4d35d
--- /dev/null
+++ b/aai-resources/src/test/java/org/openecomp/aai/rest/retired/V7V8NamedQueriesTest.java
@@ -0,0 +1,9 @@
+package org.openecomp.aai.rest.retired;
+
+public class V7V8NamedQueriesTest extends RetiredConsumerTest {
+
+ @Override
+ public RetiredConsumer getRetiredConsumer() {
+ return new V7V8NamedQueries();
+ }
+} \ No newline at end of file
diff --git a/aai-resources/src/test/java/org/openecomp/aai/rest/tools/ModelVersionTransformerTest.java b/aai-resources/src/test/java/org/openecomp/aai/rest/tools/ModelVersionTransformerTest.java
new file mode 100644
index 0000000..75d25df
--- /dev/null
+++ b/aai-resources/src/test/java/org/openecomp/aai/rest/tools/ModelVersionTransformerTest.java
@@ -0,0 +1,116 @@
+package org.openecomp.aai.rest.tools;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.aai.AAISetup;
+import org.openecomp.aai.dbmap.AAIGraph;
+import org.openecomp.aai.introspection.ModelInjestor;
+import org.skyscreamer.jsonassert.JSONAssert;
+
+import javax.ws.rs.core.*;
+import java.util.*;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.when;
+
+public class ModelVersionTransformerTest extends AAISetup {
+
+
+ protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
+
+ private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
+
+ static {
+ VALID_HTTP_STATUS_CODES.add(200);
+ VALID_HTTP_STATUS_CODES.add(201);
+ VALID_HTTP_STATUS_CODES.add(204);
+ }
+
+ private ModelVersionTransformer modelVersionTransformer;
+
+ private HttpHeaders httpHeaders;
+
+ private UriInfo uriInfo;
+
+ private MultivaluedMap<String, String> headersMultiMap;
+ private MultivaluedMap<String, String> queryParameters;
+
+ private List<String> aaiRequestContextList;
+
+ private List<MediaType> outputMediaTypes;
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(ModelVersionTransformerTest.class.getName());
+
+ @BeforeClass
+ public static void setupRest(){
+ AAIGraph.getInstance();
+ ModelInjestor.getInstance();
+ }
+
+ @Before
+ public void setup(){
+ logger.info("Starting the setup for the integration tests of Rest Endpoints");
+
+ modelVersionTransformer = new ModelVersionTransformer();
+ httpHeaders = Mockito.mock(HttpHeaders.class);
+ uriInfo = Mockito.mock(UriInfo.class);
+
+ headersMultiMap = new MultivaluedHashMap<>();
+ queryParameters = Mockito.spy(new MultivaluedHashMap<>());
+
+ headersMultiMap.add("X-FromAppId", "JUNIT");
+ headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString());
+ headersMultiMap.add("Real-Time", "true");
+ headersMultiMap.add("Content-Type", "application/xml");
+ headersMultiMap.add("Accept", "application/json");
+ headersMultiMap.add("aai-request-context", "");
+
+ outputMediaTypes = new ArrayList<>();
+ outputMediaTypes.add(APPLICATION_JSON);
+
+ aaiRequestContextList = new ArrayList<>();
+ aaiRequestContextList.add("");
+
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+ when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList);
+
+
+ when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
+ when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
+
+ // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
+ Mockito.doReturn(null).when(queryParameters).remove(anyObject());
+
+ when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
+ }
+
+ @Test
+ public void modelTransform() throws Exception {
+
+ String modelXmlPayload = getPayload("payloads/modeltransforms/model.xml");
+ String modelJsonPayload = getPayload("payloads/modeltransforms/model.json");
+
+ String uri = "modeltransform";
+
+ when(uriInfo.getPath()).thenReturn(uri);
+ // Comment the following line for the null pointer exception
+ when(uriInfo.getPath(false)).thenReturn(uri);
+
+ outputMediaTypes = new ArrayList<>();
+ outputMediaTypes.add(MediaType.valueOf("application/xml"));
+
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+ when(httpHeaders.getMediaType()).thenReturn(MediaType.valueOf("application/xml"));
+
+ Response response = modelVersionTransformer.modelTransform(modelXmlPayload,uri, httpHeaders, uriInfo, null);
+
+ assertNotNull(response);
+ }
+} \ No newline at end of file
diff --git a/aai-resources/src/test/java/org/openecomp/aai/rest/util/EchoResponseTest.java b/aai-resources/src/test/java/org/openecomp/aai/rest/util/EchoResponseTest.java
new file mode 100644
index 0000000..c4d435a
--- /dev/null
+++ b/aai-resources/src/test/java/org/openecomp/aai/rest/util/EchoResponseTest.java
@@ -0,0 +1,116 @@
+package org.openecomp.aai.rest.util;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.aai.AAISetup;
+
+import javax.ws.rs.core.*;
+import java.util.*;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class EchoResponseTest extends AAISetup {
+
+ protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
+
+ private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
+
+ static {
+ VALID_HTTP_STATUS_CODES.add(200);
+ VALID_HTTP_STATUS_CODES.add(201);
+ VALID_HTTP_STATUS_CODES.add(204);
+ }
+
+ private EchoResponse echoResponse;
+
+ private HttpHeaders httpHeaders;
+
+ private UriInfo uriInfo;
+
+ private MultivaluedMap<String, String> headersMultiMap;
+ private MultivaluedMap<String, String> queryParameters;
+
+ private List<String> aaiRequestContextList;
+
+ private List<MediaType> outputMediaTypes;
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(EchoResponseTest.class.getName());
+
+ @Before
+ public void setup(){
+ logger.info("Starting the setup for the integration tests of Rest Endpoints");
+
+ echoResponse = new EchoResponse();
+ httpHeaders = mock(HttpHeaders.class);
+ uriInfo = mock(UriInfo.class);
+
+ headersMultiMap = new MultivaluedHashMap<>();
+ queryParameters = Mockito.spy(new MultivaluedHashMap<>());
+
+ headersMultiMap.add("X-FromAppId", "JUNIT");
+ headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString());
+ headersMultiMap.add("Real-Time", "true");
+ headersMultiMap.add("Accept", "application/json");
+ headersMultiMap.add("aai-request-context", "");
+
+ outputMediaTypes = new ArrayList<>();
+ outputMediaTypes.add(APPLICATION_JSON);
+
+ aaiRequestContextList = new ArrayList<>();
+ aaiRequestContextList.add("");
+
+ when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
+ when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
+ when(httpHeaders.getRequestHeader("X-FromAppId")).thenReturn(Arrays.asList("JUNIT"));
+ when(httpHeaders.getRequestHeader("X-TransactionId")).thenReturn(Arrays.asList("JUNIT"));
+
+ when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList);
+
+
+ when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
+ when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
+
+ // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
+ Mockito.doReturn(null).when(queryParameters).remove(anyObject());
+
+ when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
+ }
+
+ @Test
+ public void testEchoResultWhenValidHeaders() throws Exception {
+
+ Response response = echoResponse.echoResult(httpHeaders, null, "");
+
+ assertNotNull(response);
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testEchoResultWhenInValidHeadersThrowsBadRequest() throws Exception {
+
+ httpHeaders = mock(HttpHeaders.class);
+ Response response = echoResponse.echoResult(httpHeaders, null, "");
+
+ assertNotNull(response);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testEchoResultWhenValidHeadersButMediaTypeWrong() throws Exception {
+
+ when(httpHeaders.getAcceptableMediaTypes()).thenThrow(new IllegalStateException())
+ .thenReturn(outputMediaTypes);
+
+ Response response = echoResponse.echoResult(httpHeaders, null, "");
+
+ assertNotNull(response);
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());
+ }
+} \ No newline at end of file
diff --git a/aai-resources/src/test/java/org/openecomp/aai/rest/util/LogFormatToolsTest.java b/aai-resources/src/test/java/org/openecomp/aai/rest/util/LogFormatToolsTest.java
new file mode 100644
index 0000000..55d8ce3
--- /dev/null
+++ b/aai-resources/src/test/java/org/openecomp/aai/rest/util/LogFormatToolsTest.java
@@ -0,0 +1,15 @@
+package org.openecomp.aai.rest.util;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+
+public class LogFormatToolsTest {
+
+ @Test
+ public void testLogFormatTools(){
+
+ String dateTime = new LogFormatTools().getCurrentDateTime();
+ assertNotNull(dateTime);
+ }
+} \ No newline at end of file
diff --git a/aai-resources/src/test/java/org/openecomp/aai/rest/util/ValidateEncodingTest.java b/aai-resources/src/test/java/org/openecomp/aai/rest/util/ValidateEncodingTest.java
index 8c6450d..220d7d3 100644
--- a/aai-resources/src/test/java/org/openecomp/aai/rest/util/ValidateEncodingTest.java
+++ b/aai-resources/src/test/java/org/openecomp/aai/rest/util/ValidateEncodingTest.java
@@ -20,16 +20,15 @@
package org.openecomp.aai.rest.util;
-import static org.junit.Assert.*;
-
-import java.io.UnsupportedEncodingException;
+import org.junit.Test;
+import org.mockito.Mockito;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.UriInfo;
+import java.io.UnsupportedEncodingException;
-import org.junit.Test;
-import org.mockito.Mockito;
+import static org.junit.Assert.assertEquals;
public class ValidateEncodingTest {