summaryrefslogtreecommitdiffstats
path: root/a1-policy-management/src/test
diff options
context:
space:
mode:
authorPatrikBuhr <patrik.buhr@est.tech>2020-08-21 11:35:17 +0200
committerPatrik Buhr <patrik.buhr@est.tech>2020-08-25 13:32:57 +0000
commit4b4404a2ab0b239a1cc17510196195ec599d66ae (patch)
tree0930db90300985f24c2a63fac56ce903d7076859 /a1-policy-management/src/test
parent923196e662717d8e631d89d29818b88db17e320a (diff)
Some improvements if NBI V2.0
Improved generated swagger API. Furter alignments to https://opensource.zalando.com/restful-api-guidelines/#118 Improved unitttest for faulty JSON in configuration. Changed names: "NonRT-RIC" to "Non-RT RIC" and "NearRT-RIC" to "Near-RT RIC" Change-Id: I4ca0d45605a770b5c33e34019671e088e3fe979d Issue-ID: CCSDK-2498 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
Diffstat (limited to 'a1-policy-management/src/test')
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/ApplicationTestV2.java2
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java35
2 files changed, 11 insertions, 26 deletions
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/ApplicationTestV2.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/ApplicationTestV2.java
index 3a7068d6..591b29c9 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/ApplicationTestV2.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/ApplicationTestV2.java
@@ -255,7 +255,7 @@ class ApplicationTestV2 {
Policy policy2 = addPolicy("policyId2", "typeName", "service", ric1Name);
Ric ric2 = addRic("ric2");
- getA1Client(ric1Name).putPolicy(policy2); // put it in the RIC (NearRT-RIC)
+ getA1Client(ric1Name).putPolicy(policy2); // put it in the RIC (Near-RT RIC)
policies.remove(policy2); // Remove it from the repo -> should be deleted in the RIC
String policyId = "policyId";
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java
index 72b20600..572ba0b5 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java
@@ -144,21 +144,6 @@ class RefreshConfigTaskTest {
}
@Test
- void startWithStubbedRefreshReturnError_thenErrorAndTerminationLogged() {
- refreshTaskUnderTest = this.createTestObject(CONFIG_FILE_DOES_NOT_EXIST, null, null, false);
- String errorMessage = "Error";
- doReturn(Flux.error(new Exception(errorMessage))).when(refreshTaskUnderTest).createRefreshTask();
-
- final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, ERROR);
-
- refreshTaskUnderTest.start();
-
- ILoggingEvent event = logAppender.list.get(0);
- assertThat(event.getFormattedMessage())
- .isEqualTo("Configuration refresh terminated due to exception java.lang.Exception: " + errorMessage);
- }
-
- @Test
void stop_thenTaskIsDisposed() throws Exception {
refreshTaskUnderTest = this.createTestObject(CONFIG_FILE_DOES_NOT_EXIST, null, null, false);
refreshTaskUnderTest.systemEnvironment = new Properties();
@@ -202,7 +187,8 @@ class RefreshConfigTaskTest {
refreshTaskUnderTest.systemEnvironment = new Properties();
// When
- doReturn(getIncorrectJson()).when(refreshTaskUnderTest).createInputStream(any());
+ final String JUNK_JSON = "{\"junk }";
+ doReturn(getJsonSteam(JUNK_JSON)).when(refreshTaskUnderTest).createInputStream(any());
doReturn("fileName").when(appConfig).getLocalConfigurationFilePath();
final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, ERROR);
@@ -269,7 +255,7 @@ class RefreshConfigTaskTest {
doReturn(Mono.just(props)).when(refreshTaskUnderTest).getEnvironment(any());
doReturn(Mono.just(cbsClient)).when(refreshTaskUnderTest).createCbsClient(props);
- JsonObject configAsJson = getJsonRootObject(true);
+ JsonObject configAsJson = getJsonRootObject(getCorrectJson());
String newBaseUrl = "newBaseUrl";
modifyTheRicConfiguration(configAsJson, newBaseUrl);
when(cbsClient.get(any())).thenReturn(Mono.just(configAsJson));
@@ -309,8 +295,8 @@ class RefreshConfigTaskTest {
doReturn(Mono.just(props)).when(refreshTaskUnderTest).getEnvironment(any());
doReturn(Mono.just(cbsClient)).when(refreshTaskUnderTest).createCbsClient(props);
- JsonObject configAsJson = getJsonRootObject(false);
- when(cbsClient.get(any())).thenReturn(Mono.just(configAsJson));
+ JsonObject emptyJsonObject = new JsonObject();
+ when(cbsClient.get(any())).thenReturn(Mono.just(emptyJsonObject));
final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, ERROR);
@@ -368,9 +354,9 @@ class RefreshConfigTaskTest {
.addProperty("baseUrl", newBaseUrl);
}
- private JsonObject getJsonRootObject(boolean valid) throws JsonIOException, JsonSyntaxException, IOException {
- JsonObject rootObject = JsonParser
- .parseReader(new InputStreamReader(valid ? getCorrectJson() : getIncorrectJson())).getAsJsonObject();
+ private JsonObject getJsonRootObject(InputStream inStream)
+ throws JsonIOException, JsonSyntaxException, IOException {
+ JsonObject rootObject = JsonParser.parseReader(new InputStreamReader(inStream)).getAsJsonObject();
return rootObject;
}
@@ -380,8 +366,7 @@ class RefreshConfigTaskTest {
return new ByteArrayInputStream((string.getBytes(StandardCharsets.UTF_8)));
}
- private static InputStream getIncorrectJson() {
- String string = "{}"; //
- return new ByteArrayInputStream((string.getBytes(StandardCharsets.UTF_8)));
+ private static InputStream getJsonSteam(String json) {
+ return new ByteArrayInputStream((json.getBytes(StandardCharsets.UTF_8)));
}
}