diff options
author | William Reehil <william.reehil@att.com> | 2022-11-11 13:37:39 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2022-11-11 13:37:39 +0000 |
commit | 72b44a38290334c46a9dedc0be1dadcd08520515 (patch) | |
tree | 4ea0ae01f4dabf1b9781779b5fea790f9c2c03ba | |
parent | 131345b4ef18b8dc2c346c6af59f90f0d3fde431 (diff) | |
parent | 2c9ee21f2cf8fc230decfc48e3f652fe11862216 (diff) |
Merge "Reduce the number of raw-type related warnings in aai-common"
25 files changed, 98 insertions, 59 deletions
diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AafRequestFilter.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AafRequestFilter.java index cfaa61be..2c8aaf28 100644 --- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AafRequestFilter.java +++ b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AafRequestFilter.java @@ -99,7 +99,7 @@ public class AafRequestFilter { return; } issuer = issuer.replaceAll("\\s+", "").toUpperCase(); - Enumeration hdrs = request.getHeaders(CertUtil.AAF_USER_CHAIN_HDR); + Enumeration<String> hdrs = request.getHeaders(CertUtil.AAF_USER_CHAIN_HDR); while (hdrs.hasMoreElements()) { String headerValue = (String) hdrs.nextElement(); LOGGER.debug("authorizationFilter user chain headerValue=" + headerValue); diff --git a/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java b/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java index 2858ece3..d3addebb 100644 --- a/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java +++ b/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java @@ -119,7 +119,7 @@ public class AAIDmaapEventJMSConsumer implements MessageListener { } metricLog.pre(eventName, aaiEvent, transactionId, serviceName); - HttpEntity httpEntity = new HttpEntity(aaiEvent, httpHeaders); + HttpEntity<String> httpEntity = new HttpEntity<String>(aaiEvent, httpHeaders); String transportType = environment.getProperty("dmaap.ribbon.transportType", "http"); String baseUrl = transportType + "://" + environment.getProperty("dmaap.ribbon.listOfServers"); diff --git a/aai-core/src/main/java/org/onap/aai/introspection/JSONStrategy.java b/aai-core/src/main/java/org/onap/aai/introspection/JSONStrategy.java index 2676d19d..496c1e82 100644 --- a/aai-core/src/main/java/org/onap/aai/introspection/JSONStrategy.java +++ b/aai-core/src/main/java/org/onap/aai/introspection/JSONStrategy.java @@ -151,7 +151,7 @@ public class JSONStrategy extends Introspector { Class<?> resultClass = null; Object resultObject = this.getValue(name); if (resultObject instanceof JSONArray) { - resultClass = ((List) resultObject).get(0).getClass(); + resultClass = ((List<?>) resultObject).get(0).getClass(); } return resultClass; diff --git a/aai-core/src/main/java/org/onap/aai/introspection/MoxyStrategy.java b/aai-core/src/main/java/org/onap/aai/introspection/MoxyStrategy.java index df8e9238..55980c3b 100644 --- a/aai-core/src/main/java/org/onap/aai/introspection/MoxyStrategy.java +++ b/aai-core/src/main/java/org/onap/aai/introspection/MoxyStrategy.java @@ -25,8 +25,15 @@ import com.google.common.base.Joiner; import java.io.StringWriter; import java.io.UnsupportedEncodingException; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; @@ -170,12 +177,12 @@ public class MoxyStrategy extends Introspector { DatabaseMapping mapping = cd.getMappingForAttributeName(propName); Map<PropertyMetadata, String> result = new HashMap<>(); if (mapping != null) { - Set<Entry> entrySet = mapping.getProperties().entrySet(); - for (Entry<?, ?> entry : entrySet) { + Set<Map.Entry<String, String>> entrySet = mapping.getProperties().entrySet(); + for (Entry<String, String> entry : entrySet) { result.put( - PropertyMetadata.valueOf( - CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, (String) entry.getKey())), - (String) entry.getValue()); + PropertyMetadata + .valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, entry.getKey())), + entry.getValue()); } } diff --git a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/PrivateEdge.java b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/PrivateEdge.java index 9e32ef40..e58ff9bc 100644 --- a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/PrivateEdge.java +++ b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/PrivateEdge.java @@ -25,8 +25,12 @@ import com.google.common.collect.Multimap; import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URISyntaxException; -import java.util.*; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; +import java.util.Optional; import javax.ws.rs.core.MultivaluedMap; @@ -92,7 +96,7 @@ public class PrivateEdge extends SideEffect { List<Vertex> results = uriQuery.getQueryBuilder().toList(); if (results.size() == 1) { Vertex otherVertex = results.get(0); - VertexProperty otherVProperty = otherVertex.property("aai-node-type"); + VertexProperty<Object> otherVProperty = otherVertex.property("aai-node-type"); if (otherVProperty.isPresent()) { diff --git a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationService.java b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationService.java index c66511f0..70e16e27 100644 --- a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationService.java +++ b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationService.java @@ -222,7 +222,7 @@ public class ValidationService { httpHeaders.put("Content-Type", "application/json"); List<String> violations = new ArrayList<>(); - ResponseEntity responseEntity; + ResponseEntity<String> responseEntity; try { responseEntity = validationRestClient.execute(VALIDATION_ENDPOINT, HttpMethod.POST, httpHeaders, body); @@ -267,7 +267,7 @@ public class ValidationService { return violations; } - boolean isSuccess(ResponseEntity responseEntity) { + boolean isSuccess(ResponseEntity<String> responseEntity) { return responseEntity != null && responseEntity.getStatusCode().is2xxSuccessful(); } diff --git a/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java b/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java index 187db197..3c5c4489 100644 --- a/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java +++ b/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java @@ -909,7 +909,7 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> { protected void executeQuery() { - Admin admin; + Admin<Vertex, Vertex> admin; if (start != null) { this.completeTraversal = traversal.asAdmin(); } else { diff --git a/aai-core/src/main/java/org/onap/aai/restcore/RESTAPI.java b/aai-core/src/main/java/org/onap/aai/restcore/RESTAPI.java index 3666eb67..31805fd4 100644 --- a/aai-core/src/main/java/org/onap/aai/restcore/RESTAPI.java +++ b/aai-core/src/main/java/org/onap/aai/restcore/RESTAPI.java @@ -341,7 +341,7 @@ public class RESTAPI { * @return the response */ public Response runner(String toe, String tba, String tdl, HttpHeaders headers, UriInfo info, HttpMethod httpMethod, - Callable c) { + Callable<Response> c) { Response response = null; Future<Response> handler = null; ExecutorService executor = null; diff --git a/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java b/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java index 9f599eb9..2192ff5e 100644 --- a/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java +++ b/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java @@ -723,7 +723,7 @@ public class DBSerializer { throws IllegalArgumentException, SecurityException, UnsupportedEncodingException, AAIException { HashMap<String, Introspector> relatedVertices = new HashMap<>(); - VertexProperty aaiUriProperty = v.property(AAIProperties.AAI_URI); + VertexProperty<Object> aaiUriProperty = v.property(AAIProperties.AAI_URI); if (!aaiUriProperty.isPresent()) { if (LOGGER.isDebugEnabled()) { @@ -1232,7 +1232,7 @@ public class DBSerializer { throw new AAIException("AAI_6136", "query object mismatch: this object cannot hold multiple items." + obj.getDbName()); } else if (obj.isContainer()) { - final List getList; + final List<Object> getList; String listProperty = null; for (String property : obj.getProperties()) { if (obj.isListType(property) && obj.isComplexGenericType(property)) { @@ -1565,7 +1565,7 @@ public class DBSerializer { throws UnsupportedEncodingException, AAIException { List<Object> relationshipObjList = obj.getValue(RELATIONSHIP); - VertexProperty nodeTypeProperty = v.property(AAIProperties.NODE_TYPE); + VertexProperty<Object> nodeTypeProperty = v.property(AAIProperties.NODE_TYPE); if (!nodeTypeProperty.isPresent()) { LOGGER.warn("Not processing the vertex {} because its missing required property aai-node-type", v.id()); @@ -1651,7 +1651,7 @@ public class DBSerializer { private Object processEdgeRelationship(Introspector relationshipObj, Vertex cousin, String cleanUp, String edgeLabel, boolean isSkipRelatedTo) throws UnsupportedEncodingException, AAIUnknownObjectException { - VertexProperty aaiUriProperty = cousin.property("aai-uri"); + VertexProperty<Object> aaiUriProperty = cousin.property("aai-uri"); if (!aaiUriProperty.isPresent()) { return null; @@ -1670,7 +1670,7 @@ public class DBSerializer { return null; } - VertexProperty cousinVertexNodeType = cousin.property(AAIProperties.NODE_TYPE); + VertexProperty<Object> cousinVertexNodeType = cousin.property(AAIProperties.NODE_TYPE); if (cousinVertexNodeType.isPresent()) { String cousinType = cousinVertexNodeType.value().toString(); diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java index 3706da0d..71f7bc78 100644 --- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java +++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java @@ -202,7 +202,8 @@ public class Aggregate extends MultiFormatMapper { return Optional.of(json); } - private Optional<JsonArray> processInput(Object input, Map properties) throws AAIFormatVertexException { + private Optional<JsonArray> processInput(Object input, Map<String, List<String>> properties) + throws AAIFormatVertexException { JsonArray json = new JsonArray(); for (Object l : (ArrayList) input) { if (l instanceof ArrayList) { diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java index e03620ba..c0ba860f 100644 --- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java +++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java @@ -104,7 +104,7 @@ public class GraphSON implements FormatMapper { */ private void removePrivateEdges(JsonObject jsonObject, JsonObject edges, String edgeDirection) { - Iterator it = edges.entrySet().iterator(); + Iterator<Map.Entry<String, JsonElement>> it = edges.entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, JsonElement> outEntry = (Map.Entry<String, JsonElement>) it.next(); JsonArray edgePropertiesArray = outEntry.getValue().getAsJsonArray(); diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/HistoryFormat.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/HistoryFormat.java index 4443ade8..02c4041f 100644 --- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/HistoryFormat.java +++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/HistoryFormat.java @@ -92,10 +92,10 @@ public abstract class HistoryFormat extends MultiFormatMapper { protected JsonObject createMetaPropertiesObject(VertexProperty<Object> prop) { JsonObject json = new JsonObject(); - Iterator iter = prop.properties(); + Iterator<Property<Object>> iter = prop.properties(); while (iter.hasNext()) { - Property<Object> metaProp = (Property) iter.next(); + Property<Object> metaProp = iter.next(); mapPropertyValues(json, metaProp.key(), metaProp.value()); } diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/SimpleFormat.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/SimpleFormat.java index 657dd89b..1caa7b50 100644 --- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/SimpleFormat.java +++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/SimpleFormat.java @@ -78,7 +78,7 @@ public class SimpleFormat extends RawFormat { @Override protected void addEdge(Edge e, Vertex v, JsonArray array) throws AAIFormatVertexException { - Property property = e.property("private"); + Property<Object> property = e.property("private"); if (property.isPresent()) { if ("true".equals(e.property("private").value().toString())) { diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/TreeFormat.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/TreeFormat.java index 4b8229fa..0da0ec55 100644 --- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/TreeFormat.java +++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/TreeFormat.java @@ -183,9 +183,9 @@ public class TreeFormat extends MultiFormatMapper { // DSL Query if (o instanceof BulkSet) { - BulkSet bs = (BulkSet) o; - for (Object o1 : bs) { - Optional<JsonObject> obj = this.getJsonFromVertex((Vertex) o1); + BulkSet<Vertex> bs = (BulkSet<Vertex>) o; + for (Vertex o1 : bs) { + Optional<JsonObject> obj = this.getJsonFromVertex(o1); if (obj.isPresent()) { jsonObject = obj.get(); for (Map.Entry<String, JsonElement> mapEntry : jsonObject.entrySet()) { diff --git a/aai-core/src/main/java/org/onap/aai/util/RestController.java b/aai-core/src/main/java/org/onap/aai/util/RestController.java index 379b31f3..1b050829 100644 --- a/aai-core/src/main/java/org/onap/aai/util/RestController.java +++ b/aai-core/src/main/java/org/onap/aai/util/RestController.java @@ -257,7 +257,7 @@ public class RestController implements RestControllerInterface { * @return the list * @throws Exception the exception */ - private <T> List<T> mapJsonToObjectList(T typeDef, String json, Class clazz) throws Exception { + private <T> List<T> mapJsonToObjectList(T typeDef, String json, Class<?> clazz) throws Exception { List<T> list; ObjectMapper mapper = new ObjectMapper(); System.out.println(json); diff --git a/aai-core/src/test/java/org/onap/aai/prevalidation/ValidationServiceTest.java b/aai-core/src/test/java/org/onap/aai/prevalidation/ValidationServiceTest.java index 7f6e5610..d017408f 100644 --- a/aai-core/src/test/java/org/onap/aai/prevalidation/ValidationServiceTest.java +++ b/aai-core/src/test/java/org/onap/aai/prevalidation/ValidationServiceTest.java @@ -115,7 +115,7 @@ public class ValidationServiceTest { String validationResponse = PayloadUtil.getResourcePayload("prevalidation/success-response-with-empty-violations.json"); - ResponseEntity responseEntity = Mockito.mock(ResponseEntity.class, Mockito.RETURNS_DEEP_STUBS); + ResponseEntity<String> responseEntity = Mockito.mock(ResponseEntity.class, Mockito.RETURNS_DEEP_STUBS); Mockito.when(restClient.execute(eq(ValidationService.VALIDATION_ENDPOINT), eq(HttpMethod.POST), any(), eq(pserverRequest))).thenReturn(responseEntity); diff --git a/aai-core/src/test/java/org/onap/aai/restcore/RESTAPITest.java b/aai-core/src/test/java/org/onap/aai/restcore/RESTAPITest.java index 3c099c75..4b73a7d7 100644 --- a/aai-core/src/test/java/org/onap/aai/restcore/RESTAPITest.java +++ b/aai-core/src/test/java/org/onap/aai/restcore/RESTAPITest.java @@ -27,7 +27,11 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.Callable; -import javax.ws.rs.core.*; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MultivaluedHashMap; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; import org.junit.Assert; import org.junit.BeforeClass; @@ -38,7 +42,7 @@ import org.onap.aai.exceptions.AAIException; public class RESTAPITest extends AAISetup { private static RESTAPI restapi; private static HttpHeaders httpHeaders; - private static Callable callable; + private static Callable<Response> callable; private static UriInfo info; private static Response response; diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerTest.java b/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerTest.java index 282f6457..f921a77c 100644 --- a/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerTest.java +++ b/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerTest.java @@ -21,14 +21,27 @@ package org.onap.aai.serialization.db; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URISyntaxException; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.UUID; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.Edge; @@ -37,7 +50,12 @@ import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; import org.janusgraph.core.JanusGraphFactory; -import org.junit.*; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -987,7 +1005,7 @@ public class DbSerializerTest extends AAISetup { @Test public void cascadeL3NetworkPreventDeleteTest() throws AAIException, UnsupportedEncodingException { l3NetworkSetup(); - ArrayList expected_messages = new ArrayList<String>(); + ArrayList<String> expected_messages = new ArrayList<>(); expected_messages.add( "Object is being reference by additional objects preventing it from being deleted. Please clean up references from the following types [l3-interface-ipv4-address-list, l3-interface-ipv6-address-list]"); expected_messages.add( diff --git a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/ResourceFormatTest.java b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/ResourceFormatTest.java index 10178931..e26c56e2 100644 --- a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/ResourceFormatTest.java +++ b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/ResourceFormatTest.java @@ -20,7 +20,9 @@ package org.onap.aai.serialization.queryformats; -import static org.junit.Assert.*; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; @@ -130,7 +132,7 @@ public class ResourceFormatTest extends AAISetup { FormatFactory ff = new FormatFactory(loader, serializer, schemaVersions, basePath, "https://localhost:8447/aai/"); - MultivaluedMap mvm = new MultivaluedHashMap(); + MultivaluedMap<String, String> mvm = new MultivaluedHashMap<>(); mvm.add("depth", "0"); Formatter formatter = ff.get(Format.resource, mvm); diff --git a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/SimpleFormatTest.java b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/SimpleFormatTest.java index 7aebe84d..7634d22a 100644 --- a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/SimpleFormatTest.java +++ b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/SimpleFormatTest.java @@ -142,7 +142,7 @@ public class SimpleFormatTest extends AAISetup { FormatFactory ff = new FormatFactory(loader, serializer, schemaVersions, basePath, "https://localhost:8447/aai/"); - MultivaluedMap mvm = new MultivaluedHashMap(); + MultivaluedMap<String, String> mvm = new MultivaluedHashMap<>(); mvm.add("depth", "0"); Formatter formatter = ff.get(Format.simple, mvm); diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/LoggingContext.java b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/LoggingContext.java index 97288af8..d3fbd959 100644 --- a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/LoggingContext.java +++ b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/LoggingContext.java @@ -41,7 +41,7 @@ public class LoggingContext { public static final String BUSINESS_PROCESS_ERROR = "500"; public static final String UNKNOWN_ERROR = "900"; - public static final Map<String, String> responseMap = new HashMap(); + public static final Map<String, String> responseMap = new HashMap<>(); // Specific Log Event Fields public static enum LoggingField { diff --git a/aai-rest/src/main/java/org/onap/aai/restclient/RestClient.java b/aai-rest/src/main/java/org/onap/aai/restclient/RestClient.java index 6fd2ab60..44b1fe44 100644 --- a/aai-rest/src/main/java/org/onap/aai/restclient/RestClient.java +++ b/aai-rest/src/main/java/org/onap/aai/restclient/RestClient.java @@ -53,7 +53,7 @@ public abstract class RestClient { * @return response of request * @throws RestClientException on internal rest template exception or invalid url */ - public ResponseEntity execute(String uri, HttpMethod method, Map<String, String> headers, String body) + public ResponseEntity<String> execute(String uri, HttpMethod method, Map<String, String> headers, String body) throws RestClientException { HttpEntity<String> httpEntity; @@ -79,7 +79,7 @@ public abstract class RestClient { throw new RestClientException(e.getMessage()); } log.debug("METHOD={}, URL={}, BODY={}", method, url, httpEntity.getBody()); - ResponseEntity responseEntity = getRestTemplate().exchange(url, method, httpEntity, String.class); + ResponseEntity<String> responseEntity = getRestTemplate().exchange(url, method, httpEntity, String.class); log.trace("RESPONSE={}", responseEntity); return responseEntity; } @@ -94,7 +94,7 @@ public abstract class RestClient { * @return response of request * @throws RestClientException on internal rest template exception or invalid url */ - public ResponseEntity execute(String uri, String method, Map<String, String> headers, String body) + public ResponseEntity<String> execute(String uri, String method, Map<String, String> headers, String body) throws RestClientException { return execute(uri, HttpMethod.valueOf(method), headers, body); } @@ -108,7 +108,7 @@ public abstract class RestClient { * @return response of request * @throws RestClientException on internal rest template exception or invalid url */ - public ResponseEntity execute(String uri, HttpMethod method, Map<String, String> headers) + public ResponseEntity<String> execute(String uri, HttpMethod method, Map<String, String> headers) throws RestClientException { return execute(uri, method, headers, null); } @@ -122,14 +122,15 @@ public abstract class RestClient { * @return response of request * @throws RestClientException on internal rest template exception or invalid url */ - public ResponseEntity execute(String uri, String method, Map<String, String> headers) throws RestClientException { + public ResponseEntity<String> execute(String uri, String method, Map<String, String> headers) + throws RestClientException { return execute(uri, HttpMethod.valueOf(method), headers, null); } - public ResponseEntity executeResource(String uri, HttpMethod method, Map<String, String> headers, String body) - throws RestClientException { + public ResponseEntity<Resource> executeResource(String uri, HttpMethod method, Map<String, String> headers, + String body) throws RestClientException { - HttpEntity httpEntity; + HttpEntity<String> httpEntity; log.debug("Headers: " + headers.toString()); if (body == null) { httpEntity = new HttpEntity(getHeaders(headers)); @@ -140,12 +141,12 @@ public abstract class RestClient { return getRestTemplate().exchange(url, method, httpEntity, Resource.class); } - public ResponseEntity getGetRequest(String content, String uri, Map<String, String> headersMap) { + public ResponseEntity<String> getGetRequest(String content, String uri, Map<String, String> headersMap) { return this.execute(uri, HttpMethod.GET, headersMap, content); } - public ResponseEntity getGetResource(String content, String uri, Map<String, String> headersMap) { + public ResponseEntity<Resource> getGetResource(String content, String uri, Map<String, String> headersMap) { return this.executeResource(uri, HttpMethod.GET, headersMap, content); } diff --git a/aai-rest/src/main/java/org/onap/aai/restclient/RestClientFactoryConfiguration.java b/aai-rest/src/main/java/org/onap/aai/restclient/RestClientFactoryConfiguration.java index 08060238..9a28c1cb 100644 --- a/aai-rest/src/main/java/org/onap/aai/restclient/RestClientFactoryConfiguration.java +++ b/aai-rest/src/main/java/org/onap/aai/restclient/RestClientFactoryConfiguration.java @@ -20,7 +20,6 @@ package org.onap.aai.restclient; -import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.config.ServiceLocatorFactoryBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -28,8 +27,9 @@ import org.springframework.context.annotation.Configuration; @Configuration public class RestClientFactoryConfiguration { + // ServiceLocatorFactoryBean @Bean - public FactoryBean restClientFactoryBean() { + public ServiceLocatorFactoryBean restClientFactoryBean() { ServiceLocatorFactoryBean factoryBean = new ServiceLocatorFactoryBean(); factoryBean.setServiceLocatorInterface(RestClientFactory.class); return factoryBean; diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java index 57988f0b..16889c7c 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java @@ -188,7 +188,7 @@ public class MockRestClient extends RestClient { } @Override - public ResponseEntity execute(String uri, HttpMethod method, Map<String, String> headers, String body) { + public ResponseEntity<String> execute(String uri, HttpMethod method, Map<String, String> headers, String body) { String url = "https://localhost:8447/aai/v14/" + uri; @@ -224,16 +224,17 @@ public class MockRestClient extends RestClient { headersMap.add("X-FromAppId", "JUNIT"); headersMap.add("X-TransactionId", "JUNIT"); - HttpEntity httpEntity = new HttpEntity(headers); + HttpEntity<String> httpEntity = new HttpEntity(headers); - ResponseEntity responseEntity = restTemplate.exchange(url, HttpMethod.GET, httpEntity, String.class); + ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.GET, httpEntity, String.class); // mockRestServiceServer.verify(); return responseEntity; } @Override - public ResponseEntity executeResource(String uri, HttpMethod method, Map<String, String> headers, String body) { + public ResponseEntity<Resource> executeResource(String uri, HttpMethod method, Map<String, String> headers, + String body) { String url = "https://localhost:8447/aai/v14/" + uri; @@ -269,9 +270,10 @@ public class MockRestClient extends RestClient { headersMap.add("X-FromAppId", "JUNIT"); headersMap.add("X-TransactionId", "JUNIT"); - HttpEntity httpEntity = new HttpEntity(headers); + HttpEntity<String> httpEntity = new HttpEntity(headers); - ResponseEntity responseEntity = restTemplate.exchange(url, HttpMethod.GET, httpEntity, Resource.class); + ResponseEntity<Resource> responseEntity = + restTemplate.exchange(url, HttpMethod.GET, httpEntity, Resource.class); // mockRestServiceServer.verify(); return responseEntity; diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java index cbbc63d3..4b12936e 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java @@ -50,7 +50,7 @@ public class SchemaRestClientTest { @Test public void testGetRequestToSchemaService() { - ResponseEntity aaiResponse; + ResponseEntity<String> aaiResponse; RestClient restClient = null; restClient = restClientFactory.getRestClient(SCHEMA_SERVICE); |