aboutsummaryrefslogtreecommitdiffstats
path: root/a1-policy-management/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'a1-policy-management/src/test')
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java29
1 files changed, 23 insertions, 6 deletions
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java
index 87589f22..100e841c 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java
@@ -30,6 +30,9 @@ import static org.mockito.Mockito.doReturn;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.time.Instant;
@@ -37,6 +40,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import org.json.JSONObject;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -202,6 +206,18 @@ class ApplicationTest {
}
@Test
+
+ void createApiDoc() throws FileNotFoundException {
+ String url = "https://localhost:" + this.port + "/v2/api-docs";
+ ResponseEntity<String> resp = restClient("", false).getForEntity(url).block();
+ assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.OK);
+ String indented = (new JSONObject(resp.getBody())).toString(4);
+ try (PrintStream out = new PrintStream(new FileOutputStream("api/api_generated.json"))) {
+ out.print(indented);
+ }
+ }
+
+ @Test
void testGetRics() throws Exception {
addRic("ric1");
this.addPolicyType("type1", "ric1");
@@ -729,10 +745,6 @@ class ApplicationTest {
}
}
- private String baseUrl() {
- return "https://localhost:" + port + Consts.V2_API_ROOT;
- }
-
private String jsonString() {
return "{\"servingCellNrcgi\":\"1\"}";
}
@@ -766,7 +778,7 @@ class ApplicationTest {
logger.info("Concurrency test took " + Duration.between(startTime, Instant.now()));
}
- private AsyncRestClient restClient(boolean useTrustValidation) {
+ private AsyncRestClient restClient(String baseUrl, boolean useTrustValidation) {
WebClientConfig config = this.applicationConfig.getWebClientConfig();
config = ImmutableWebClientConfig.builder() //
.keyStoreType(config.keyStoreType()) //
@@ -778,7 +790,12 @@ class ApplicationTest {
.trustStorePassword(config.trustStorePassword()) //
.build();
- return new AsyncRestClient(baseUrl(), config);
+ return new AsyncRestClient(baseUrl, config);
+ }
+
+ private AsyncRestClient restClient(boolean useTrustValidation) {
+ String baseUrl = "https://localhost:" + port + Consts.V2_API_ROOT;
+ return restClient(baseUrl, useTrustValidation);
}
private AsyncRestClient restClient() {