summaryrefslogtreecommitdiffstats
path: root/aai-resources/src/test
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-08-27 07:57:29 +0200
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-08-29 07:46:38 +0200
commit222f8efa881e940a4a3529706e067d0cefb6db99 (patch)
treedb74c86336ddb2835a1917ede99b94372661bca3 /aai-resources/src/test
parent87502d28e8b2edd55dabf0186a8e2ac233388886 (diff)
Create request interceptor class to remove namespace attribute from xml request bodies
- add interceptor that removes xmlns attribute from xml bodies - update eclipse persistence (2.6.2 -> 2.7.7) - use spring-boot-starter-test instead of spring framework's spring-test - bump snapshot version to 1.14.7-SNAPSHOT - remove unused imports Issue-ID: AAI-3976 Change-Id: Iac7103ae003cb7bb7269ada983af97e003be155c Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Diffstat (limited to 'aai-resources/src/test')
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/BulkProcessorTestAbstraction.java1
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java26
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/ExampleConsumerTest.java1
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/URLFromVertexIdConsumerTest.java1
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/VertexIdConsumerTest.java1
-rw-r--r--aai-resources/src/test/resources/application-test.properties2
-rw-r--r--aai-resources/src/test/resources/logback.xml2
7 files changed, 19 insertions, 15 deletions
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessorTestAbstraction.java b/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessorTestAbstraction.java
index 706da69..f734360 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessorTestAbstraction.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessorTestAbstraction.java
@@ -37,7 +37,6 @@ import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.mockito.Mockito;
import org.onap.aai.AAISetup;
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 21f2fb4..b780d90 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
@@ -41,6 +41,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
import org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration;
+import org.springframework.boot.test.autoconfigure.actuate.metrics.AutoConfigureMetrics;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.context.annotation.Import;
@@ -58,6 +59,7 @@ import org.springframework.web.client.RestTemplate;
* Test REST requests against configuration resource
*/
+@AutoConfigureMetrics
@TestPropertySource(locations = "classpath:application-test.properties")
@ContextConfiguration(initializers = PropertyPasswordConfiguration.class, classes = {SpringContextAware.class})
@EnableAutoConfiguration(exclude={CassandraDataAutoConfiguration.class, CassandraAutoConfiguration.class}) // there is no running cassandra instance for the test
@@ -66,6 +68,7 @@ import org.springframework.web.client.RestTemplate;
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes = {SpringContextAware.class, ResourcesApp.class})
public class ConfigurationTest extends AbstractSpringRestTest {
+
@Autowired
RestTemplate restTemplate;
@@ -92,7 +95,7 @@ public class ConfigurationTest extends AbstractSpringRestTest {
headersGet.add("X-FromAppId", "JUNIT");
headersGet.add("X-TransactionId", "JUNIT");
- headersGet.setBasicAuth("AAI","AAI");
+ headersGet.setBasicAuth("AAI", "AAI");
headersPutPatch = new HttpHeaders();
headersPutPatch.putAll(headersGet);
@@ -112,7 +115,8 @@ public class ConfigurationTest extends AbstractSpringRestTest {
responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntityGet, String.class);
assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode());
- // String putBody = " configuration-id, configuration-type configuration-sub-type";
+ // String putBody = " configuration-id, configuration-type
+ // configuration-sub-type";
String putBody = "{" + "\"configuration-id\": \"" + cid + "\"," + "\"configuration-type\": \"type1\","
+ "\"configuration-sub-type\": \"subtype1\", " + "\"operational-status\": \"example1\", "
+ "\"orchestration-status\": \"example1\", " + "\"configuration-selflink\": \"example1\", "
@@ -171,29 +175,31 @@ public class ConfigurationTest extends AbstractSpringRestTest {
ResponseEntity<String> responseEntity = null;
String responseBody = null;
- // set Accept as text/plain in order to get access of endpoint "/actuator/prometheus"
+ // set Accept as text/plain in order to get access of endpoint
+ // "/actuator/prometheus"
headersGet.set("Accept", "text/plain");
headersGet.setAccept(Arrays.asList(MediaType.TEXT_PLAIN));
httpEntityGet = new HttpEntity<String>(headersGet);
- responseEntity =
- restTemplate.exchange(actuatorurl + "/actuator/prometheus", HttpMethod.GET, httpEntityGet, String.class);
+ responseEntity = restTemplate.exchange(actuatorurl + "/actuator/prometheus", HttpMethod.GET, httpEntityGet,
+ String.class);
responseBody = (String) responseEntity.getBody();
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
assertTrue(responseBody.contains("group_id"));
assertTrue(responseBody.contains("aai_uri"));
- // Set Accept as MediaType.APPLICATION_JSON in order to get access of endpoint "/actuator/info" and
+ // Set Accept as MediaType.APPLICATION_JSON in order to get access of endpoint
+ // "/actuator/info" and
// "/actuator/health"
headersGet.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
httpEntityGet = new HttpEntity<String>(headersGet);
- responseEntity =
- restTemplate.exchange(actuatorurl + "/actuator/info", HttpMethod.GET, httpEntityGet, String.class);
+ responseEntity = restTemplate.exchange(actuatorurl + "/actuator/info", HttpMethod.GET, httpEntityGet,
+ String.class);
responseBody = (String) responseEntity.getBody();
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
assertTrue(responseBody.contains("aai-resources"));
- responseEntity =
- restTemplate.exchange(actuatorurl + "/actuator/health", HttpMethod.GET, httpEntityGet, String.class);
+ responseEntity = restTemplate.exchange(actuatorurl + "/actuator/health", HttpMethod.GET, httpEntityGet,
+ String.class);
responseBody = (String) responseEntity.getBody();
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
assertTrue(responseBody.contains("UP"));
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/ExampleConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/ExampleConsumerTest.java
index 73eed51..b48cdb2 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/ExampleConsumerTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/ExampleConsumerTest.java
@@ -38,7 +38,6 @@ import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/URLFromVertexIdConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/URLFromVertexIdConsumerTest.java
index e515098..e97a43a 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/URLFromVertexIdConsumerTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/URLFromVertexIdConsumerTest.java
@@ -41,7 +41,6 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.json.JSONException;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/VertexIdConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/VertexIdConsumerTest.java
index 8c62950..d0455b1 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/VertexIdConsumerTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/VertexIdConsumerTest.java
@@ -41,7 +41,6 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.json.JSONException;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
diff --git a/aai-resources/src/test/resources/application-test.properties b/aai-resources/src/test/resources/application-test.properties
index 253a191..b4cd460 100644
--- a/aai-resources/src/test/resources/application-test.properties
+++ b/aai-resources/src/test/resources/application-test.properties
@@ -76,6 +76,8 @@ schema.translator.list=config
#To expose the Prometheus scraping endpoint in unit test
management.server.port=0
+management.endpoint.metrics.enabled=true
+management.endpoint.prometheus.enabled=true
management.endpoints.enabled-by-default=true
management.endpoints.web.exposure.include=info, health, prometheus
management.metrics.web.server.request.autotime.enabled=false
diff --git a/aai-resources/src/test/resources/logback.xml b/aai-resources/src/test/resources/logback.xml
index a550336..80050ca 100644
--- a/aai-resources/src/test/resources/logback.xml
+++ b/aai-resources/src/test/resources/logback.xml
@@ -269,7 +269,7 @@
<logger name="org.testcontainers" level="INFO"/>
<logger name="com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.wire" level="OFF"/>
- <root level="DEBUG">
+ <root level="INFO">
<appender-ref ref="external" />
<appender-ref ref="STDOUT" />
</root>