aboutsummaryrefslogtreecommitdiffstats
path: root/aai-schema-service/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'aai-schema-service/src/test')
-rw-r--r--aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java2
-rw-r--r--aai-schema-service/src/test/java/org/onap/aai/schemaservice/WebClientConfiguration.java32
-rw-r--r--aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/NodeSchemaChecksumResourceTest.java65
-rw-r--r--aai-schema-service/src/test/resources/application.properties (renamed from aai-schema-service/src/test/resources/application-test.properties)4
4 files changed, 101 insertions, 2 deletions
diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java
index 49c3c33..f2f91cb 100644
--- a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java
+++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java
@@ -49,7 +49,7 @@ import org.springframework.web.client.RestTemplate;
@SpringBootTest(
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes = SchemaServiceApp.class)
-@TestPropertySource(locations = "classpath:application-test.properties")
+// @TestPropertySource(locations = "classpath:application-test.properties")
@ContextConfiguration(initializers = PropertyPasswordConfiguration.class)
@Import(SchemaServiceTestConfiguration.class)
public class SchemaServiceTest {
diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/WebClientConfiguration.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/WebClientConfiguration.java
new file mode 100644
index 0000000..613e3d9
--- /dev/null
+++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/WebClientConfiguration.java
@@ -0,0 +1,32 @@
+package org.onap.aai.schemaservice;
+
+import java.time.Duration;
+import java.util.Collections;
+
+import org.onap.aai.schemaservice.nodeschema.SchemaVersions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.TestConfiguration;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.http.MediaType;
+import org.springframework.test.web.reactive.server.WebTestClient;
+
+@TestConfiguration
+public class WebClientConfiguration {
+
+ @Lazy
+ @Bean
+ WebTestClient webTestClient(@LocalServerPort int port) {
+ return WebTestClient.bindToServer()
+ .baseUrl("http://localhost:" + port + "/aai/schema-service")
+ .responseTimeout(Duration.ofSeconds(300))
+ .defaultHeaders(headers -> {
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ headers.set("X-FromAppId", "test");
+ headers.set("X-TransactionId", "someTransaction");
+ headers.setBasicAuth("AAI", "AAI");
+ })
+ .build();
+ }
+}
diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/NodeSchemaChecksumResourceTest.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/NodeSchemaChecksumResourceTest.java
new file mode 100644
index 0000000..b22940d
--- /dev/null
+++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/NodeSchemaChecksumResourceTest.java
@@ -0,0 +1,65 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+*/
+
+package org.onap.aai.schemaservice.nodeschema;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.schemaservice.WebClientConfiguration;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Import;
+import org.springframework.test.web.reactive.server.WebTestClient;
+
+import org.onap.aai.schemaservice.nodeschema.SchemaVersion;
+
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@Import(WebClientConfiguration.class)
+public class NodeSchemaChecksumResourceTest {
+
+ @Autowired
+ WebTestClient client;
+
+ @Autowired
+ SchemaVersions schemaVersions;
+
+ @BeforeAll
+ public static void setupConfig() throws AAIException {
+ System.setProperty("AJSC_HOME", "./");
+ System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/");
+ System.out.println("Current directory: " + System.getProperty("user.dir"));
+ }
+
+ @Test
+ public void thatChecksumsCanBeRetrieved() {
+ ChecksumResponse response = client.get()
+ .uri("/v1/nodes/checksums")
+ .exchange()
+ .expectStatus().isOk()
+ .returnResult(ChecksumResponse.class)
+ .getResponseBody()
+ .blockFirst();
+ assertEquals(schemaVersions.getVersions().size(), response.getChecksumMap().size());
+ }
+
+}
diff --git a/aai-schema-service/src/test/resources/application-test.properties b/aai-schema-service/src/test/resources/application.properties
index 03781bc..a711688 100644
--- a/aai-schema-service/src/test/resources/application-test.properties
+++ b/aai-schema-service/src/test/resources/application.properties
@@ -1,6 +1,8 @@
spring.application.name=aai-schema-service
spring.jersey.type=filter
+spring.main.allow-bean-definition-overriding=true
+
server.servlet.context-path=${schema.uri.base.path}
spring.autoconfigure.exclude=\
@@ -40,7 +42,7 @@ schema.ingest.file=${server.local.startpath}/application.properties
# Schema Version Related Attributes
schema.uri.base.path=/aai/schema-service
# Lists all of the versions in the schema
-schema.version.list=v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20,v20,v21,v22,v23,v24,v25,v26,v27,v28,v29,v30
+schema.version.list=v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20,v21,v22,v23,v24,v25,v26,v27,v28,v29,v30
# Specifies from which version should the depth parameter to default to zero
schema.version.depth.start=v10
# Specifies from which version should the related link be displayed in response payload