}
private <T> void throwIfPriorityAnnotationAbsent(Collection<Class<? extends T>> classes) {
- for (Class clazz : classes) {
+ for (Class<? extends T> clazz : classes) {
if (!clazz.isAnnotationPresent(Priority.class)) {
throw new MissingFilterPriorityException(clazz);
}
public JerseyTagsProvider jerseyTagsProvider() {
return new JerseyTagsProvider() {
@Override
- public Iterable httpRequestTags(RequestEvent event) {
+ public Iterable<Tag> httpRequestTags(RequestEvent event) {
ContainerResponse response = event.getContainerResponse();
return Tags.of(JerseyTags.method(event.getContainerRequest()), JerseyTags.exception(event),
JerseyTags.status(response), JerseyTags.outcome(response), getAaiUriTag(event));
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)
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());
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());
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());
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());
}
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;
@LocalServerPort
protected int randomPort;
- protected HttpEntity httpEntity;
+ protected HttpEntity<String> httpEntity;
protected String baseUrl;
protected HttpHeaders headers;
headers.add("X-TransactionId", "JUNIT");
headers.add("Authorization", "Basic " + authorization);
- httpEntity = new HttpEntity(headers);
+ httpEntity = new HttpEntity<String>(headers);
baseUrl = "http://localhost:" + randomPort;
}
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());
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;
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());
@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"
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 {
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"));
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());
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();
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 {
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());
assertEquals(HttpStatus.NO_CONTENT, responseEntity.getStatusCode());
}
- private HttpEntity plainHttpEntity() throws UnsupportedEncodingException {
+ private HttpEntity<String> plainHttpEntity() throws UnsupportedEncodingException {
HttpHeaders headers = new HttpHeaders();
String authorization = Base64.getEncoder().encodeToString("AAI:AAI".getBytes("UTF-8"));
headers.add("Authorization", "Basic " + authorization);
- return new HttpEntity(headers);
+ return new HttpEntity<String>(headers);
}
}
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 {
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());
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();
import org.junit.Test;
import org.onap.aai.PayloadUtil;
-import org.onap.aai.util.MapperUtil;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
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();
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);
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"));
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());
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 {
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();
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());