aboutsummaryrefslogtreecommitdiffstats
path: root/aai-schema-service/src/test/java/org
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-12-08 20:41:19 +0100
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-12-09 08:39:06 +0100
commit31bb930755b5b350bedb2ab0bc18f0ec820c17f8 (patch)
tree577b8fb8ce2960a35b5b07632a8584c60fd610db /aai-schema-service/src/test/java/org
parent8b018d4f1c8a2dbc7bf68aa3275d6756b814cd0a (diff)
Add checksum endpoint to schema-service
- provide endpoint that allows consumers to check if schema creation is necessary - this can be used for the schema creation job to only run when the schema changed Issue-ID: AAI-4084 Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de> Change-Id: I831f8c134b548f460eda26570d45f99f28e048a4
Diffstat (limited to 'aai-schema-service/src/test/java/org')
-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
3 files changed, 98 insertions, 1 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());
+ }
+
+}