diff options
author | William Reehil <william.reehil@att.com> | 2022-11-15 14:32:02 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2022-11-15 14:32:02 +0000 |
commit | 24c274fd267d1eea33a1c47eba3aa01a5be1c442 (patch) | |
tree | 31fbaf516f5c35308bdb52f3bcc7281926817059 /aai-resources/src/test/java | |
parent | 31ab53b6ad8a4bc0a0405d0c8193e7d59c01b98d (diff) | |
parent | 96e5984c8132e1c0623e7dc8f38dac951fa0c42d (diff) |
Merge "Remove raw-type related warnings in resources"
Diffstat (limited to 'aai-resources/src/test/java')
13 files changed, 77 insertions, 40 deletions
diff --git a/aai-resources/src/test/java/org/onap/aai/it/multitenancy/MultiTenancyIT.java b/aai-resources/src/test/java/org/onap/aai/it/multitenancy/MultiTenancyIT.java index 300730a..baa78c9 100644 --- a/aai-resources/src/test/java/org/onap/aai/it/multitenancy/MultiTenancyIT.java +++ b/aai-resources/src/test/java/org/onap/aai/it/multitenancy/MultiTenancyIT.java @@ -35,7 +35,12 @@ import org.onap.aai.PayloadUtil; import org.onap.aai.rest.AbstractSpringRestTest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Import; -import org.springframework.http.*; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.test.context.TestPropertySource; @Import(KeycloakTestConfiguration.class) @@ -53,12 +58,12 @@ public class MultiTenancyIT extends AbstractSpringRestTest { public void testCreateAndGetPnf() throws Exception { baseUrl = "http://localhost:" + randomPort; String endpoint = baseUrl + "/aai/v23/network/pnfs/pnf/pnf-1"; - ResponseEntity responseEntity = null; + ResponseEntity<String> responseEntity = null; // create pnf with ran (operator) String username = "ran", password = "ran"; headers = this.getHeaders(username, password); - httpEntity = new HttpEntity(PayloadUtil.getResourcePayload("pnf.json"), headers); + httpEntity = new HttpEntity<String>(PayloadUtil.getResourcePayload("pnf.json"), headers); responseEntity = restTemplate.exchange(endpoint, HttpMethod.PUT, httpEntity, String.class); assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode()); @@ -66,7 +71,7 @@ public class MultiTenancyIT extends AbstractSpringRestTest { username = "bob"; password = "bob"; headers = this.getHeaders(username, password); - httpEntity = new HttpEntity("", headers); + httpEntity = new HttpEntity<String>("", headers); responseEntity = restTemplate.exchange(endpoint, HttpMethod.GET, httpEntity, String.class); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); @@ -74,14 +79,14 @@ public class MultiTenancyIT extends AbstractSpringRestTest { username = "ted"; password = "ted"; headers = this.getHeaders(username, password); - httpEntity = new HttpEntity("", headers); + httpEntity = new HttpEntity<String>("", headers); responseEntity = restTemplate.exchange(endpoint, HttpMethod.GET, httpEntity, String.class); assertEquals(HttpStatus.FORBIDDEN, responseEntity.getStatusCode()); // add role to ted and try to get pnf again roleHandler.addToUser(RoleHandler.OPERATOR_READ_ONLY, username); headers = this.getHeaders(username, password); - httpEntity = new HttpEntity("", headers); + httpEntity = new HttpEntity<String>("", headers); responseEntity = restTemplate.exchange(endpoint, HttpMethod.GET, httpEntity, String.class); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); @@ -89,7 +94,7 @@ public class MultiTenancyIT extends AbstractSpringRestTest { username = "ran"; password = "ran"; headers = this.getHeaders(username, password); - httpEntity = new HttpEntity("", headers); + httpEntity = new HttpEntity<String>("", headers); responseEntity = restTemplate.exchange(endpoint, HttpMethod.GET, httpEntity, String.class); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); } diff --git a/aai-resources/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java b/aai-resources/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java index b47485e..b4a1b52 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java @@ -28,7 +28,11 @@ import org.apache.tinkerpop.gremlin.process.traversal.P; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.janusgraph.core.JanusGraph; import org.janusgraph.core.JanusGraphTransaction; -import org.junit.*; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Rule; import org.onap.aai.ResourcesApp; import org.onap.aai.ResourcesTestConfiguration; import org.onap.aai.dbmap.AAIGraph; @@ -70,7 +74,7 @@ public abstract class AbstractSpringRestTest { @LocalServerPort protected int randomPort; - protected HttpEntity httpEntity; + protected HttpEntity<String> httpEntity; protected String baseUrl; protected HttpHeaders headers; @@ -98,7 +102,7 @@ public abstract class AbstractSpringRestTest { headers.add("X-TransactionId", "JUNIT"); headers.add("Authorization", "Basic " + authorization); - httpEntity = new HttpEntity(headers); + httpEntity = new HttpEntity<String>(headers); baseUrl = "http://localhost:" + randomPort; } diff --git a/aai-resources/src/test/java/org/onap/aai/rest/CloudRegionTest.java b/aai-resources/src/test/java/org/onap/aai/rest/CloudRegionTest.java index 0f4a20e..fd4d34b 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/CloudRegionTest.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/CloudRegionTest.java @@ -40,13 +40,13 @@ public class CloudRegionTest extends AbstractSpringRestTest { String endpoint = "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/testOwner/testRegionOne"; - ResponseEntity responseEntity = null; + ResponseEntity<String> responseEntity = null; responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class); assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode()); String payload = PayloadUtil.getResourcePayload("cloud-region.json"); - httpEntity = new HttpEntity(payload, headers); + httpEntity = new HttpEntity<String>(payload, headers); responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode()); diff --git a/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java b/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java index d8e02b2..357ea41 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java @@ -42,7 +42,12 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.web.server.LocalServerPort; import org.springframework.context.annotation.Import; -import org.springframework.http.*; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.web.client.RestTemplate; @@ -98,7 +103,7 @@ public class ConfigurationTest extends AbstractSpringRestTest { String cid = "configtest" + UUID.randomUUID().toString(); String endpoint = "/aai/v12/network/configurations/configuration/" + cid; - ResponseEntity responseEntity = null; + ResponseEntity<String> responseEntity = null; responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class); assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode()); @@ -159,7 +164,7 @@ public class ConfigurationTest extends AbstractSpringRestTest { @Test public void TestManagementEndpointConfiguration() { - ResponseEntity responseEntity = null; + ResponseEntity<String> responseEntity = null; String responseBody = null; // set Accept as text/plain in order to get access of endpoint "/actuator/prometheus" diff --git a/aai-resources/src/test/java/org/onap/aai/rest/CustomerFilterSearchTest.java b/aai-resources/src/test/java/org/onap/aai/rest/CustomerFilterSearchTest.java index cc35e21..28347cb 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/CustomerFilterSearchTest.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/CustomerFilterSearchTest.java @@ -29,7 +29,12 @@ import java.util.Collections; import org.junit.Test; import org.onap.aai.PayloadUtil; -import org.springframework.http.*; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; public class CustomerFilterSearchTest extends AbstractSpringRestTest { @@ -49,16 +54,16 @@ public class CustomerFilterSearchTest extends AbstractSpringRestTest { headers.add("Authorization", "Basic " + authorization); String body = PayloadUtil.getResourcePayload("customer.json"); - httpEntity = new HttpEntity(body, headers); + httpEntity = new HttpEntity<String>(body, headers); baseUrl = "http://localhost:" + randomPort; - ResponseEntity responseEntity; + ResponseEntity<String> responseEntity; responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode()); String searchUrl = baseUrl + "/aai/v11/business/customers?subscriber-name=subscriber-name-987654321-91&depth=0"; - httpEntity = new HttpEntity(headers); + httpEntity = new HttpEntity<String>(headers); responseEntity = restTemplate.exchange(searchUrl, HttpMethod.GET, httpEntity, String.class); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); assertThat(responseEntity.getBody().toString(), containsString("global-customer-id")); diff --git a/aai-resources/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java index fab07fc..a804ee5 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java @@ -67,7 +67,7 @@ public class ExceptionHandlerTest extends AAISetup { public void setup() { MockitoAnnotations.initMocks(this); - MultivaluedHashMap headersMultiMap = new MultivaluedHashMap<>(); + MultivaluedHashMap<String, String> headersMultiMap = new MultivaluedHashMap<>(); headersMultiMap.add("X-FromAppId", "JUNIT"); headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString()); diff --git a/aai-resources/src/test/java/org/onap/aai/rest/InvalidURITest.java b/aai-resources/src/test/java/org/onap/aai/rest/InvalidURITest.java index 128a190..d0d0668 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/InvalidURITest.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/InvalidURITest.java @@ -36,7 +36,7 @@ public class InvalidURITest extends AbstractSpringRestTest { String endpoint = "/aai1/v11/cloud-infrastructure/pservers/pserver/test"; - ResponseEntity responseEntity; + ResponseEntity<String> responseEntity; responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class); String body = responseEntity.getBody().toString(); diff --git a/aai-resources/src/test/java/org/onap/aai/rest/PserverGenerateUrlTest.java b/aai-resources/src/test/java/org/onap/aai/rest/PserverGenerateUrlTest.java index a4277fb..b59b134 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/PserverGenerateUrlTest.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/PserverGenerateUrlTest.java @@ -32,7 +32,12 @@ import java.util.Collections; import java.util.UUID; import org.junit.Test; -import org.springframework.http.*; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; public class PserverGenerateUrlTest extends AbstractSpringRestTest { @@ -41,7 +46,7 @@ public class PserverGenerateUrlTest extends AbstractSpringRestTest { String endpoint = "/aai/v11/cloud-infrastructure/pservers/pserver/test" + UUID.randomUUID().toString(); - ResponseEntity responseEntity = null; + ResponseEntity<String> responseEntity = null; responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class); assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode()); @@ -66,7 +71,7 @@ public class PserverGenerateUrlTest extends AbstractSpringRestTest { assertEquals(HttpStatus.NO_CONTENT, responseEntity.getStatusCode()); } - private HttpEntity plainHttpEntity() throws UnsupportedEncodingException { + private HttpEntity<String> plainHttpEntity() throws UnsupportedEncodingException { HttpHeaders headers = new HttpHeaders(); @@ -77,6 +82,6 @@ public class PserverGenerateUrlTest extends AbstractSpringRestTest { String authorization = Base64.getEncoder().encodeToString("AAI:AAI".getBytes("UTF-8")); headers.add("Authorization", "Basic " + authorization); - return new HttpEntity(headers); + return new HttpEntity<String>(headers); } } diff --git a/aai-resources/src/test/java/org/onap/aai/rest/PserverMissingTest.java b/aai-resources/src/test/java/org/onap/aai/rest/PserverMissingTest.java index e59b772..e6a185e 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/PserverMissingTest.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/PserverMissingTest.java @@ -24,11 +24,20 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.StringContains.containsString; import static org.junit.Assert.assertEquals; -import java.util.*; +import java.util.Base64; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; import org.junit.Test; import org.onap.aai.PayloadUtil; -import org.springframework.http.*; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; public class PserverMissingTest extends AbstractSpringRestTest { @@ -51,10 +60,10 @@ public class PserverMissingTest extends AbstractSpringRestTest { templateMap.put("hostname", id); String body = PayloadUtil.getTemplatePayload("pserver.json", templateMap); - httpEntity = new HttpEntity(body, headers); + httpEntity = new HttpEntity<String>(body, headers); baseUrl = "http://localhost:" + randomPort; - ResponseEntity responseEntity; + ResponseEntity<String> responseEntity; responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode()); @@ -73,10 +82,10 @@ public class PserverMissingTest extends AbstractSpringRestTest { String authorization = Base64.getEncoder().encodeToString("AAI:AAI".getBytes("UTF-8")); headers.add("Authorization", "Basic " + authorization); - httpEntity = new HttpEntity(headers); + httpEntity = new HttpEntity<String>(headers); baseUrl = "http://localhost:" + randomPort; - ResponseEntity responseEntity; + ResponseEntity<String> responseEntity; responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class); String body = responseEntity.getBody().toString(); diff --git a/aai-resources/src/test/java/org/onap/aai/rest/PserverRelationshipTest.java b/aai-resources/src/test/java/org/onap/aai/rest/PserverRelationshipTest.java index 6e52df0..f6917cf 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/PserverRelationshipTest.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/PserverRelationshipTest.java @@ -45,7 +45,7 @@ public class PserverRelationshipTest extends AbstractSpringRestTest { String endpoint = "/aai/v12/cloud-infrastructure/pservers/pserver/test/relationship-list/relationship"; - ResponseEntity responseEntity = null; + ResponseEntity<String> responseEntity = null; responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class); String body = responseEntity.getBody().toString(); @@ -67,7 +67,7 @@ public class PserverRelationshipTest extends AbstractSpringRestTest { String hostname = "test-pserver1"; String endpoint = "/aai/v12/cloud-infrastructure/pservers/pserver/" + hostname; - ResponseEntity responseEntity = null; + ResponseEntity<String> responseEntity = null; restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); @@ -81,10 +81,10 @@ public class PserverRelationshipTest extends AbstractSpringRestTest { map.put("cloud-owner", cloudOwnerId); String payload = PayloadUtil.getTemplatePayload("pserver-to-cloud-region.json", map); - httpEntity = new HttpEntity(payload, headers); + httpEntity = new HttpEntity<String>(payload, headers); restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); - httpEntity = new HttpEntity(headers); + httpEntity = new HttpEntity<String>(headers); responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class); assertThat(responseEntity.getBody().toString(), containsString("relationship-label")); diff --git a/aai-resources/src/test/java/org/onap/aai/rest/PserverTest.java b/aai-resources/src/test/java/org/onap/aai/rest/PserverTest.java index b7dc836..f23abd2 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/PserverTest.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/PserverTest.java @@ -49,7 +49,7 @@ public class PserverTest extends AbstractSpringRestTest { String endpoint = "/aai/v11/cloud-infrastructure/pservers/pserver/test" + UUID.randomUUID().toString(); - ResponseEntity responseEntity = null; + ResponseEntity<String> responseEntity = null; responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class); assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode()); diff --git a/aai-resources/src/test/java/org/onap/aai/rest/PserverWrongHeaderTest.java b/aai-resources/src/test/java/org/onap/aai/rest/PserverWrongHeaderTest.java index a1b8cec..4c93f58 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/PserverWrongHeaderTest.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/PserverWrongHeaderTest.java @@ -27,7 +27,11 @@ import static org.junit.Assert.assertThat; import java.util.UUID; import org.junit.Test; -import org.springframework.http.*; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; public class PserverWrongHeaderTest extends AbstractSpringRestTest { @@ -36,11 +40,11 @@ public class PserverWrongHeaderTest extends AbstractSpringRestTest { HttpHeaders httpHeaders = new HttpHeaders(); - httpEntity = new HttpEntity(httpHeaders); + httpEntity = new HttpEntity<String>(httpHeaders); String endpoint = "/aai/v11/cloud-infrastructure/pservers/pserver/test" + UUID.randomUUID().toString(); - ResponseEntity responseEntity; + ResponseEntity<String> responseEntity; responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class); String body = responseEntity.getBody().toString(); diff --git a/aai-resources/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java b/aai-resources/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java index ed7f274..d729266 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java @@ -118,7 +118,7 @@ public class RetiredConsumerSpringTest extends AbstractSpringRestTest { protected void executeRestCalls() { httpStatusMap.forEach((url, status) -> { - ResponseEntity responseEntity; + ResponseEntity<String> responseEntity; responseEntity = restTemplate.exchange(baseUrl + url, HttpMethod.GET, httpEntity, String.class); LOGGER.debug("For url {} expected status {} actual status {} and body {}", url, status, responseEntity.getStatusCodeValue(), responseEntity.getBody()); |